Refactor to Pure Native JSON-RPC (Ditch SDKs)

This commit is contained in:
Riz Ashraf committed 2026-09-08 21:50:40 +01:00
1 parent 5f0eba8a80
commit f9dee11f32
9 files changed
+575 -1169

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
use schemars::JsonSchema;
use serde_json::json;
pub fn success(id: serde_json::Value, result: serde_json::Value) -> serde_json::Value {
json!({
"jsonrpc": "2.0",
"id": id,
"result": result
})
}
pub fn error(id: serde_json::Value, code: i32, message: &str) -> serde_json::Value {
json!({
"jsonrpc": "2.0",
"id": id,
"error": {
"code": code,
"message": message
}
})
}
pub fn tool_def<T: JsonSchema>(name: &str, description: &str) -> serde_json::Value {
let schema = schemars::schema_for!(T);
let schema_val = serde_json::to_value(&schema).unwrap();
// MCP expects standard JSON schema. Schemars returns draft-07.
json!({
"name": name,
"description": description,
"inputSchema": schema_val
})
}