Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(install-mcp): write Claude Desktop's config on Linux

AkitaOnRailsc97766d55fe9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 779c81a7..b43a8edc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
the placeholder id `empty-state-draft` and no workspace, and each launch
appended another observation to that one empty session. The server now
acknowledges and drops that placeholder.
+- Fixed `install-mcp --client claude-desktop` refusing to run on Linux:
+ Anthropic ships Claude Desktop for Linux as a beta, and the command now
+ writes `$XDG_CONFIG_HOME/Claude/claude_desktop_config.json` (default
+ `~/.config/Claude/`) instead of requiring `--config-file`.
- Corrected the Claude Desktop documentation: Linux is an Anthropic beta for
Debian-based distributions with its config at
`~/.config/Claude/claude_desktop_config.json` (pass it to
diff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rs
index f425c5ee..477db531 100644
--- a/crates/ai-memory-cli/src/commands/install_mcp.rs
+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs
@@ -269,10 +269,12 @@ pub(crate) fn mcp_config_path_with(
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
{
- bail!(
- "Claude Desktop is not officially distributed for this OS. \
- Pass --config-file explicitly if you know where it lives."
- );
+ // Anthropic's Linux beta keeps Electron's profile, and the
+ // config, under $XDG_CONFIG_HOME/Claude.
+ claude_desktop_config_path_linux(
+ &dirs::config_dir()
+ .context("could not locate the user config directory for Claude Desktop")?,
+ )
}
}
McpClient::GeminiCli => home()?.join(".gemini").join("settings.json"),
@@ -363,6 +365,12 @@ fn zed_config_path_in(config_dir: &Path, target_os: &str) -> PathBuf {
config_dir.join(app_dir).join("settings.json")
}
+/// Claude Desktop's config file under the Linux user config directory.
+#[cfg_attr(any(target_os = "macos", target_os = "windows"), allow(dead_code))]
+fn claude_desktop_config_path_linux(config_dir: &Path) -> PathBuf {
+ config_dir.join("Claude").join("claude_desktop_config.json")
+}
+
#[cfg(any(target_os = "windows", test))]
fn claude_desktop_config_path_in(
local_data_dir: &Path,
@@ -1619,8 +1627,8 @@ fn render_claude_desktop(args: &InstallMcpArgs) -> Result<String> {
# - Windows (MSIX): %LOCALAPPDATA%\\Packages\\Claude_<id>\\LocalCache\\Roaming\\Claude\\claude_desktop_config.json\n\
# --apply detects the installed form; if multiple MSIX packages\n\
# are present, select the active one with --config-file.\n\
- # - Linux: Claude Desktop is not officially distributed for Linux;\n\
- # use Claude Code or another HTTP client instead.\n\
+ # - Linux (beta, Debian/Ubuntu): $XDG_CONFIG_HOME/Claude/claude_desktop_config.json\n\
+ # (default ~/.config/Claude/claude_desktop_config.json)\n\
#\n\
# Claude Desktop's JSON config does not support HTTP MCP servers\n\
# directly. We bridge through the community `mcp-remote` stdio shim\n\
@@ -2389,6 +2397,18 @@ mod tests {
}
}
+ #[test]
+ fn claude_desktop_config_sits_under_the_linux_config_dir() {
+ let config = Path::new("/home/me/.config");
+ assert_eq!(
+ claude_desktop_config_path_linux(config),
+ Path::new("/home/me/.config/Claude/claude_desktop_config.json")
+ );
+ let rendered = render_claude_desktop(&args_for(McpClient::ClaudeDesktop)).unwrap();
+ assert!(rendered.contains("$XDG_CONFIG_HOME/Claude/claude_desktop_config.json"));
+ assert!(!rendered.contains("not officially distributed"));
+ }
+
/// A relocated Windows profile (`run --env`, a hermetic backup test)
/// moves Claude Desktop's config with it; the Known Folder API alone
/// would keep pointing at the real profile.
diff --git a/docs/desktop/claude-desktop.md b/docs/desktop/claude-desktop.md
index 3bb7333f..e2c6cfca 100644
--- a/docs/desktop/claude-desktop.md
+++ b/docs/desktop/claude-desktop.md
@@ -39,10 +39,8 @@ Two distinct MCP surfaces:
already detects both)
- Linux: `~/.config/Claude/claude_desktop_config.json` (**verified
locally**; the file exists with a `preferences` object — the Linux beta
- reuses the same file). Note ai-memory's own `docs/mcp-install.md` still
- says "Linux: not officially distributed by Anthropic" — that is now
- outdated versus the official Linux beta and should be updated in a
- follow-up docs PR.
+ reuses the same file). `docs/mcp-install.md` documents it, and
+ `install-mcp --client claude-desktop` writes it on Linux.
- Source: <https://modelcontextprotocol.io/quickstart/user> (mac/win
paths), local file inspection, ai-memory `docs/mcp-install.md`.
- Local MCP logs: `~/Library/Logs/Claude/mcp*.log` (mac),
diff --git a/docs/mcp-install.md b/docs/mcp-install.md
index e95f3013..46f06fd9 100644
--- a/docs/mcp-install.md
+++ b/docs/mcp-install.md
@@ -512,9 +512,8 @@ are captured by the [Claude Code](#claude-code) hooks.
it stops and asks for an explicit `--config-file` instead of guessing.
- Linux: `~/.config/Claude/claude_desktop_config.json`. Anthropic ships
Claude Desktop for Linux as a beta for Debian-based distributions
- (Ubuntu 22.04+, Debian 12+). `install-mcp` does not detect this path on
- Linux yet, so pass it explicitly:
- `ai-memory install-mcp --client claude-desktop --apply --config-file ~/.config/Claude/claude_desktop_config.json`.
+ (Ubuntu 22.04+, Debian 12+). `install-mcp --client claude-desktop` writes
+ it there (`$XDG_CONFIG_HOME/Claude/` when that is set).
**Important:** Claude Desktop's JSON config supports stdio MCP
servers only. To talk to ai-memory's HTTP endpoint, bridge through
diff --git a/docs/support-matrix.md b/docs/support-matrix.md
index 780fc811..515354c5 100644
--- a/docs/support-matrix.md
+++ b/docs/support-matrix.md
@@ -24,7 +24,7 @@
| Crush | Managed-only | `ai-memory run crush` resumes its project-local session database and supplies portable context through a temporary supported global-context file; no lifecycle-hook installer is provided. |
| Managed workstreams | Opt-in | `ai-memory run` provides transparent cross-harness continuity for Claude Code, Codex, OpenCode, OpenCode 2 beta, Pi, Crush, Kimi Code, Command Code, both incompatible Kiro CLI engines, OMP, Grok Build CLI, and Antigravity CLI. Direct launches remain unchanged. See [`docs/managed-workstreams.md`](managed-workstreams.md). |
| `--yolo` safety + ai-jail | Linux/macOS; Windows partial | `ai-memory run --yolo` warns before it disarms an agent's permission prompts and, on Linux/macOS, offers to re-exec the session inside [ai-jail](https://github.com/akitaonrails/ai-jail) when it is usable — installed and with its sandbox backend present (`bwrap` / `sandbox-exec`); otherwise it asks nothing and proceeds (`--network`, forwarding only already-set credential/config env vars). Accepting the offer shows a checklist of ai-jail toggles pre-marked with smart defaults (credentials present on the host, SSH for an SSH `origin`, worktree metadata in a linked worktree; Docker socket, GPU, display, Pictures, Tailscale unchecked). `--jail` re-runs inside ai-jail without asking (also without `--yolo` and non-interactively; it errors when ai-jail is not usable), `--jail=github,aws,no-mise` is exact (every unnamed checklist row is forced off with `--no-X`; `all`/`none` too; the checklist likewise passes unchecked rows as `--no-X`, while bare `--jail` leaves unmarked rows to your ai-jail config), and `--no-jail` skips the offer. Only toggles the installed ai-jail supports are offered; the credential mounts (`github`, `aws`, `kube`, `gcloud`, `docker-config`) need ai-jail 2.5.0. A project `.ai-jail` in the launch directory replaces the checklist and the bare-`--jail` defaults (ai-jail loads it as-is; `--jail=…` still overrides), and every re-exec passes `--no-save-config` so ai-jail never writes the run's flags into it. Both prompts are skipped on a non-interactive stdin/stderr and when already detected inside ai-jail. Windows gets the warning but never the ai-jail offer (ai-jail is Linux/macOS-only). Opt-in `--true-yolo` implies `--yolo` and, for Claude only, additionally forces `bypassPermissions` over any settings `defaultMode` (interchangeable with `--yolo` for other harnesses); `claude_true_yolo` applies the same Claude extra to `--yolo` launches. Claude's own explicit `ask` rules and command-safety checks still prompt in every mode. See [`docs/design-yolo-safety-ai-jail.md`](design-yolo-safety-ai-jail.md). |
-| Claude Desktop (Chat) | MCP-only | Uses `mcp-remote`; the ordinary Chat surface does not run lifecycle hooks. macOS, Windows, and Linux (Anthropic's Debian/Ubuntu beta; pass `--config-file ~/.config/Claude/claude_desktop_config.json` there). Cowork capture is not claimed; see the explicit boundary in [`mcp-install.md`](mcp-install.md#claude-desktop). |
+| Claude Desktop (Chat) | MCP-only | Uses `mcp-remote`; the ordinary Chat surface does not run lifecycle hooks. macOS, Windows, and Linux (Anthropic's Debian/Ubuntu beta, `~/.config/Claude/claude_desktop_config.json`). Cowork capture is not claimed; see the explicit boundary in [`mcp-install.md`](mcp-install.md#claude-desktop). |
| Claude Desktop (Code tab) | Supported | Local Code-tab sessions run Claude Code with the user's `~/.claude/settings.json`, so the Claude Code hooks capture them as `claude-code`; a session without a project folder lands in its own scratch-directory project. |
| OpenClaw | Supported | MCP config + native plugin lifecycle hooks; generated plugin enforces capture exclusions. |
| Antigravity CLI | Supported | MCP config (`serverUrl`) + lifecycle hooks (`agy` alias). Only `PreInvocation` with `invocationNum = 0` maps to SessionStart; later model calls cannot consume a next-session handoff. No automatic true session-end hook, so run `ai-memory finalize-session --agent antigravity-cli` after the final turn when you need a summary, handoff, and opt-in SessionEnd consolidation; an interactive session launched with `ai-memory run antigravity` is finalized automatically when it exits if the run can tie the session to itself (see [`docs/managed-workstreams.md`](managed-workstreams.md)). `ai-memory run antigravity` (aliases `antigravity-cli`, `agy`) adds managed workstream resume via `--conversation`; its conversation store is not decoded, so the ledger takes user prompts from `agy`'s `history.jsonl` (only this conversation's lines typed in this checkout) and assistant and tool steps from hook capture. Tool outputs (`run_command`, `view_file`, `list_dir`, etc.) are resolved directly from `.system_generated/steps/<stepIdx>/output.txt` during `post-tool-use` while mutation tools preserve code from arguments (#966). |