Skip to main content

Crate tonin_mcp_macros

Crate tonin_mcp_macros 

Source
Expand description

Proc-macro that derives an MCP tool surface from a gRPC service impl.

§Don’t depend on this crate directly

Use tonin and write #[tonin::mcp_expose]. The umbrella crate re-exports this macro alongside the rmcp runtime it plugs into.

§Example

Before — a normal tonic service impl:

#[tonic::async_trait]
impl Greeter for GreeterImpl {
    async fn say_hello(
        &self,
        req: Request<HelloRequest>,
    ) -> Result<Response<HelloReply>, Status> { /* ... */ }
}

After — one attribute added:

#[tonic::async_trait]
#[tonin::mcp_expose]
impl Greeter for GreeterImpl {
    async fn say_hello(
        &self,
        req: Request<HelloRequest>,
    ) -> Result<Response<HelloReply>, Status> { /* ... */ }
}

Every gRPC method is now also an MCP tool, dispatched through a generated GreeterImplMcpAdapter that Service::handler wires into the in-process MCP server.

§Sample app

https://github.com/Rushit/tonin/tree/main/examples/greeter

Attribute Macros§

mcp_expose