Skip to main content

mcp_handler

Attribute Macro mcp_handler 

Source
#[mcp_handler]
Expand description

Creates an MCP handler with the specified tools, resources, and prompts.

This macro generates all the necessary WebAssembly bindings and handler logic with zero runtime overhead. It handles WIT file generation automatically, so you don’t need any local WIT files in your project.

§Example

use wasmcp::mcp_handler;

#[mcp_handler(
    tools(EchoTool, CalculatorTool),
    resources(ConfigResource),
    prompts(GreetingPrompt),
)]
mod handler {}