Skip to main content
Version: 1.1.0 (latest)

Macros Overview

The macros feature provides procedural macros that simplify common MCP tasks.

Enable with:

[dependencies]
rust-mcp-sdk = { version = "1.0", features = ["macros"] }

Available Macrosโ€‹

MacroPurpose
mcp_toolGenerate Tool from a struct
mcp_promptGenerate Prompt from a struct with message templates
mcp_elicitGenerate elicitation schemas
mcp_resourceGenerate static Resource definitions
mcp_resource_templateGenerate parameterized ResourceTemplate definitions
JsonSchemaDerive macro for JSON Schema generation

The tool_box! and mcp_icon! macros are plain macro_rules! exported from the SDK crate root - they are always available and do not require the macros feature.

MacroPurpose
tool_box!Generate an enum from multiple tools
mcp_icon!Convenient Icon builder