#[tool]Expand description
Defines a tool handler.
The function signature should be:
ⓘ
async fn tool_name(ctx: &McpContext, args...) -> Result§Attributes
name- Override the tool name (default: function name)description- Tool description (default: doc comment)tags- List of tool tags for filtering (tags = ["api", "read"])
§Parameter Defaults
Rust has no default function arguments. For feature parity with Python FastMCP,
#[tool] supports per-parameter defaults via defaults(...):
ⓘ
#[tool(defaults(title = "World"))]
fn greet(name: String, title: String) -> String {
format!("Hello {title} {name}")
}If the argument is omitted in the JSON-RPC call, the default value is used.