Skip to content

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

Rust

feat(mcp): add ZCode as an install-mcp client (#511) (#529)

Bruno Costa022e9d869072
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09f75866..ebdbd5d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
duplicate rows, and clamp `limit` to 1..=200 (default 50). The `detail`
column is returned for schema fidelity; the only writer still stores the
literal `{}`. (#531)
+- `install-mcp --client zcode` registers ai-memory as an MCP server in the
+ ZCode CLI (z.ai). The user-scope config lives at `~/.zcode/cli/config.json`
+ with servers under the nested `mcp.servers` map, and the generated entry is
+ a native streamable-HTTP registration — `type: "http"`, `url`, and an
+ `Authorization` bearer header when a token is configured. ZCode's entry
+ schema is strict (unknown keys make it drop the server silently), so the
+ entry carries exactly those keys and nothing else. `--apply` merges in place
+ preserving sibling servers and is idempotent; uninstall sweeps the same
+ file. MCP-only for now — lifecycle hooks are tracked separately in #512.
+ (#511)
### Fixed
- Stopped a session summary spending its characters on tool family labels. The
diff --git a/README.md b/README.md
index d0a4d17a..9b71446d 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@
| Grok Build CLI | Supported | MCP config (`install-mcp --client grok` → `$GROK_HOME/config.toml`, default `~/.grok/config.toml`) + lifecycle hooks (`install-hooks --agent grok` → `$GROK_HOME/hooks/ai-memory.json`, default `~/.grok/hooks/ai-memory.json`, Grok-specific hook bundle). Capture works; no hook handoff injection — Grok ignores `SessionStart` stdout, so recover handoffs via MCP `memory_handoff_accept`. `ai-memory run grok` adds managed workstream resume with the context packet delivered natively through `--rules`. Skills root: `.grok/skills` / `$GROK_HOME/skills` (default `~/.grok/skills`). |
| Swival CLI | MCP-only | `install-mcp --client swival --apply` merges a native HTTP entry into the project-root `.swival/mcp.json`, preserving sibling servers. Lifecycle and managed-workstream support are not claimed because Swival's callback contract does not expose a stable session identifier. |
| Zero | Supported | `install-mcp --client zero` (native HTTP + bearer in `~/.config/zero/config.json`) + lifecycle hooks via `install-hooks --agent zero --apply` (exec-form native commands in `~/.config/zero/hooks.json`, JSON payload on stdin, no shell). Capture works incl. specialist (subagent) events; no handoff injection — Zero discards `sessionStart` stdout, so recover handoffs via MCP `memory_handoff_accept`. |
+| ZCode | MCP-only | `install-mcp --client zcode --apply` merges a native HTTP entry (strict schema: `type`/`url`/`headers` only) into the `mcp.servers` map of `~/.zcode/cli/config.json`, preserving sibling servers. Lifecycle hooks are not yet available — see #512. |
| Kimi Code | Supported | MCP config (`url` entry in `~/.kimi-code/mcp.json`) + lifecycle hooks (`[[hooks]]` in `~/.kimi-code/config.toml`, 10 events including subagent start/stop and `PostToolUseFailure` for tool-failure capture); both paths honor `$KIMI_CODE_HOME`. Handoffs inject via `UserPromptSubmit` stdout (Kimi Code discards `SessionStart` hook stdout); `ai-memory run kimi` adds managed workstream resume. |
| Kiro CLI | Supported | MCP config uses `install-mcp --client kiro-cli` (alias `kiro`) and Kiro's Bedrock-compatible schema flavor. `install-hooks --agent kiro-cli` merges v2 hooks into existing agent configs; the explicit `--agent kiro-cli-v3` target writes the incompatible standalone v3 registration. Both preserve unrelated entries, honor `$KIRO_HOME`, enforce capture exclusions, and inject pending handoffs at session start. Kiro has no true SessionEnd hook; use `ai-memory finalize-session --agent kiro-cli`, with `--session-id <uuid>` for concurrent sessions. `ai-memory run kiro` manages v2; add `--v3`, `--mode`, or `--agent-engine v3` for version-safe v3 resume. |
| Pool | Hooks-only | Poolside Agent CLI (`pool`). Lifecycle-hook capture via `install-hooks --agent pool` (alias `poolside`): Pool reads project-scoped hooks from the repo-root `.poolside/settings.yaml`, so ai-memory stages the scripts and prints a ready-to-paste `hooks:` snippet rather than writing project-local files; native commands enforce capture exclusions. Five Claude-shaped events (`SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`) and no true session-end — `Stop` is a turn boundary, so run `ai-memory finalize-session --agent pool` after the final turn. `SessionStart` stdout injection is not demonstrated, so capture works but handoff injection does not — recover handoffs via MCP `memory_handoff_accept`. No first-party `install-mcp` client and no managed workstream (`ai-memory run pool`) are claimed: Pool's native session-store contract is not demonstrated (see [`docs/managed-harness-contributions.md`](docs/managed-harness-contributions.md)). Verified against Poolside CLI v1.0.16. |
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index ab2dee6f..2a77f5d3 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -1258,6 +1258,11 @@ pub enum McpClient {
/// Zero coding agent (Gitlawb/zero) — `~/.config/zero/config.json`,
/// `mcp.servers` map with native HTTP transport + bearer headers.
Zero,
+ /// ZCode (z.ai) — `~/.zcode/cli/config.json`, nested `mcp.servers`
+ /// map with `type: "http"` + `url` + optional `headers`. ZCode's
+ /// entry schema is strict: unknown keys make it drop the server
+ /// silently, so the generated entry carries nothing else.
+ Zcode,
/// Devin CLI — `~/.devin/config.json`.
Devin,
/// xAI Grok Build CLI — `~/.grok/config.toml` under
@@ -2520,6 +2525,23 @@ mod tests {
assert_eq!(args.client, McpClient::Swival);
}
+ #[test]
+ fn zcode_mcp_client_parses() {
+ let cli = Cli::try_parse_from([
+ "ai-memory",
+ "install-mcp",
+ "--client",
+ "zcode",
+ "--server-url",
+ "http://memory.example:49374",
+ ])
+ .unwrap_or_else(|error| panic!("failed to parse MCP client zcode: {error}"));
+ let Command::InstallMcp(args) = cli.command else {
+ panic!("expected install-mcp for zcode");
+ };
+ assert_eq!(args.client, McpClient::Zcode);
+ }
+
#[test]
fn install_hooks_project_strategy_repo_root_parses() {
let cli = Cli::try_parse_from([
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rs
index 8fdc54b9..fbcdab96 100644
--- a/crates/ai-memory-cli/src/commands/install_hooks.rs
+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs
@@ -972,6 +972,11 @@ fn infer_installed_mcp_config(agent: AgentChoice) -> Result<Option<InferredMcpCo
&["mcp", "servers", "ai-memory"],
"url",
)),
+ McpClient::Zcode => Ok(infer_json_mcp_config(
+ &content,
+ &["mcp", "servers", "ai-memory"],
+ "url",
+ )),
McpClient::Pi => Ok(None),
McpClient::AntigravityCli => Ok(infer_json_mcp_config(
&content,
diff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rs
index c8df7ccd..565a7629 100644
--- a/crates/ai-memory-cli/src/commands/install_mcp.rs
+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs
@@ -73,6 +73,7 @@ pub fn run(config: &Config, args: InstallMcpArgs) -> Result<()> {
McpClient::Omp => render_omp(&args)?,
McpClient::AntigravityCli => render_antigravity_cli(&args)?,
McpClient::Zero => render_zero(&args)?,
+ McpClient::Zcode => render_zcode(&args)?,
McpClient::Devin => render_devin(&args)?,
McpClient::KimiCode => render_kimi_code(&args)?,
McpClient::KiroCli => render_kiro_cli(&args)?,
@@ -204,6 +205,10 @@ pub(crate) fn mcp_config_path(client: crate::cli::McpClient) -> Result<PathBuf>
// to ~/.config; we target the default and --config-file covers
// non-default XDG setups (same policy as OpenCode above).
McpClient::Zero => home()?.join(".config").join("zero").join("config.json"),
+ // ZCode keeps its user-scope config at ~/.zcode/cli/config.json
+ // (workspace scopes like .zcode/config.json exist, but user scope
+ // is the install default for every other client too).
+ McpClient::Zcode => home()?.join(".zcode").join("cli").join("config.json"),
McpClient::Devin => home()?.join(".devin").join("config.json"),
// Kimi Code keeps its data dir at $KIMI_CODE_HOME when set,
// falling back to ~/.kimi-code; MCP servers live in mcp.json at
@@ -490,8 +495,10 @@ fn json_mcp_location(client: McpClient) -> Option<JsonMcpLocation> {
| McpClient::Swival => Some(JsonMcpLocation::RootMcpServers),
McpClient::OpenCode => Some(JsonMcpLocation::RootMcp),
// Zero's config.json nests servers under `mcp.servers`, the same
- // shape OpenClaw uses.
- McpClient::Openclaw | McpClient::Zero => Some(JsonMcpLocation::NestedMcpServers),
+ // shape OpenClaw uses. ZCode nests its servers the same way.
+ McpClient::Openclaw | McpClient::Zero | McpClient::Zcode => {
+ Some(JsonMcpLocation::NestedMcpServers)
+ }
McpClient::VsCodeCopilot => Some(JsonMcpLocation::RootServers),
McpClient::Zed => Some(JsonMcpLocation::RootContextServers),
McpClient::Codex | McpClient::Grok | McpClient::Pi => None,
@@ -504,6 +511,7 @@ fn build_json_mcp_entry(args: &InstallMcpArgs) -> Result<serde_json::Value> {
McpClient::OpenCode => build_mcp_entry_opencode(args),
McpClient::Openclaw => build_mcp_entry_openclaw(args),
McpClient::Zero => build_mcp_entry_zero(args),
+ McpClient::Zcode => build_mcp_entry_zcode(args),
McpClient::Codex | McpClient::Grok => {
bail!("internal: Codex/Grok MCP config is TOML, not JSON")
}
@@ -780,6 +788,23 @@ fn build_mcp_entry_zero(args: &InstallMcpArgs) -> Result<serde_json::Value> {
Ok(serde_json::Value::Object(entry))
}
+/// ZCode MCP entry: `type: "http"` + `url` + optional `headers` under
+/// `~/.zcode/cli/config.json`'s `mcp.servers` map. ZCode's entry schema
+/// is strict — an entry carrying any key outside `type`/`url`/`headers`/
+/// `enabled`/`timeoutMs` is dropped silently — so this deliberately
+/// emits nothing else (issue #511).
+fn build_mcp_entry_zcode(args: &InstallMcpArgs) -> Result<serde_json::Value> {
+ let bearer = bearer_header_value(args.auth_token.as_deref());
+ let server_url = args.server_url.as_deref().unwrap_or(DEFAULT_MCP_URL);
+ let mut entry = serde_json::Map::new();
+ entry.insert("type".into(), json!("http"));
+ entry.insert("url".into(), json!(server_url));
+ if let Some(b) = bearer {
+ entry.insert("headers".into(), json!({"Authorization": b}));
+ }
+ Ok(serde_json::Value::Object(entry))
+}
+
/// Insert / replace `[mcp_servers.<name>]` in a Codex `config.toml`.
///
/// Codex parses both forms (block-style `[mcp_servers.foo]` and the
@@ -1097,6 +1122,20 @@ fn render_zero(args: &InstallMcpArgs) -> Result<String> {
))
}
+fn render_zcode(args: &InstallMcpArgs) -> Result<String> {
+ Ok(format!(
+ "# ZCode (z.ai) — merge into ~/.zcode/cli/config.json\n\
+ # (or re-run this command with --apply), then restart ZCode.\n\
+ #\n\
+ # The entry schema is strict: keys outside type/url/headers/\n\
+ # enabled/timeoutMs make ZCode drop the server silently.\n\
+ # ai-memory's default stateless /mcp endpoint needs no flavor\n\
+ # marker; auth goes in the headers map.\n\
+ {snippet}\n",
+ snippet = render_json_mcp_fragment(args)?,
+ ))
+}
+
fn render_pi(args: &InstallMcpArgs) -> Result<String> {
Ok(pi_mcp_render_guidance(args))
}
@@ -1650,6 +1689,7 @@ mod tests {
McpClient::Omp => render_omp(&args).unwrap(),
McpClient::AntigravityCli => render_antigravity_cli(&args).unwrap(),
McpClient::Zero => render_zero(&args).unwrap(),
+ McpClient::Zcode => render_zcode(&args).unwrap(),
McpClient::Devin => render_devin(&args).unwrap(),
McpClient::KimiCode => render_kimi_code(&args).unwrap(),
McpClient::KiroCli => render_kiro_cli(&args).unwrap(),
@@ -1676,6 +1716,7 @@ mod tests {
McpClient::Omp,
McpClient::AntigravityCli,
McpClient::Zero,
+ McpClient::Zcode,
McpClient::Devin,
McpClient::KimiCode,
McpClient::KiroCli,
@@ -1716,6 +1757,7 @@ mod tests {
McpClient::Omp,
McpClient::AntigravityCli,
McpClient::Zero,
+ McpClient::Zcode,
McpClient::Devin,
McpClient::KimiCode,
McpClient::KiroCli,
@@ -1749,6 +1791,7 @@ mod tests {
McpClient::Omp => render_omp(&args).unwrap(),
McpClient::AntigravityCli => render_antigravity_cli(&args).unwrap(),
McpClient::Zero => render_zero(&args).unwrap(),
+ McpClient::Zcode => render_zcode(&args).unwrap(),
McpClient::Devin => render_devin(&args).unwrap(),
McpClient::KimiCode => render_kimi_code(&args).unwrap(),
McpClient::KiroCli => render_kiro_cli(&args).unwrap(),
@@ -1980,6 +2023,92 @@ mod tests {
);
}
+ /// Pin ZCode's user-scope config destination: ~/.zcode/cli/config.json.
+ /// Workspace scopes (.zcode/config.json, zcode.json, .agents/mcp.json)
+ /// exist, but user scope is the install default every other client
+ /// uses too (#511).
+ #[test]
+ fn zcode_mcp_config_path_pins_user_scope_location() {
+ assert_eq!(
+ mcp_config_path(McpClient::Zcode).unwrap(),
+ home_dir()
+ .unwrap()
+ .join(".zcode")
+ .join("cli")
+ .join("config.json")
+ );
+ }
+
+ /// ZCode's entry schema is strict — any key outside
+ /// type/url/headers/enabled/timeoutMs makes it drop the server
+ /// silently — so the fragment must carry exactly the documented
+ /// keys, nested under `mcp.servers` (#511).
+ #[test]
+ fn zcode_renderer_nests_strict_http_entry_under_mcp_servers() {
+ let fragment = render_json_mcp_fragment(&args_with_token(McpClient::Zcode)).unwrap();
+ let value: serde_json::Value = serde_json::from_str(&fragment).unwrap();
+
+ assert_eq!(
+ value,
+ json!({
+ "mcp": {
+ "servers": {
+ "ai-memory": {
+ "type": "http",
+ "url": "http://127.0.0.1:49374/mcp",
+ "headers": {
+ "Authorization": "Bearer test-token-deadbeef"
+ }
+ }
+ }
+ }
+ })
+ );
+ let rendered = render_zcode(&args_for(McpClient::Zcode)).unwrap();
+ assert!(rendered.contains("~/.zcode/cli/config.json"));
+ assert!(rendered.contains("strict"));
+ }
+
+ /// `--apply` merges under `mcp.servers` keeping the rest of the
+ /// config and sibling servers intact, and re-runs are a no-op.
+ #[test]
+ fn zcode_apply_preserves_siblings_and_is_idempotent() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let config_path = tmp.path().join("config.json");
+ fs::write(
+ &config_path,
+ r#"{
+ "theme": "dark",
+ "mcp": {
+ "servers": {
+ "other": {"type": "http", "url": "https://other.example/mcp"}
+ }
+ }
+}"#,
+ )
+ .unwrap();
+ let mut args = args_with_token(McpClient::Zcode);
+ args.config_file = Some(config_path.clone());
+
+ apply_to_config_file(&args).unwrap();
+ let first = fs::read_to_string(&config_path).unwrap();
+ apply_to_config_file(&args).unwrap();
+ let second = fs::read_to_string(&config_path).unwrap();
+
+ assert_eq!(first, second);
+ let value: serde_json::Value = serde_json::from_str(&second).unwrap();
+ assert_eq!(value["theme"], "dark");
+ assert_eq!(
+ value["mcp"]["servers"]["other"]["url"], "https://other.example/mcp",
+ "install must preserve sibling servers"
+ );
+ assert_eq!(value["mcp"]["servers"]["ai-memory"]["type"], "http");
+ assert_eq!(
+ value["mcp"]["servers"]["ai-memory"]["headers"]["Authorization"],
+ "Bearer test-token-deadbeef"
+ );
+ }
+
/// Pin the append rules: `?` on a bare endpoint, `&` with an existing
/// query, never duplicate an existing marker.
#[test]
diff --git a/crates/ai-memory-cli/src/commands/uninstall.rs b/crates/ai-memory-cli/src/commands/uninstall.rs
index 6a62b90a..ed81382e 100644
--- a/crates/ai-memory-cli/src/commands/uninstall.rs
+++ b/crates/ai-memory-cli/src/commands/uninstall.rs
@@ -344,6 +344,7 @@ fn build_plan(args: &UninstallArgs) -> anyhow::Result<Vec<PlannedChange>> {
Omp,
AntigravityCli,
Zero,
+ Zcode,
VsCodeCopilot,
Zed,
Devin,
@@ -1095,7 +1096,7 @@ fn mcp_servers_path(client: McpClient) -> Option<&'static [&'static str]> {
| McpClient::Swival
| McpClient::Devin => Some(&["mcpServers"]),
McpClient::OpenCode => Some(&["mcp"]),
- McpClient::Openclaw | McpClient::Zero => Some(&["mcp", "servers"]),
+ McpClient::Openclaw | McpClient::Zero | McpClient::Zcode => Some(&["mcp", "servers"]),
McpClient::VsCodeCopilot => Some(&["servers"]),
McpClient::Zed => Some(&["context_servers"]),
McpClient::Codex | McpClient::Grok | McpClient::Pi => None,
diff --git a/crates/ai-memory-cli/tests/removal.rs b/crates/ai-memory-cli/tests/removal.rs
index 12f60278..3c8c20e8 100644
--- a/crates/ai-memory-cli/tests/removal.rs
+++ b/crates/ai-memory-cli/tests/removal.rs
@@ -511,6 +511,51 @@ fn uninstall_mcp_custom_url_removes_antigravity_only_by_endpoint() {
assert!(after["mcpServers"].get("other").is_some());
}
+#[test]
+fn zcode_mcp_install_and_uninstall_round_trip_preserves_siblings() {
+ let _guard = cli_test_lock();
+ let home = tempfile::tempdir().unwrap();
+ let mcp = home.path().join(".zcode/cli/config.json");
+ write_file(
+ &mcp,
+ r#"{"mcp":{"servers":{"other":{"type":"http","url":"https://other.example/mcp"}}}}"#,
+ );
+
+ let install = command_with_home(home.path())
+ .args(["install-mcp", "--client", "zcode", "--apply"])
+ .output()
+ .unwrap();
+ assert!(
+ install.status.success(),
+ "install failed: {}",
+ String::from_utf8_lossy(&install.stderr)
+ );
+ let installed: serde_json::Value =
+ serde_json::from_str(&std::fs::read_to_string(&mcp).unwrap()).unwrap();
+ assert_eq!(installed["mcp"]["servers"]["ai-memory"]["type"], "http");
+ assert_eq!(
+ installed["mcp"]["servers"]["other"]["url"], "https://other.example/mcp",
+ "install must preserve sibling servers"
+ );
+
+ let uninstall = command_with_home(home.path())
+ .args(["uninstall", "--apply", "--only", "mcp", "--yes"])
+ .output()
+ .unwrap();
+ assert!(
+ uninstall.status.success(),
+ "uninstall failed: {}",
+ String::from_utf8_lossy(&uninstall.stderr)
+ );
+ let removed: serde_json::Value =
+ serde_json::from_str(&std::fs::read_to_string(&mcp).unwrap()).unwrap();
+ assert!(removed["mcp"]["servers"].get("ai-memory").is_none());
+ assert_eq!(
+ removed["mcp"]["servers"]["other"]["url"], "https://other.example/mcp",
+ "uninstall must preserve sibling servers"
+ );
+}
+
#[test]
fn swival_mcp_install_and_uninstall_round_trip_from_nested_directory() {
let _guard = cli_test_lock();
diff --git a/docs/install.md b/docs/install.md
index 30ec8525..db2b7930 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -9,7 +9,7 @@ path (docker + Claude Code). This page covers everything else:
- [Arch Linux native packages (AUR)](#arch-linux-native-packages-aur)
(systemd system service or user service)
- [Configuring other agent CLIs](#configuring-other-agent-clis)
- (Codex, Command Code, Devin CLI, OpenCode, OMP, Pi, Cursor, Claude Desktop, Gemini CLI, Antigravity CLI, Grok Build CLI, Zero, Kimi Code, Kiro CLI, Pool, OpenClaw, VS Code Copilot, Zed)
+ (Codex, Command Code, Devin CLI, OpenCode, OMP, Pi, Cursor, Claude Desktop, Gemini CLI, Antigravity CLI, Grok Build CLI, Zero, ZCode, Kimi Code, Kiro CLI, Pool, OpenClaw, VS Code Copilot, Zed)
- [Installing hooks without docker](#installing-hooks-without-docker)
(curl-based installer)
- [Running ai-memory without docker](#running-ai-memory-without-docker)
@@ -1240,6 +1240,10 @@ docker run --rm akitaonrails/ai-memory:latest \
docker run --rm akitaonrails/ai-memory:latest \
install-mcp --client zed --auth-token "$TOKEN" \
--server-url "http://homelab:49374/mcp"
+
+docker run --rm akitaonrails/ai-memory:latest \
+ install-mcp --client zcode --auth-token "$TOKEN" \
+ --server-url "http://homelab:49374/mcp"
```
Cursor, Gemini CLI, Antigravity CLI, Grok Build CLI, Kiro CLI, Command Code, and OpenClaw support both
@@ -1248,7 +1252,8 @@ Cursor, Gemini CLI, Antigravity CLI, Grok Build CLI, Kiro CLI, Command Code, and
`$GROK_HOME/hooks` (default `~/.grok/hooks`). `install-hooks --agent grok`
captures lifecycle events.
Grok ignores `SessionStart` stdout, so handoffs must be accepted through MCP with
-`memory_handoff_accept` when resuming. Claude Desktop, VS Code Copilot, and Zed
+`memory_handoff_accept` when resuming. Claude Desktop, VS Code Copilot, Zed,
+and ZCode
are MCP-only here, so you'll need to nudge the model to call
`memory_query` / `memory_handoff_accept` itself.
For clients with `install-hooks` support, the capture path handles
diff --git a/docs/mcp-install.md b/docs/mcp-install.md
index dcea7f6f..533ebac0 100644
--- a/docs/mcp-install.md
+++ b/docs/mcp-install.md
@@ -120,7 +120,7 @@ metadata.
> **One-shot tip:** every snippet below is also reachable from the
> CLI:
> ```bash
-> ai-memory install-mcp --client gemini-cli # or cursor / claude-desktop / openclaw / omp / pi / antigravity-cli / grok / kimi-code / kiro-cli / command-code / swival / devin / zero / vscode-copilot / zed
+> ai-memory install-mcp --client gemini-cli # or cursor / claude-desktop / openclaw / omp / pi / antigravity-cli / grok / kimi-code / kiro-cli / command-code / swival / devin / zero / zcode / vscode-copilot / zed
> ```
---
@@ -602,6 +602,45 @@ capture and session-end handoff *creation* work, but handoff *injection*
does not — ask Zero to call `memory_handoff_accept` at the start of a
resumed session.
+## ZCode (z.ai)
+
+**Status:** MCP supported. Lifecycle hooks are not installed by this command;
+they are tracked in issue #512, so until then capture is not active and
+ai-memory only sees the sessions where an agent calls its MCP tools.
+
+**Config file:** ZCode keeps its user-scope config at
+`~/.zcode/cli/config.json`, with servers under the nested `mcp.servers` map
+(the same shape Zero and OpenClaw use). Workspace scopes
+(`.zcode/config.json`, `zcode.json`, `.agents/mcp.json`) also exist; pass
+`--config-file` to target one of them explicitly.
+
+```bash
+ai-memory install-mcp --client zcode --apply \
+ --server-url "http://homelab:49374/mcp" --auth-token "$TOKEN"
+```
+
+which merges:
+
+```json
+{
+ "mcp": {
+ "servers": {
+ "ai-memory": {
+ "type": "http",
+ "url": "http://homelab:49374/mcp",
+ "headers": { "Authorization": "Bearer <token>" }
+ }
+ }
+ }
+}
+```
+
+The entry schema is strict: an entry carrying any key outside
+`type`/`url`/`headers`/`enabled`/`timeoutMs` is dropped silently, so the
+generated registration carries exactly those keys. The default stateless
+`/mcp` endpoint needs no flavor marker; auth goes in the `headers` map.
+Servers from every scope auto-connect at session start.
+
## Swival CLI
**Status:** MCP supported. Lifecycle hooks and managed workstreams are not