Skip to content

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

Rust

feat(install-mcp): add Prime Agent as an MCP-only client (#1163)

AkitaOnRails2faddbcdd4c3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a242d98d..6828c67e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
+- `install-mcp --client prime-agent` registers ai-memory with Prime Agent
+ (PrimeIntellect-ai/prime-agent), merging an HTTP entry into the `mcpServers`
+ map of `$PRIME_AGENT_CODING_AGENT_DIR/settings.json` (default
+ `~/.prime/agent/settings.json`) and preserving other settings and servers.
+ With a token the entry names `"bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"`
+ and the token is not written; Prime Agent 0.10 counts a user HTTP server as
+ connected, and lists it to the model, only with that variable set (or an
+ OAuth grant), so export it where you launch `prime-agent`. Without a token
+ the server is still callable through `mcp.call_tool("ai-memory", ...)` but is
+ not listed. MCP-only: Prime Agent 0.10 has no lifecycle hooks. (#1163)
- `memory_write_page` accepts `expected_page_id` (write only if that is still
the page's latest version) or `create_only` (write only if the page does not
exist), and `memory_delete_page` accepts `expected_page_id`. A precondition
diff --git a/README.md b/README.md
index 903f642f..bce9e475 100644
--- a/README.md
+++ b/README.md
@@ -144,6 +144,7 @@ caveats is in [`docs/support-matrix.md`](docs/support-matrix.md).
| Zed | MCP-only |
| Muse Code | MCP-only |
| DeepSeek Harness (DSH) | MCP-only |
+| Prime Agent | MCP-only |
| Hermes Agent | Supported |
| GrizzyBot | Supported |
| LLM/auth providers | Supported |
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index a10b6d3d..032bb6be 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -2684,6 +2684,14 @@ pub enum McpClient {
/// claimed.
#[value(alias = "deepseek-harness", alias = "deepseek_harness")]
Dsh,
+ /// Prime Agent (PrimeIntellect-ai/prime-agent) - the `mcpServers` map of
+ /// `$PRIME_AGENT_CODING_AGENT_DIR/settings.json` (default
+ /// `~/.prime/agent/settings.json`) with `type: "http"` + `url`. A token is
+ /// referenced through `bearerTokenEnvVar: "AI_MEMORY_AUTH_TOKEN"`, never
+ /// written literally: that is the only non-OAuth credential Prime Agent
+ /// counts as connected and names to the model. MCP-only: Prime Agent 0.10
+ /// has no lifecycle hooks (its earlier TypeScript extensions were removed).
+ PrimeAgent,
}
/// Arguments for `commit`.
@@ -4460,6 +4468,16 @@ mod tests {
assert_eq!(args.client, McpClient::Swival);
}
+ #[test]
+ fn prime_agent_mcp_client_parses() {
+ let cli = Cli::try_parse_from(["ai-memory", "install-mcp", "--client", "prime-agent"])
+ .unwrap_or_else(|error| panic!("failed to parse MCP client prime-agent: {error}"));
+ let Command::InstallMcp(args) = cli.command else {
+ panic!("expected install-mcp for prime-agent");
+ };
+ assert_eq!(args.client, McpClient::PrimeAgent);
+ }
+
#[test]
fn zcode_mcp_client_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 ec4ea17f..ff1f0d00 100644
--- a/crates/ai-memory-cli/src/commands/install_hooks.rs
+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs
@@ -1530,6 +1530,14 @@ fn infer_installed_mcp_config(
&["mcp_servers", "ai-memory"],
"url",
)),
+ // MCP-only client: no AgentChoice counterpart routes here. Prime
+ // Agent 0.10 has no lifecycle hooks, and its entry names the token
+ // variable rather than carrying a bearer, so only the URL is there.
+ McpClient::PrimeAgent => Ok(infer_json_mcp_config(
+ &content,
+ &["mcpServers", "ai-memory"],
+ "url",
+ )),
}
}
diff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rs
index cd4f4585..bba96faf 100644
--- a/crates/ai-memory-cli/src/commands/install_mcp.rs
+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs
@@ -31,6 +31,10 @@ use crate::config::{Config, DEFAULT_MCP_URL};
const GEMINI_MCP_TIMEOUT_MS: u64 = 5000;
+/// The variable a Prime Agent entry names in `bearerTokenEnvVar`: the same one
+/// ai-memory's own hooks and CLI read the server token from.
+const PRIME_AGENT_TOKEN_ENV: &str = "AI_MEMORY_AUTH_TOKEN";
+
#[derive(Clone, Copy)]
enum JsonMcpLocation {
RootMcpServers,
@@ -136,6 +140,7 @@ pub(crate) fn run_with_opencode_dialect(
McpClient::Zed => render_zed(&args)?,
McpClient::Muse => render_muse(&args)?,
McpClient::Dsh => render_dsh(&args)?,
+ McpClient::PrimeAgent => render_prime_agent(&args)?,
};
println!("{snippet}");
Ok(())
@@ -176,6 +181,9 @@ fn validate_args(args: &InstallMcpArgs) -> Result<()> {
if matches!(args.client, McpClient::Dsh) {
validate_dsh_server_name(&args.name)?;
}
+ if matches!(args.client, McpClient::PrimeAgent) {
+ validate_prime_agent_server_name(&args.name)?;
+ }
Ok(())
}
@@ -194,6 +202,26 @@ fn validate_dsh_server_name(name: &str) -> Result<()> {
Ok(())
}
+/// Prime Agent resolves a user MCP server only when its name is 1-64
+/// characters of `[A-Za-z0-9_-]` starting with a letter or digit; any other
+/// name is never connected, so refuse it before writing the entry.
+fn validate_prime_agent_server_name(name: &str) -> Result<()> {
+ let valid = name.len() <= 64
+ && name
+ .bytes()
+ .next()
+ .is_some_and(|b| b.is_ascii_alphanumeric())
+ && name
+ .bytes()
+ .all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-');
+ if !valid {
+ bail!(
+ "Prime Agent MCP server names must be 1-64 characters of [A-Za-z0-9_-] starting with a letter or digit; got {name:?}"
+ );
+ }
+ Ok(())
+}
+
/// Kiro accepts HTTPS remote MCP endpoints and plain HTTP only on loopback.
/// Reject an unusable registration before `--apply` mutates user config.
fn validate_kiro_remote_url(server_url: &str) -> Result<()> {
@@ -230,7 +258,8 @@ pub(crate) fn mcp_config_path(client: crate::cli::McpClient) -> Result<PathBuf>
}
/// [`mcp_config_path`] with the relocation variables (`CLAUDE_CONFIG_DIR`,
-/// `CODEX_HOME`, `COPILOT_HOME`, `GROK_HOME`, `KIMI_CODE_HOME`, `KIRO_HOME`, and OMP's
+/// `CODEX_HOME`, `COPILOT_HOME`, `GROK_HOME`, `KIMI_CODE_HOME`, `KIRO_HOME`,
+/// `PRIME_AGENT_CODING_AGENT_DIR`, and OMP's
/// `OMP_PROFILE`, `PI_PROFILE`, `PI_CODING_AGENT_DIR` and `PI_CONFIG_DIR`) read
/// through `env`,
/// so `ai-memory run --env` can point auto-wire at the same config home
@@ -361,6 +390,13 @@ pub(crate) fn mcp_config_path_with(
// $XDG_CONFIG_HOME for its skill roots, so --config-file covers
// non-default XDG setups (same policy as Zero above).
McpClient::Muse => home()?.join(".config").join("muse").join("settings.json"),
+ // Prime Agent's agent dir is $PRIME_AGENT_CODING_AGENT_DIR when set,
+ // else ~/.prime/agent; user MCP servers live in its settings.json
+ // (a project's `.prime/agent/settings.json` overrides it: pass that
+ // path via --config-file).
+ McpClient::PrimeAgent => {
+ prime_agent_dir_in(env("PRIME_AGENT_CODING_AGENT_DIR"))?.join("settings.json")
+ }
})
}
@@ -548,6 +584,19 @@ pub(crate) fn copilot_home_in(env_override: Option<std::ffi::OsString>) -> Resul
.join(".copilot"))
}
+/// Prime Agent's agent directory: `$PRIME_AGENT_CODING_AGENT_DIR` when set and
+/// not blank, otherwise `~/.prime/agent`. The override is injected to keep
+/// path tests process-local.
+fn prime_agent_dir_in(env_override: Option<std::ffi::OsString>) -> Result<PathBuf> {
+ if let Some(dir) = crate::commands::path_util::agent_config_home(env_override) {
+ return Ok(dir);
+ }
+ Ok(home_dir()
+ .context("could not locate $HOME for Prime Agent configuration")?
+ .join(".prime")
+ .join("agent"))
+}
+
/// Resolve Grok Build CLI's user configuration root. Grok honours
/// `GROK_HOME`; otherwise it uses `~/.grok`.
pub(crate) fn grok_home() -> Result<PathBuf> {
@@ -648,6 +697,11 @@ fn apply_to_config_file(args: &InstallMcpArgs) -> Result<()> {
ApplyOutcome::NoOp => "already up to date",
}
);
+ if matches!(args.client, McpClient::PrimeAgent) && args.auth_token.is_some() {
+ println!(
+ " Prime Agent reads the token from ${PRIME_AGENT_TOKEN_ENV}; export it where you launch prime-agent."
+ );
+ }
Ok(())
}
@@ -702,7 +756,8 @@ fn json_mcp_location(client: McpClient) -> Option<JsonMcpLocation> {
| McpClient::KiroCli
| McpClient::CommandCode
| McpClient::CopilotCli
- | McpClient::Swival => Some(JsonMcpLocation::RootMcpServers),
+ | McpClient::Swival
+ | McpClient::PrimeAgent => Some(JsonMcpLocation::RootMcpServers),
McpClient::OpenCode => Some(JsonMcpLocation::RootMcp),
// V2 nests servers under `mcp.servers` — the same shape OpenClaw,
// Zero, and ZCode use.
@@ -1262,6 +1317,21 @@ fn build_mcp_entry(args: &InstallMcpArgs) -> Result<serde_json::Value> {
}
entry.insert("tools".into(), json!(["*"]));
}
+ McpClient::PrimeAgent => {
+ // Prime Agent 0.10 counts a user HTTP server as connected, and
+ // names it to the model, only with an OAuth grant or a
+ // `bearerTokenEnvVar` whose variable is set; a literal
+ // `headers.Authorization` still dispatches but stays unlisted.
+ // So the token is referenced by variable, which also keeps it
+ // out of settings.json. The camelCase key is the one Prime
+ // Agent's loader reads (its own `mcp add` writes snake_case,
+ // which is ignored).
+ entry.insert("type".into(), json!("http"));
+ entry.insert("url".into(), json!(server_url));
+ if args.auth_token.is_some() {
+ entry.insert("bearerTokenEnvVar".into(), json!(PRIME_AGENT_TOKEN_ENV));
+ }
+ }
_ => bail!("internal: build_mcp_entry called for unsupported client"),
}
Ok(serde_json::Value::Object(entry))
@@ -1730,6 +1800,39 @@ fn render_muse(args: &InstallMcpArgs) -> Result<String> {
))
}
+fn render_prime_agent(args: &InstallMcpArgs) -> Result<String> {
+ let auth = if args.auth_token.is_some() {
+ format!(
+ "# The token is not written: the entry names ${PRIME_AGENT_TOKEN_ENV}\n\
+ # (bearerTokenEnvVar), so export it where you launch prime-agent.\n\
+ # Without it the server is disconnected and calls fail.\n"
+ )
+ } else {
+ format!(
+ "# Without a token Prime Agent 0.10 lists the server as not connected\n\
+ # and leaves it out of the model's MCP prompt, though\n\
+ # mcp.call_tool(\"{name}\", ...) still reaches it. Run the server\n\
+ # with {PRIME_AGENT_TOKEN_ENV} and pass --auth-token to list it.\n",
+ name = args.name,
+ )
+ };
+ Ok(format!(
+ "# Prime Agent - merge into $PRIME_AGENT_CODING_AGENT_DIR/settings.json\n\
+ # (default ~/.prime/agent/settings.json), or re-run with --apply to\n\
+ # merge it in place preserving other settings. A project's\n\
+ # .prime/agent/settings.json also works: pass it via --config-file.\n\
+ #\n\
+ {auth}\
+ #\n\
+ # The model calls tools from its Python REPL:\n\
+ # await mcp.call_tool(\"{name}\", \"memory_query\", {{...}})\n\
+ # MCP-only: Prime Agent has no lifecycle hooks to capture sessions.\n\
+ {snippet}\n",
+ name = args.name,
+ snippet = render_json_mcp_fragment(args)?,
+ ))
+}
+
/// DeepSeek Harness (DSH) has no fixed JSON/TOML MCP config: the client is a
/// Cordis plugin entry inside a profile's cordis.patch.yml. Render the
/// patch-list fragment the operator merges by hand; --apply is refused.
@@ -2534,6 +2637,11 @@ mod tests {
(McpClient::KimiCode, "KIMI_CODE_HOME", "mcp.json"),
(McpClient::KiroCli, "KIRO_HOME", "settings/mcp.json"),
(McpClient::Omp, "PI_CODING_AGENT_DIR", "mcp.json"),
+ (
+ McpClient::PrimeAgent,
+ "PRIME_AGENT_CODING_AGENT_DIR",
+ "settings.json",
+ ),
] {
let env = |name: &str| (name == var).then(|| root.as_os_str().to_owned());
assert_eq!(
@@ -3028,6 +3136,7 @@ mod tests {
McpClient::Zed => render_zed(&args).unwrap(),
McpClient::Muse => render_muse(&args).unwrap(),
McpClient::Dsh => render_dsh(&args).unwrap(),
+ McpClient::PrimeAgent => render_prime_agent(&args).unwrap(),
}
}
@@ -3103,6 +3212,7 @@ mod tests {
McpClient::Zed,
McpClient::Muse,
McpClient::Dsh,
+ McpClient::PrimeAgent,
] {
let out = render_for_test(client);
assert!(
@@ -3141,6 +3251,7 @@ mod tests {
McpClient::Zed => render_zed(&args).unwrap(),
McpClient::Muse => render_muse(&args).unwrap(),
McpClient::Dsh => render_dsh(&args).unwrap(),
+ McpClient::PrimeAgent => render_prime_agent(&args).unwrap(),
}
}
@@ -3650,6 +3761,141 @@ mod tests {
assert_eq!(ours["tools"], json!(["*"]));
}
+ /// Prime Agent 0.10 lists a user HTTP server to the model only when its
+ /// `bearerTokenEnvVar` is set, so a token is referenced by variable and
+ /// never written into settings.json.
+ #[test]
+ fn prime_agent_entry_names_the_token_variable_never_the_token() {
+ let fragment = render_json_mcp_fragment(&args_with_token(McpClient::PrimeAgent)).unwrap();
+ let value: serde_json::Value = serde_json::from_str(&fragment).unwrap();
+ assert_eq!(
+ value,
+ json!({
+ "mcpServers": {
+ "ai-memory": {
+ "type": "http",
+ "url": "http://127.0.0.1:49374/mcp",
+ "bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"
+ }
+ }
+ })
+ );
+
+ let rendered = render_prime_agent(&args_with_token(McpClient::PrimeAgent)).unwrap();
+ assert!(!rendered.contains("test-token-deadbeef"), "{rendered}");
+ assert!(rendered.contains("export it where you launch prime-agent"));
+ assert!(rendered.contains("~/.prime/agent/settings.json"));
+ assert!(rendered.contains(r#"await mcp.call_tool("ai-memory", "memory_query""#));
+ }
+
+ #[test]
+ fn prime_agent_entry_without_a_token_is_bare_http_and_says_it_is_unlisted() {
+ let entry = build_json_mcp_entry(&args_for(McpClient::PrimeAgent)).unwrap();
+ assert_eq!(
+ entry,
+ json!({"type": "http", "url": "http://127.0.0.1:49374/mcp"})
+ );
+ let rendered = render_prime_agent(&args_for(McpClient::PrimeAgent)).unwrap();
+ assert!(rendered.contains("not connected"), "{rendered}");
+ assert!(
+ !rendered.contains("export it where you launch"),
+ "{rendered}"
+ );
+ }
+
+ /// Prime Agent fronts several model vendors, so it has no default schema
+ /// flavor, but an explicit `--flavor` reaches the URL it lists tools from.
+ #[test]
+ fn prime_agent_entry_carries_an_explicit_flavor_only() {
+ let mut args = args_for(McpClient::PrimeAgent);
+ assert_eq!(
+ build_json_mcp_entry(&args).unwrap()["url"],
+ "http://127.0.0.1:49374/mcp"
+ );
+ args.flavor = Some(SchemaFlavor::Gemini);
+ assert_eq!(
+ build_json_mcp_entry(&args).unwrap()["url"],
+ "http://127.0.0.1:49374/mcp?flavor=gemini"
+ );
+ }
+
+ #[test]
+ fn prime_agent_apply_preserves_settings_and_siblings_and_is_idempotent() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let config_path = tmp.path().join("settings.json");
+ fs::write(
+ &config_path,
+ r#"{"defaultModel":"glm","mcpServers":{"search":{"type":"http","url":"https://search.example/mcp","bearerTokenEnvVar":"SEARCH_TOKEN"}}}"#,
+ )
+ .unwrap();
+ let mut args = args_with_token(McpClient::PrimeAgent);
+ args.server_url = Some("https://memory.example/mcp".into());
+ 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);
+ assert!(!second.contains("test-token-deadbeef"), "{second}");
+ let value: serde_json::Value = serde_json::from_str(&second).unwrap();
+ assert_eq!(value["defaultModel"], "glm");
+ assert_eq!(
+ value["mcpServers"]["search"]["bearerTokenEnvVar"],
+ "SEARCH_TOKEN"
+ );
+ assert_eq!(
+ value["mcpServers"]["ai-memory"],
+ json!({
+ "type": "http",
+ "url": "https://memory.example/mcp",
+ "bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"
+ })
+ );
+ }
+
+ /// A name Prime Agent would never connect is refused before any write.
+ #[test]
+ fn prime_agent_rejects_server_names_it_cannot_resolve() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let config_path = tmp.path().join("settings.json");
+ for name in [
+ "",
+ "-memory",
+ "_memory",
+ "ai memory",
+ "ai.memory",
+ &"m".repeat(65),
+ ] {
+ let mut args = args_for(McpClient::PrimeAgent);
+ args.name = name.to_string();
+ args.config_file = Some(config_path.clone());
+ let error = apply_to_config_file(&args).unwrap_err();
+ assert!(
+ error.to_string().contains("Prime Agent MCP server names"),
+ "{name:?}: {error:#}"
+ );
+ assert!(!config_path.exists(), "{name:?} must not write the file");
+ }
+ for name in ["ai-memory", "memory_2", "M", &"m".repeat(64)] {
+ let mut args = args_for(McpClient::PrimeAgent);
+ args.name = name.to_string();
+ validate_args(&args).unwrap_or_else(|error| panic!("{name:?}: {error:#}"));
+ }
+ }
+
+ #[test]
+ fn prime_agent_dir_honours_env_override() {
+ assert_eq!(
+ prime_agent_dir_in(Some("/tmp/custom-prime-agent".into())).unwrap(),
+ PathBuf::from("/tmp/custom-prime-agent")
+ );
+ let default = home_dir().unwrap().join(".prime").join("agent");
+ assert_eq!(prime_agent_dir_in(Some("".into())).unwrap(), default);
+ assert_eq!(prime_agent_dir_in(None).unwrap(), default);
+ }
+
#[test]
fn kiro_apply_preserves_siblings_and_is_idempotent() {
let tmp = tempfile::TempDir::new().unwrap();
diff --git a/crates/ai-memory-cli/src/commands/uninstall.rs b/crates/ai-memory-cli/src/commands/uninstall.rs
index e7977e8b..767d837e 100644
--- a/crates/ai-memory-cli/src/commands/uninstall.rs
+++ b/crates/ai-memory-cli/src/commands/uninstall.rs
@@ -413,6 +413,7 @@ fn build_plan(args: &UninstallArgs, data_dir: &Path) -> anyhow::Result<Vec<Plann
CopilotCli,
Swival,
Muse,
+ PrimeAgent,
] {
let paths = if matches!(client, ClaudeCode) {
claude_config_paths(
@@ -1257,7 +1258,8 @@ fn mcp_servers_path(client: McpClient) -> Option<&'static [&'static str]> {
| McpClient::CommandCode
| McpClient::CopilotCli
| McpClient::Swival
- | McpClient::Devin => Some(&["mcpServers"]),
+ | McpClient::Devin
+ | McpClient::PrimeAgent => Some(&["mcpServers"]),
McpClient::OpenCode => Some(&["mcp"]),
McpClient::OpenCode2 => Some(&["mcp", "servers"]),
McpClient::Openclaw | McpClient::Zero | McpClient::Zcode => Some(&["mcp", "servers"]),
@@ -2248,6 +2250,26 @@ mod tests {
assert!(v["mcpServers"].get("github").is_some());
}
+ /// Prime Agent's settings.json carries every other Prime Agent setting
+ /// beside `mcpServers`; the strip removes only ai-memory's entry.
+ #[test]
+ fn strip_mcp_prime_agent_keeps_other_settings_and_servers() {
+ let content = r#"{"defaultModel":"glm","mcpServers":{"ai-memory":{"type":"http","url":"http://127.0.0.1:49374/mcp","bearerTokenEnvVar":"AI_MEMORY_AUTH_TOKEN"},"search":{"type":"http","url":"https://search.example/mcp"}}}"#;
+ let (out, removed) = strip_mcp_json(
+ content,
+ McpClient::PrimeAgent,
+ Some("ai-memory"),
+ "http://127.0.0.1:49374/mcp",
+ )
+ .unwrap();
+
+ assert_eq!(removed, vec!["ai-memory".to_string()]);
+ let v: serde_json::Value = serde_json::from_str(&out).unwrap();
+ assert!(v["mcpServers"].get("ai-memory").is_none());
+ assert!(v["mcpServers"].get("search").is_some());
+ assert_eq!(v["defaultModel"], "glm");
+ }
+
#[test]
fn strip_mcp_zed_context_servers_preserves_other_settings() {
let content = r#"{
diff --git a/docs/install.md b/docs/install.md
index 50ff173d..d97e6334 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -1714,6 +1714,10 @@ docker run --rm akitaonrails/ai-memory:latest \
docker run --rm akitaonrails/ai-memory:latest \
install-mcp --client dsh --auth-token "$TOKEN" \
--server-url "http://homelab:49374/mcp"
+
+docker run --rm akitaonrails/ai-memory:latest \
+ install-mcp --client prime-agent --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
@@ -1726,9 +1730,11 @@ so those hooks do not accept the handoff. The first `PostToolUse` prints
`hookSpecificOutput.additionalContext` (pending handoff, plus an opted-in
`[briefing]`). The model sees it after that tool result, not before the
first prompt. A session with no tool call leaves the handoff for
-`memory_handoff_accept`. Claude Desktop, VS Code Copilot, Zed, ZCode, and
-DeepSeek Harness (DSH) are MCP-only here, so you'll need to nudge the model
-to call `memory_query` / `memory_handoff_accept` itself.
+`memory_handoff_accept`. Claude Desktop, VS Code Copilot, Zed, ZCode,
+DeepSeek Harness (DSH), and Prime Agent are MCP-only here, so you'll need to
+nudge the model to call `memory_query` / `memory_handoff_accept` itself.
+Prime Agent's snippet names `$AI_MEMORY_AUTH_TOKEN` rather than embedding the
+token, so export that variable where you launch `prime-agent`.
For clients with `install-hooks` support, the capture path handles
handoff injection at session start or the client's closest equivalent, except
for Zero's no-stdout SessionStart behavior. Grok delivers on the first
diff --git a/docs/mcp-install.md b/docs/mcp-install.md
index f7bf8810..5cfca890 100644
--- a/docs/mcp-install.md
+++ b/docs/mcp-install.md
@@ -152,7 +152,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 / zcode / copilot-cli / vscode-copilot / zed / muse / dsh
+> 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 / copilot-cli / vscode-copilot / zed / muse / dsh / prime-agent
> ```
---
@@ -528,6 +528,76 @@ detached. Treat DSH as MCP-only here and recover handoffs explicitly with
---
+## Prime Agent
+
+**Status:** MCP supported. No lifecycle hooks or managed workstream claimed.
+
+[Prime Agent](https://github.com/PrimeIntellect-ai/prime-agent) reads user MCP
+servers from the `mcpServers` map of its agent dir's `settings.json`:
+`$PRIME_AGENT_CODING_AGENT_DIR/settings.json`, default
+`~/.prime/agent/settings.json`. A project's `.prime/agent/settings.json`
+overrides it; pass that path with `--config-file`.
+
+```json
+{
+ "mcpServers": {
+ "ai-memory": {
+ "type": "http",
+ "url": "http://127.0.0.1:49374/mcp",
+ "bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"
+ }
+ }
+}
+```
+
+```bash
+ai-memory install-mcp --client prime-agent --apply \
+ --server-url "http://homelab:49374/mcp" \
+ --auth-token "$TOKEN"
+export AI_MEMORY_AUTH_TOKEN="$TOKEN" # in the shell you launch prime-agent from
+```
+
+How Prime Agent 0.10 treats the entry shapes the generated one:
+
+- **The token is referenced, not written.** Prime Agent counts a user HTTP
+ server as connected, and names it in the model's prompt
+ (`Enabled generic MCP servers: ai-memory`), only when the variable in
+ `bearerTokenEnvVar` is set or an OAuth grant exists. A literal
+ `headers.Authorization` still reaches the server but leaves it unlisted, so
+ `install-mcp` writes `"bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"` and the
+ token stays out of `settings.json`. If the variable is unset, Prime Agent
+ shows the server as disconnected and calls fail.
+- **Without a token** the entry is just `type` + `url`. Calls through
+ `mcp.call_tool("ai-memory", ...)` still work, but the server is not listed in
+ the prompt or shown as connected in `/mcp`. Run the server with
+ `AI_MEMORY_AUTH_TOKEN` and pass `--auth-token` to get it listed.
+- **Use the camelCase key.** Prime Agent 0.10.0's own
+ `prime-agent mcp add --bearer-token-env-var` writes `bearer_token_env_var`,
+ which its settings loader ignores. Use `install-mcp` or edit the file.
+
+Prime Agent does not expose MCP tools as native tools. The model calls them
+from its persistent Python REPL:
+`await mcp.list_tools("ai-memory")`, then
+`await mcp.call_tool("ai-memory", "memory_query", {...})`. Requests carry no
+session id or working directory, so Prime Agent is a static client: pass
+`workspace` and `project` on project-scoped calls (the routing snippet from
+`ai-memory install-instructions --target AGENTS.md` says so, and Prime Agent
+loads `AGENTS.md`).
+
+Prime Agent 0.10 is a Rust rewrite: the TypeScript extensions of its 0.9
+releases, which were built on Pi, are gone, and it has no lifecycle hook
+surface. Automatic capture and handoff
+injection are therefore not claimed, and `install-hooks --agent pi` does not
+apply. Ask the agent to call `memory_handoff_begin` before leaving and
+`memory_handoff_accept` when resuming.
+
+Verified against Prime Agent 0.10.0. Sources:
+<https://github.com/PrimeIntellect-ai/prime-agent> (`crates/pa-core/src/mcp/mod.rs`,
+`crates/pa-cli/src/mcp_command.rs`, `prime-agent-runtime/src/rlm/mcp.py`,
+`skills/mcp/SKILL.md`).
+
+---
+
## Claude Desktop
**Status:** ✅ MCP supported (via stdio shim for HTTP). ❌ No lifecycle hooks
diff --git a/docs/support-matrix.md b/docs/support-matrix.md
index af895b46..5d4af43a 100644
--- a/docs/support-matrix.md
+++ b/docs/support-matrix.md
@@ -40,6 +40,7 @@
| Zed | MCP-only | Native remote MCP under `context_servers` in Zed's user `settings.json`; no lifecycle hooks or managed-workstream support. |
| Muse Code | MCP-only | `install-mcp --client muse` merges a native streamable-HTTP entry with bearer `headers` into the snake_case `mcp_servers` map of `~/.config/muse/settings.json`, preserving sibling servers. The writer adds the mandatory `"schema_version": 1` when absent (without it every `muse` command fails at startup) and never rewrites an existing value, and it sets `"mode": "optional"` because Muse's default `required` aborts the whole run when the server is unreachable. Skills need no extra step: Muse reads `~/.agents/skills`, which `install-skills` already writes. Lifecycle capture and managed workstreams are not claimed — Muse documents a hook surface, but the output contract of its `SessionStart` event is not specified. |
| DeepSeek Harness (DSH) | MCP-only | `install-mcp --client dsh` prints a Cordis patch fragment (a `- insert:` item for `@deepseek-ai/dsh-mcp-client`) to merge into `$DSH_HOME/profiles/<profile>/cordis.patch.yml`; DSH has no fixed MCP config file, so `--apply` is refused. Lifecycle capture is not claimed: DSH's `@deepseek-ai/dsh-hooks-claude-code` bridge can run a Claude Code hook config, but ai-memory's Claude Code hooks would report DSH sessions as `agent=claude-code`, and the bridge delivers only seven Claude Code events (`PreCompact` and `SessionEnd` are not), with a detached `SessionStart`. No managed workstream. |
+| Prime Agent | MCP-only | `install-mcp --client prime-agent` merges an HTTP entry (`type: "http"` + `url`) into the `mcpServers` map of `$PRIME_AGENT_CODING_AGENT_DIR/settings.json` (default `~/.prime/agent/settings.json`), preserving other settings and servers; a project's `.prime/agent/settings.json` works through `--config-file`. A token is referenced as `"bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"`, never written: Prime Agent 0.10 counts a user HTTP server as connected and names it in the model's prompt only with that variable set or an OAuth grant. A credential-less entry is still callable through `mcp.call_tool("ai-memory", ...)` but is not listed. The model reaches MCP tools from its Python REPL (`await mcp.call_tool("ai-memory", "memory_query", {...})`), and Prime Agent sends no session id or cwd, so pass `workspace` and `project` on project-scoped calls. Lifecycle capture and managed workstreams are not claimed: Prime Agent 0.10 removed the TypeScript extensions its 0.9 releases had and has no hook surface. Verified against Prime Agent 0.10.0. |
| Hermes Agent | Supported | `install-hooks --agent hermes` (alias `hermes-agent`) prints a ready-to-paste `hooks:` block for `~/.hermes/config.yaml`. Hermes splits each configured `command` with `shlex.split` and runs it with no shell, passing the event JSON on stdin, so the entries invoke the native `ai-memory hook` command (exec form, like Zero and ZCode — no script bundle is staged); ai-memory never writes that YAML file, which is yours to edit and which Hermes itself gates behind its hook-acceptance prompt (`hooks_auto_accept`). Two tool events are wired, `pre_tool_call` → `pre-tool-use` and `post_tool_call` → `post-tool-use`; their `tool_name` / `tool_input` payload drives concrete session attribution, tool-family titles, and capture exclusions. Session lifecycle (recall, prompt capture, session-end, automatic handoff) is owned by the community-maintained [`ai-memory-hermes-plugin`](https://github.com/MrLuciano/ai-memory-hermes-plugin) memory provider, so no hook-driven `session-end` is installed and nothing is duplicated; review that plugin's compatibility matrix, install/uninstall scripts, and secret handling before enabling it. No first-party `install-mcp` client and no managed workstream are claimed yet, and because Hermes ignores session-start hook stdout a pending handoff is recovered through MCP (`memory_handoff_list` then `memory_handoff_accept`). |
| GrizzyBot | Supported | [GrizzyBot](https://github.com/Foscoe63/GrizzyBot), a native macOS agent app, ships its own ai-memory bridge: it posts lifecycle events to `/hook` with `agent=grizzybot` (alias `grizzy-bot`) and talks to `/mcp` directly, so there is nothing for `install-hooks` or `install-mcp` to write. Sessions are attributed to `grizzybot`, and its Claude Code-shaped tool payloads (`tool_name`/`tool_input`/`tool_use_id`) are stored as closed-schema tool families, never tool names or arguments. The bridge is maintained in the GrizzyBot repository; review it before pointing it at a shared server. No managed workstream. |
| LLM/auth providers | Supported | Anthropic, OpenAI, OpenAI OAuth/Codex, GitHub Copilot, Gemini, OpenCode (Go and Zen), OpenAI-compatible endpoints, and generic OIDC device auth for native hooks. |