macro_rules! tool {
($name:expr, $schema:expr, $handler:expr) => { ... };
($name:expr, $description:expr, $schema:expr, $handler:expr) => { ... };
}
Expand description
Helper macro for creating tools with schema validation
ยงExamples
use mcp_protocol_sdk::{tool, core::tool::ToolHandler};
use serde_json::json;
struct MyHandler;
#[async_trait::async_trait]
impl ToolHandler for MyHandler {
async fn call(&self, _args: std::collections::HashMap<String, serde_json::Value>) -> mcp_protocol_sdk::McpResult<mcp_protocol_sdk::protocol::types::ToolResult> {
// Implementation here
todo!()
}
}
let tool = tool!(
"my_tool",
"A sample tool",
json!({
"type": "object",
"properties": {
"input": { "type": "string" }
}
}),
MyHandler
);