#[claw_tool]Expand description
Attribute macro for defining MCP tools
This macro transforms an async function into an MCP tool definition with auto-generated JSON Schema for input parameters.
§Arguments
name- Optional tool name (defaults to function name)description- Optional tool description (defaults to doc comment)
§Requirements
- Function must be async
- Return type must be
ToolResultorResult<ToolResult, E> - Parameters must be JSON-serializable types
§Supported Parameter Types
String- JSON stringi32,i64,u32,u64,f32,f64- JSON numberbool- JSON booleanOption<T>- Optional parameter (not required in schema)Vec<T>- JSON array
§Example
ⓘ
use rusty_claw::prelude::*;
use rusty_claw::mcp_server::ToolResult;
#[claw_tool(name = "echo", description = "Echo a message")]
async fn echo_tool(message: String) -> ToolResult {
ToolResult::text(message)
}
// Use the generated tool
let tool = echo_tool();
assert_eq!(tool.name, "echo");