mercutio
A Rust library for building MCP servers. mercutio handles the protocol (parsing messages, managing the initialization handshake, dispatching tool calls), while you handle the transport. The core is a pure state machine: feed it JSON-RPC messages, and it returns what to send back.
This sans-io design means you can run it over stdio, HTTP, WebSockets, or anything else without fighting the library.
If you'd rather not wire up your own transport, the io-* feature flags provide ready-made integrations.
Side-effect free usage
use ;
// Define your tools with the macro - generates input structs and dispatch enum.
// Field docstrings become JSON Schema descriptions that the LLM sees.
tool_registry!
let mut server = builder
.name
.version
.build;
// You provide the transport - MCP uses newline-delimited JSON
loop
Feature Flags
If you do not want/need to implement the IO harness yourself, mercutio has a few implementations ready:
io-stdlib- Synchronous stdin/stdout transport using standard library I/Oio-tokio- Async stdin/stdout transport using Tokio
io-stdlib
Runs an MCP server over stdin/stdout with newline-delimited JSON:
use Infallible;
use ;
tool_registry!
let server = builder
.name
.version
.build;
run_stdio?;
io-tokio
Async version using Tokio. Implement ToolHandler on a struct to use async operations:
use Infallible;
use ;
tool_registry!
;
async