Skip to content

Commit 4b4ae80

Browse files
gcormierkingpanther13claude
authored
Installer (Windows) - Detect install method (#1039)
* detect if installed via store * update per gemini comments * Address PR feedback: Get-AppxPackage detection + docs pointers Replace the filesystem-glob MSIX detection with `Get-AppxPackage` as the primary path. The package registry is authoritative — it doesn't match the zombie %LOCALAPPDATA%\Packages\Claude_* folders Windows leaves in place (sometimes under Deleted\) for days after an MSIX uninstall, which would otherwise trigger the same silent failure inverted (user moves Store → traditional, installer writes into the dead Store folder). The filesystem probe stays as a fallback for constrained environments (e.g. Windows Sandbox, locked-down PowerShell). It is now pinned to the Anthropic publisher hash `Claude_pzs8sxrjxfjjc` so we don't pick up an unrelated SKU like a hypothetical Anthropic.ClaudeDesktop_*, and gated on a Test-Path of LocalCache\Roaming\Claude so a stale leftover folder can't trigger the silent failure either. Other changes from the review: - Surface "Detected: Microsoft Store install" / "Traditional install" under Step 2 so users notice immediately if detection picks the wrong variant when both installs are present. - Reword the comment that said "under LocalPackages" — the path is %LOCALAPPDATA%\Packages. - Fix a silent rendering bug in site/src/pages/guide-windows.astro: the detection one-liner had raw `{` / `}` inside `<code>`, which Astro parsed as JSX expressions, stripping the curly braces and backslashes from the rendered HTML. Wrap the snippet in a `{`...`}` template literal so braces and backslashes render literally, and switch to the Get-AppxPackage approach for consistency with the installer. - Mirror the snippet in docs/Windows-uv-guide.md (markdown twin of the Astro guide). - Rather than duplicate the detection snippet in every doc that mentions the config path, point the remaining docs to the Windows setup guide: docs/FAQ.md, docs/dev-channel.md, homeassistant-addon/DOCS.md, site/src/content/clients/claude-desktop.md, site/src/data/clients.ts, site/src/pages/faq.astro. Fixes the silent failure reported in #1046 (Microsoft Store install, installer wrote to %APPDATA%, Claude Desktop reads from %LOCALAPPDATA%). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address review-toolkit findings on install-windows.ps1 - Drop the inaccurate "Windows Sandbox" example in the fallback comment; the Appx module ships in the default Sandbox image. Replace with the cases that actually break Get-AppxPackage: Constrained Language Mode under WDAC/AppLocker, Server Core / Nano installs. - Drop the unverifiable "for days" claim on stale package folders. The asynchronous-cleanup behavior is real but no published bound exists, and the next sentence already justifies the hardening. - Tighten the leading comment block — "different installers write to different roots" was borderline WHAT-explanation. - Bump the "Detected:" line to Cyan and echo the resolved $ConfigDir on the next line so users can sanity-check the actual path before the installer writes the config. White-on-default got lost in the rest of the script's output, defeating the point of the line. - Drop a dead try/catch{} around `Get-Command uvx -ErrorAction SilentlyContinue`. The cmdlet's SilentlyContinue already handles "not found"; the catch could only fire on terminating errors and silently swallow them, leaving the user with no signal. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4bbc74b commit 4b4ae80

8 files changed

Lines changed: 52 additions & 12 deletions

File tree

docs/FAQ.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ source ~/.zshrc
212212
1. **Restart Claude completely** - Use Cmd+Q (Mac) or Alt+F4 (Windows), not just close the window
213213
2. **Check config file location:**
214214
- Mac: `~/Library/Application Support/Claude/claude_desktop_config.json`
215-
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
215+
- Windows (traditional installer): `%APPDATA%\Claude\claude_desktop_config.json`
216+
- Windows (Microsoft Store): path varies by package — see the [Windows setup guide](https://homeassistant-ai.github.io/ha-mcp/guide-windows) for a detection snippet
216217
3. **Verify JSON syntax** - No trailing commas, proper quotes
217218
4. **Check the MCP icon** - Bottom left of Claude Desktop shows connected servers
218219

docs/Windows-uv-guide.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ Try asking Claude:
8585

8686
## Step 6: Connect Your Home Assistant
8787

88-
Ready to use your own Home Assistant? Edit the config file:
88+
Ready to use your own Home Assistant? Edit the config file.
89+
90+
If you installed Claude Desktop from the **Microsoft Store**, run this in PowerShell to find your config path:
91+
92+
```powershell
93+
$pkg = Get-AppxPackage -Name Claude -ErrorAction SilentlyContinue | Select-Object -First 1; if ($pkg) { "$env:LOCALAPPDATA\Packages\$($pkg.PackageFamilyName)\LocalCache\Roaming\Claude\claude_desktop_config.json" } else { "$env:APPDATA\Claude\claude_desktop_config.json" }
94+
```
95+
96+
Or open it directly (works for the **traditional installer**):
8997

9098
```powershell
9199
notepad "$env:APPDATA\Claude\claude_desktop_config.json"

docs/dev-channel.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ If you're using Claude Desktop, update your `claude_desktop_config.json`:
159159

160160
**Location:**
161161
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
162-
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
162+
- **Windows (traditional installer):** `%APPDATA%\Claude\claude_desktop_config.json`
163+
- **Windows (Microsoft Store):** path varies by package — see the [Windows setup guide](https://homeassistant-ai.github.io/ha-mcp/guide-windows) for a detection snippet
163164

164165
**For uvx (dev channel):**
165166
```json

homeassistant-addon/DOCS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ Then add to your Claude Desktop configuration file:
6161

6262
**Location:**
6363
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
64-
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
64+
- Windows (traditional installer): `%APPDATA%\Claude\claude_desktop_config.json`
65+
- Windows (Microsoft Store): path varies by package — see the [Windows setup guide](https://homeassistant-ai.github.io/ha-mcp/guide-windows) for a detection snippet
6566

6667
**Configuration:**
6768
```json

scripts/install-windows.ps1

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,34 @@
44

55
$ErrorActionPreference = "Stop"
66

7-
# Configuration
8-
$ConfigDir = "$env:APPDATA\Claude"
7+
# Configuration: detect which Claude Desktop variant is installed so the
8+
# config lands where Claude will actually read it. Get-AppxPackage queries
9+
# the package registry, which is authoritative — it won't match a stale
10+
# %LOCALAPPDATA%\Packages\Claude_* folder left behind after an MSIX uninstall.
11+
try {
12+
$ClaudeAppx = Get-AppxPackage -Name Claude -ErrorAction Stop | Select-Object -First 1
13+
} catch {
14+
$ClaudeAppx = $null
15+
}
16+
17+
if ($ClaudeAppx) {
18+
$ConfigDir = "$env:LOCALAPPDATA\Packages\$($ClaudeAppx.PackageFamilyName)\LocalCache\Roaming\Claude"
19+
$DetectedVariant = "Microsoft Store install"
20+
} else {
21+
# Fallback for environments where Get-AppxPackage isn't usable (e.g.,
22+
# Constrained Language Mode under WDAC/AppLocker, Server Core/Nano).
23+
# Pin to the Anthropic publisher hash so we don't pick up an unrelated
24+
# SKU, and require LocalCache\Roaming\Claude to exist so we don't write
25+
# into a "zombie" folder left behind after an MSIX uninstall.
26+
$MsixPackage = Get-ChildItem "$env:LOCALAPPDATA\Packages" -Filter "Claude_pzs8sxrjxfjjc" -Directory -ErrorAction SilentlyContinue | Select-Object -First 1
27+
if ($MsixPackage -and (Test-Path "$($MsixPackage.FullName)\LocalCache\Roaming\Claude")) {
28+
$ConfigDir = "$($MsixPackage.FullName)\LocalCache\Roaming\Claude"
29+
$DetectedVariant = "Microsoft Store install"
30+
} else {
31+
$ConfigDir = "$env:APPDATA\Claude"
32+
$DetectedVariant = "Traditional install"
33+
}
34+
}
935
$ConfigFile = "$ConfigDir\claude_desktop_config.json"
1036
$DemoUrl = "https://ha-mcp-demo-server.qc-h.net"
1137
$DemoToken = "demo"
@@ -18,10 +44,7 @@ Write-Host ""
1844

1945
# Step 1: Check/install uv
2046
Write-Host "Step 1: Checking for uv..." -ForegroundColor Yellow
21-
$uvInstalled = $null
22-
try {
23-
$uvInstalled = Get-Command uvx -ErrorAction SilentlyContinue
24-
} catch {}
47+
$uvInstalled = Get-Command uvx -ErrorAction SilentlyContinue
2548

2649
if ($uvInstalled) {
2750
Write-Host " uv is already installed" -ForegroundColor Green
@@ -44,6 +67,8 @@ Write-Host ""
4467

4568
# Step 2: Configure Claude Desktop
4669
Write-Host "Step 2: Configuring Claude Desktop..." -ForegroundColor Yellow
70+
Write-Host " Detected: $DetectedVariant" -ForegroundColor Cyan
71+
Write-Host " Config path: $ConfigDir" -ForegroundColor Cyan
4772
$ClaudeNotInstalled = $false
4873
if (-not (Test-Path $ConfigDir)) {
4974
$ClaudeNotInstalled = $true

site/src/pages/faq.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ source ~/.zshrc
223223
<li><strong>Check config file location:</strong>
224224
<ul class="ml-6 mt-1 text-slate-400 list-disc list-inside">
225225
<li>Mac: <code class="bg-slate-800 px-1 rounded text-xs">~/Library/Application Support/Claude/claude_desktop_config.json</code></li>
226-
<li>Windows: <code class="bg-slate-800 px-1 rounded text-xs">%APPDATA%\Claude\claude_desktop_config.json</code></li>
226+
<li>Windows (traditional installer): <code class="bg-slate-800 px-1 rounded text-xs">%APPDATA%\Claude\claude_desktop_config.json</code></li>
227+
<li>Windows (Microsoft Store): path varies by package — see the <a href={withBase('/guide-windows')} class="text-blue-400 hover:underline">Windows setup guide</a> for a detection snippet</li>
227228
</ul>
228229
</li>
229230
<li><strong>Verify JSON syntax</strong> - No trailing commas, proper quotes</li>

site/src/pages/guide-windows.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ const withBase = (path: string) => {
142142
</div>
143143
<div class="step-content">
144144
<p class="text-slate-300 mb-4">Ready to use your own Home Assistant? Edit the config file:</p>
145+
<p class="text-slate-400 text-sm mb-2">If you installed Claude Desktop from the <strong>Microsoft Store</strong>, run this in PowerShell to find your config path:</p>
146+
<pre class="code-block"><code>{`$pkg = Get-AppxPackage -Name Claude -ErrorAction SilentlyContinue | Select-Object -First 1; if ($pkg) { "$env:LOCALAPPDATA\\Packages\\$($pkg.PackageFamilyName)\\LocalCache\\Roaming\\Claude\\claude_desktop_config.json" } else { "$env:APPDATA\\Claude\\claude_desktop_config.json" }`}</code></pre>
147+
<p class="text-slate-400 text-sm mb-2 mt-3">Or open it directly (works for the <strong>traditional installer</strong>):</p>
145148
<pre class="code-block"><code>notepad "$env:APPDATA\Claude\claude_desktop_config.json"</code></pre>
146149

147150
<p class="text-slate-300 mt-4 mb-4">Replace the demo values:</p>

site/src/pages/setup.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const clientsData = [
2424
"logo": "/logos/claude.svg",
2525
"transports": ["stdio"],
2626
"configFormat": "json",
27-
"configLocation": "macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\nWindows: %APPDATA%\\Claude\\claude_desktop_config.json\n",
27+
"configLocation": "macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\nWindows (traditional installer): %APPDATA%\\Claude\\claude_desktop_config.json\nWindows (Microsoft Store): path varies by package — see the Windows setup guide for a detection snippet\n",
2828
"accuracy": 5,
2929
"order": 1,
3030
"httpNote": "Use mcp-proxy for HTTP connections (see Network/Remote setup)",

0 commit comments

Comments
 (0)