diff --git a/server/src/mcp.rs b/server/src/mcp.rs index 1f6f67d..b0a156d 100644 --- a/server/src/mcp.rs +++ b/server/src/mcp.rs @@ -20,13 +20,19 @@ pub fn error(id: serde_json::Value, code: i32, message: &str) -> serde_json::Val }) } -pub fn tool_def(name: &str, description: &str) -> serde_json::Value { +pub fn tool_def(name: &str, fallback_desc: &str) -> serde_json::Value { let schema = schemars::schema_for!(T); let schema_val = serde_json::to_value(&schema).unwrap_or_default(); + + let desc = schema_val.get("description") + .and_then(|d| d.as_str()) + .unwrap_or(fallback_desc) + .to_string(); + // MCP expects standard JSON schema. Schemars returns draft-07. json!({ "name": name, - "description": description, + "description": desc, "inputSchema": schema_val }) } diff --git a/server/src/tools.rs b/server/src/tools.rs index 1a7bbc6..f75f2f7 100644 --- a/server/src/tools.rs +++ b/server/src/tools.rs @@ -55,7 +55,7 @@ pub struct DeleteRelationsTool { pub relations: Vec, } -/// Read the entire knowledge graph. +/// Read the entire knowledge graph. WARNING: For large graphs, use search_nodes instead to avoid context limits. #[derive(Debug, Deserialize, Serialize, JsonSchema)] pub struct ReadGraphTool { /// Optional namespace to restrict the read to.