Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(install-mcp): append /mcp to an explicit --server-url base (#185)
AkitaOnRailsa4a93886d5c0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9b5f93f7..7b585473 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Fixed+- `install-mcp --server-url` now appends the `/mcp` path when given a base+ URL (the same value `install-hooks --server-url` takes), instead of+ rendering a client config that points at the server root and 404s. The+ suffix join is idempotent, so passing the full `…/mcp` endpoint still+ works unchanged; only a URL deliberately pointing MCP at a path not+ ending in `/mcp` (an exotic reverse-proxy rewrite) would notice+ ([#185]).- Opening a store whose schema is *newer* than the running binary now failswith an actionable error instead of refinery's raw "migration V… is missingfrom the filesystem" wording. When an applied migration is absent from thediff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rsindex a105dfc5..c803e9ea 100644--- a/crates/ai-memory-cli/src/cli.rs+++ b/crates/ai-memory-cli/src/cli.rs@@ -1320,9 +1320,12 @@ pub struct InstallMcpArgs {/// Which MCP client to render configuration for.#[arg(long, value_enum, default_value_t = McpClient::ClaudeCode)]pub client: McpClient,- /// MCP HTTP endpoint URL the client should connect to. Defaults to the- /// configured `server_url` / AI_MEMORY_SERVER_URL plus `/mcp` when set,- /// else loopback.+ /// Server URL the client should connect to — either the base URL+ /// (`https://host:49374`, the same value `install-hooks --server-url`+ /// takes) or the full MCP endpoint (`…/mcp`); a missing `/mcp` suffix+ /// is appended automatically (#185). Defaults to the configured+ /// `server_url` / AI_MEMORY_SERVER_URL plus `/mcp` when set, else+ /// loopback.////// `Option` (no `default_value_t`) is deliberate: see the matching/// comment on `InstallHooksArgs::server_url` — same bug, same fix.diff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rsindex 75c0509c..da1cd119 100644--- a/crates/ai-memory-cli/src/commands/install_mcp.rs+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs@@ -76,7 +76,13 @@ pub fn run(config: &Config, args: InstallMcpArgs) -> Result<()> {fn effective_mcp_server_url(config: &Config, args: &InstallMcpArgs) -> String {if let Some(url) = &args.server_url {- return url.clone();+ // Normalize an explicit --server-url exactly like the config/env+ // branch below: users habitually pass the BASE url (the same value+ // `install-hooks --server-url` takes), and returning it verbatim+ // rendered a config pointing at the server root, which 404s (#185).+ // `mcp_server_url_from_base` is idempotent for full `/mcp` endpoints,+ // so callers who already pass the endpoint are unchanged.+ return mcp_server_url_from_base(url);}if config.server_url_configured() {return mcp_server_url_from_base(&config.server_url);@@ -910,6 +916,34 @@ mod tests {);}+ /// Regression for #185: an explicit `--server-url` passed as a BASE url+ /// (the same value `install-hooks --server-url` takes) must gain the+ /// `/mcp` suffix, or every client renderer emits a config pointing at+ /// the server root, which 404s. Trailing slashes are trimmed first.+ #[test]+ fn mcp_server_url_explicit_base_url_gains_mcp_suffix() {+ let config = Config::default();+ let mut args = args_for(McpClient::ClaudeCode);+ args.server_url = Some("https://memory.example.com".into());+ assert_eq!(+ effective_mcp_server_url(&config, &args),+ "https://memory.example.com/mcp"+ );++ args.server_url = Some("https://memory.example.com/".into());+ assert_eq!(+ effective_mcp_server_url(&config, &args),+ "https://memory.example.com/mcp"+ );++ // A reverse-proxy base path keeps its prefix.+ args.server_url = Some("https://host/prefix".into());+ assert_eq!(+ effective_mcp_server_url(&config, &args),+ "https://host/prefix/mcp"+ );+ }+#[test]fn mcp_server_url_explicit_flag_wins_over_config() {let config = Config {