From 56fc3a20d8f25948d7136143b88d5a9c25fcfc7d Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Fri, 3 Apr 2026 20:22:48 -0400 Subject: [PATCH] move mcp-schema to standalone binary in src/claude/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mcp-schema is Claude Code glue — extract from poc-memory subcommand to src/claude/mcp-schema.rs standalone binary. Update Python MCP bridge to call the new binary. Co-Developed-By: Kent Overstreet --- Cargo.toml | 4 ++++ src/claude/mcp-schema.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/main.rs | 6 +----- 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/claude/mcp-schema.rs diff --git a/Cargo.toml b/Cargo.toml index c333ccf..833e41a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,3 +104,7 @@ path = "src/claude/poc-daemon.rs" [[bin]] name = "memory-search" path = "src/claude/memory-search.rs" + +[[bin]] +name = "mcp-schema" +path = "src/claude/mcp-schema.rs" diff --git a/src/claude/mcp-schema.rs b/src/claude/mcp-schema.rs new file mode 100644 index 0000000..1a64d03 --- /dev/null +++ b/src/claude/mcp-schema.rs @@ -0,0 +1,38 @@ +// mcp-schema — Output MCP tool definitions as JSON +// +// Claude Code's Python MCP bridge calls this at startup to +// discover available tools. The Rust ToolDef definitions are +// the source of truth. + +fn main() { + use serde_json::json; + + // Map tool names to CLI args + stdin param. + let cli_map: std::collections::HashMap<&str, (Vec<&str>, Option<&str>)> = [ + ("memory_render", (vec!["render"], None)), + ("memory_write", (vec!["write"], Some("content"))), + ("memory_search", (vec!["graph", "spread"], None)), + ("memory_links", (vec!["graph", "link"], None)), + ("memory_link_set", (vec!["graph", "link-set"], None)), + ("memory_link_add", (vec!["graph", "link-add"], None)), + ("memory_used", (vec!["used"], None)), + ("memory_weight_set", (vec!["weight-set"], None)), + ("memory_rename", (vec!["node", "rename"], None)), + ("memory_query", (vec!["query"], None)), + ].into_iter().collect(); + + let defs = poc_memory::thought::memory::definitions(); + let json_out: Vec<_> = defs.iter().filter_map(|d| { + let name = &d.function.name; + let (cli, stdin_param) = cli_map.get(name.as_str())?; + Some(json!({ + "name": name, + "description": d.function.description, + "inputSchema": d.function.parameters, + "cli": cli, + "stdin_param": stdin_param, + })) + }).collect(); + + println!("{}", serde_json::to_string_pretty(&json_out).unwrap()); +} diff --git a/src/main.rs b/src/main.rs index 268ce9d..c4450a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -220,10 +220,6 @@ EXAMPLES: /// Admin operations (fsck, health, import, export) #[command(subcommand)] Admin(AdminCmd), - - /// Output MCP tool definitions as JSON (for generic MCP bridge) - #[command(name = "mcp-schema")] - McpSchema, } #[derive(Subcommand)] @@ -818,7 +814,7 @@ impl Run for Command { Self::Cursor(sub) => sub.run(), Self::Agent(sub) => sub.run(), Self::Admin(sub) => sub.run(), - Self::McpSchema => cli::misc::cmd_mcp_schema(), + // mcp-schema moved to standalone binary src/claude/mcp-schema.rs } } }