#[tool]Expand description
Marks an async function as an MCP tool and generates a companion
{fn_name}_tool_def() function that returns a mcp::ToolDef.
§Attributes
description = "..."— human-readable description (required)name = "..."— tool name (defaults to the function name)
§Example
ⓘ
use mcp_kit::prelude::*;
/// Add two numbers together.
#[tool(description = "Add two numbers")]
async fn add(a: f64, b: f64) -> String {
format!("{}", a + b)
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Register with the builder:
let _server = McpServer::builder()
.name("example")
.version("1.0.0")
.tool_def(add_tool_def())
.build();
Ok(())
}Each function parameter must implement serde::Deserialize and will be
extracted from the tool call’s arguments JSON object by field name.