feat(mcp): implement Prompts capability, Resources, and clean up daemon architecture

This commit is contained in:
Riz Ashraf committed 2026-09-22 21:41:17 +01:00
1 parent 9b9b403ef2
commit 251757f8fc
29 files changed
+1276 -182

No files matched your search

+44
View File
@@ -30,3 +30,47 @@ pub fn tool_def<T: JsonSchema>(name: &str, description: &str) -> serde_json::Val
"inputSchema": schema_val
})
}
#[cfg(test)]
mod tests {
use super::*;
use schemars::JsonSchema;
use serde::Serialize;
#[derive(JsonSchema, Serialize)]
struct DummyTool {
name: String,
age: i32,
}
#[test]
fn test_success_response() {
let res = success(json!(1), json!({"status": "ok"}));
assert_eq!(res["jsonrpc"], "2.0");
assert_eq!(res["id"], 1);
assert_eq!(res["result"]["status"], "ok");
}
#[test]
fn test_error_response() {
let err = error(json!(2), -32603, "internal error");
assert_eq!(err["jsonrpc"], "2.0");
assert_eq!(err["id"], 2);
assert_eq!(err["error"]["code"], -32603);
assert_eq!(err["error"]["message"], "internal error");
}
#[test]
fn test_tool_def_generation() {
let def = tool_def::<DummyTool>("dummy", "A dummy tool");
assert_eq!(def["name"], "dummy");
assert_eq!(def["description"], "A dummy tool");
assert!(def["inputSchema"].is_object());
let schema = def["inputSchema"].as_object().unwrap();
let properties = schema["properties"].as_object().unwrap();
assert!(properties.contains_key("name"));
assert!(properties.contains_key("age"));
}
}