MCP Macros
Procedural macros for the Model Context Protocol (MCP) Rust implementation.
Features
This crate provides procedural macros to reduce boilerplate when defining MCP servers:
#[mcp_server]- Define server metadata and collect tools from impl blocks#[mcp_tool]- Mark a method as an MCP tool#[param]- Document tool parameters for the LLM
Usage
use mcp_server;
;
Parameter Attributes
All tool parameters (except &self) must be marked with #[param(...)]:
// Shorthand - just the description:
// Full form - with additional options:
Options:
description- Description shown to the LLM (required for good UX)name- Custom parameter name override (optional, defaults to argument name)required- Override required/optional inference (optional, defaults based onOption<T>)
Tool Attributes
// Shorthand - just the description:
// Full form - with additional options:
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.