rust-sdk/crates/rmcp-macros
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jiho Park be23334f9d
fix(tasks): avoid dropping completed task results during collection (#639)
* fix(tasks): avoid dropping completed task results during collection

* chore(tasks): make `task_result_receiver` required

* refactor(tasks): make `collect_completed_results` private
2026-02-05 09:00:09 +01:00
..
src fix(tasks): avoid dropping completed task results during collection (#639) 2026-02-05 09:00:09 +01:00
Cargo.toml chore(deps): update darling requirement from 0.21 to 0.23 (#574) 2025-12-09 09:15:05 +08:00
CHANGELOG.md chore: release v0.14.0 (#623) 2026-01-23 13:09:02 -05:00
README.md docs: show README content on docs.rs (#583) 2026-01-21 12:56:16 -05:00

rmcp-macros

Crates.io Documentation

rmcp-macros is a procedural macro library for the Rust Model Context Protocol (RMCP) SDK, providing macros that facilitate the development of RMCP applications.

Available Macros

Macro Description
#[tool] Mark a function as an MCP tool handler
#[tool_router] Generate a tool router from an impl block
#[tool_handler] Generate call_tool and list_tools handler methods
#[prompt] Mark a function as an MCP prompt handler
#[prompt_router] Generate a prompt router from an impl block
#[prompt_handler] Generate get_prompt and list_prompts handler methods
#[task_handler] Wire up the task lifecycle on top of an OperationProcessor

Quick Example

use rmcp::{tool, tool_router, tool_handler, ServerHandler, model::*};

#[derive(Clone)]
struct MyServer {
    tool_router: rmcp::handler::server::tool::ToolRouter<Self>,
}

#[tool_router]
impl MyServer {
    #[tool(description = "Say hello")]
    async fn hello(&self) -> String {
        "Hello, world!".into()
    }
}

#[tool_handler]
impl ServerHandler for MyServer {
    fn get_info(&self) -> ServerInfo {
        ServerInfo::default()
    }
}

See the full documentation for detailed usage of each macro.

License

Please refer to the LICENSE file in the project root directory.