Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(mcp): detect MSIX-packaged Claude Desktop config path on Windows
zapatalb8f8316ab7aa
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3183aca0..5624f31b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0client of the running server; the command now requires a reachableserver and no longer works against an offline data directory.+### Fixed+- `install-mcp --client claude-desktop` now detects an MSIX-packaged+ Claude Desktop on Windows (the default distribution since February+ 2026) and writes to its virtualized+ `AppData\Local\Packages\Claude_<id>\LocalCache\Roaming\Claude\claude_desktop_config.json`+ instead of the plain `%APPDATA%\Claude\` path, which a packaged,+ AppContainer-sandboxed Claude Desktop never reads. Previously this+ silently wrote a config file the running app ignored, so the MCP+ server never appeared after restart. Unpackaged/legacy installs are+ unaffected and keep resolving to the plain path.+## [1.18.0] - 2026-07-23### Addeddiff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rsindex 04785a9c..c9efad0d 100644--- a/crates/ai-memory-cli/src/commands/install_mcp.rs+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs@@ -132,12 +132,27 @@ pub(crate) fn mcp_config_path(client: crate::cli::McpClient) -> Result<PathBuf>}#[cfg(target_os = "windows")]{- // %APPDATA% is roughly ~/AppData/Roaming.- home()?- .join("AppData")- .join("Roaming")- .join("Claude")- .join("claude_desktop_config.json")+ // Since Anthropic's Feb 2026 move to MSIX packaging, a+ // packaged Claude Desktop is an AppContainer: it never+ // sees the real, shared %APPDATA% this unpackaged binary+ // writes to. Windows silently virtualizes well-known+ // paths for packaged processes into an isolated+ // `AppData\Local\Packages\<PackageFamilyName>\LocalCache\...`+ // tree instead — writing to the plain path produces a+ // file the running app will never read (issue found+ // 2026-07-16). Prefer the packaged location when a+ // `Claude_*` package is present; only unpackaged/legacy+ // Squirrel installs fall back to the plain path.+ let home = home()?;+ let local_packages_dir = home.join("AppData").join("Local").join("Packages");+ match packaged_claude_desktop_config_path(&local_packages_dir) {+ Some(packaged) => packaged,+ None => home+ .join("AppData")+ .join("Roaming")+ .join("Claude")+ .join("claude_desktop_config.json"),+ }}#[cfg(not(any(target_os = "macos", target_os = "windows")))]{@@ -178,6 +193,41 @@ pub(crate) fn mcp_config_path(client: crate::cli::McpClient) -> Result<PathBuf>})}+/// Windows-only detection for an MSIX/AppX-packaged Claude Desktop.+/// `local_packages_dir` is normally `%LOCALAPPDATA%\Packages`; a packaged+/// Claude Desktop registers a `Claude_<PackageFamilyName>`-style directory+/// there regardless of whether the app has ever been launched (Windows+/// creates the package directory at install time, but the `LocalCache`+/// subtree lazily on first run — so this checks for the package directory+/// itself, not the config file, and lets the caller's atomic-write path+/// create the remaining subdirectories). Returns `None` when no such+/// directory exists (unpackaged/legacy Squirrel install, or a non-Windows+/// test double), so callers fall back to the plain path. Sorted so the+/// result is deterministic on the (unexpected) chance more than one+/// `Claude_*` directory exists.+fn packaged_claude_desktop_config_path(local_packages_dir: &Path) -> Option<PathBuf> {+ let mut candidates: Vec<PathBuf> = std::fs::read_dir(local_packages_dir)+ .ok()?+ .filter_map(|entry| entry.ok())+ .map(|entry| entry.path())+ .filter(|path| {+ path.is_dir()+ && path+ .file_name()+ .and_then(|name| name.to_str())+ .is_some_and(|name| name.starts_with("Claude_"))+ })+ .collect();+ candidates.sort();+ candidates.into_iter().next().map(|package_dir| {+ package_dir+ .join("LocalCache")+ .join("Roaming")+ .join("Claude")+ .join("claude_desktop_config.json")+ })+}+/// Claude Code reads MCP-server registrations from `.claude.json`/// (the same file `claude mcp add`/`claude mcp list` operate on) —/// `$CLAUDE_CONFIG_DIR/.claude.json` when the var is set, else@@ -967,6 +1017,44 @@ mod tests {}}+ #[test]+ fn packaged_claude_desktop_path_prefers_localcache_when_package_dir_exists() {+ let packages = tempfile::TempDir::new().unwrap();+ fs::create_dir_all(packages.path().join("Claude_pzs8sxrjxfjjc")).unwrap();++ let found = packaged_claude_desktop_config_path(packages.path()).unwrap();+ assert_eq!(+ found,+ packages+ .path()+ .join("Claude_pzs8sxrjxfjjc")+ .join("LocalCache")+ .join("Roaming")+ .join("Claude")+ .join("claude_desktop_config.json")+ );+ }++ #[test]+ fn packaged_claude_desktop_path_ignores_unrelated_and_non_dir_entries() {+ let packages = tempfile::TempDir::new().unwrap();+ fs::create_dir_all(packages.path().join("Microsoft.WindowsTerminal_abc123")).unwrap();+ fs::write(packages.path().join("Claude_notadir"), b"").unwrap();++ assert!(packaged_claude_desktop_config_path(packages.path()).is_none());+ }++ #[test]+ fn packaged_claude_desktop_path_none_when_packages_dir_absent_or_empty() {+ let missing = tempfile::TempDir::new().unwrap();+ assert!(+ packaged_claude_desktop_config_path(&missing.path().join("does-not-exist")).is_none()+ );++ let empty = tempfile::TempDir::new().unwrap();+ assert!(packaged_claude_desktop_config_path(empty.path()).is_none());+ }+#[test]fn claude_code_render_shows_resolved_config_path() {let args = args_for(McpClient::ClaudeCode);diff --git a/docs/mcp-install.md b/docs/mcp-install.mdindex 15e8fa50..a2cf1fb1 100644--- a/docs/mcp-install.md+++ b/docs/mcp-install.md@@ -238,7 +238,12 @@ Aliases: `copilot`, `github-copilot`.**Config file:**- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`-- Windows: `%APPDATA%\Claude\claude_desktop_config.json`+- Windows: `%APPDATA%\Claude\claude_desktop_config.json` for an+ unpackaged/legacy install, or `%LOCALAPPDATA%\Packages\Claude_<id>\LocalCache\Roaming\Claude\claude_desktop_config.json`+ for the MSIX-packaged install Anthropic has shipped by default since+ February 2026 — `install-mcp` detects which one applies automatically+ by checking for a `Claude_*` directory under+ `%LOCALAPPDATA%\Packages`.- Linux: not officially distributed by Anthropic. Use Claude Code(terminal) instead.@@ -271,6 +276,15 @@ stdio shim. Requires Node.js installed on the same machine.- If the MCP indicator doesn't appear after restart, check the logs:`~/Library/Logs/Claude/mcp*.log` (macOS) or `%APPDATA%\Claude\logs\`(Windows).+- **Windows MSIX packaging:** a packaged Claude Desktop is an+ AppContainer — Windows virtualizes `%APPDATA%` for it into an isolated+ `AppData\Local\Packages\Claude_<id>\LocalCache\Roaming\` tree that an+ unpackaged process (like this CLI) never sees at the plain path.+ `install-mcp --client claude-desktop --apply` detects this and writes+ to the packaged location automatically; if you're on an older build of+ this CLI without that detection, pass `--config-file` pointed at the+ `LocalCache` path directly (find the exact `Claude_<id>` folder name+ under `%LOCALAPPDATA%\Packages`).- Sources: <https://support.claude.com/en/articles/10949351-getting-started-with-local-mcp-servers-on-claude-desktop>,<https://support.claude.com/en/articles/11175166-how-to-connect-remote-mcp-integrations-to-claude>