Skip to main content

tools

Macro tools 

Source
macro_rules! tools {
    () => { ... };
    ($($tool:expr),+ $(,)?) => { ... };
}
Expand description

Creates a vector of tools from tool types.

This macro makes it easy to register multiple tools at once:

use mcp::macros::mcp_tool;
use mcp::{McpServerConfig, McpServer, tools};

#[mcp_tool(description = "Add numbers")]
fn add(a: f64, b: f64) -> f64 { a + b }

#[mcp_tool(description = "Subtract numbers")]
fn subtract(a: f64, b: f64) -> f64 { a - b }

let config = McpServerConfig::builder()
    .name("calc")
    .with_tools(tools![AddTool, SubtractTool])
    .build();