fix(mcp): extract and elevate struct docstrings into root tool schema descriptions to restore semantic LLM visibility
This commit is contained in:
1 parent
e84c101515
commit
05e3e53217
2 files changed
+9
-3
No files matched your search
+8
-2
@@ -20,13 +20,19 @@ pub fn error(id: serde_json::Value, code: i32, message: &str) -> serde_json::Val
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_def<T: JsonSchema>(name: &str, description: &str) -> serde_json::Value {
|
||||
pub fn tool_def<T: JsonSchema>(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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user