anyclaw-sdk-tool 0.2.10

Tool SDK for anyclaw — build MCP-compatible tool servers
Documentation

anyclaw-sdk-tool

Build MCP-compatible tool servers for anyclaw — implement the Tool trait and the SDK handles all MCP protocol framing over stdio.

crates.io docs.rs

⚠️ Unstable — APIs may change between releases.

Quick Example

use anyclaw_sdk_tool::{Tool, ToolSdkError, ToolServer};
use serde_json::{Value, json};

struct MyTool;

impl Tool for MyTool {
    fn name(&self) -> &str { "my-tool" }

    fn description(&self) -> &str { "Does something useful" }

    fn input_schema(&self) -> Value {
        json!({
            "type": "object",
            "properties": {
                "query": { "type": "string" }
            },
            "required": ["query"]
        })
    }

    async fn execute(&self, input: Value) -> Result<Value, ToolSdkError> {
        let query = input["query"].as_str().unwrap_or("");
        Ok(json!({ "result": format!("processed: {query}") }))
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    ToolServer::new(vec![Box::new(MyTool)])
        .serve_stdio()
        .await
}

One binary can register multiple tools — pass them all to ToolServer::new. The server dispatches call_tool requests by name.

Going Further

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.