move mcp-schema to standalone binary in src/claude/
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 <kent.overstreet@linux.dev>
This commit is contained in:
parent
b24e8e87a2
commit
56fc3a20d8
3 changed files with 43 additions and 5 deletions
|
|
@ -104,3 +104,7 @@ path = "src/claude/poc-daemon.rs"
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "memory-search"
|
name = "memory-search"
|
||||||
path = "src/claude/memory-search.rs"
|
path = "src/claude/memory-search.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "mcp-schema"
|
||||||
|
path = "src/claude/mcp-schema.rs"
|
||||||
|
|
|
||||||
38
src/claude/mcp-schema.rs
Normal file
38
src/claude/mcp-schema.rs
Normal file
|
|
@ -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());
|
||||||
|
}
|
||||||
|
|
@ -220,10 +220,6 @@ EXAMPLES:
|
||||||
/// Admin operations (fsck, health, import, export)
|
/// Admin operations (fsck, health, import, export)
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
Admin(AdminCmd),
|
Admin(AdminCmd),
|
||||||
|
|
||||||
/// Output MCP tool definitions as JSON (for generic MCP bridge)
|
|
||||||
#[command(name = "mcp-schema")]
|
|
||||||
McpSchema,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
|
|
@ -818,7 +814,7 @@ impl Run for Command {
|
||||||
Self::Cursor(sub) => sub.run(),
|
Self::Cursor(sub) => sub.run(),
|
||||||
Self::Agent(sub) => sub.run(),
|
Self::Agent(sub) => sub.run(),
|
||||||
Self::Admin(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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue