tmcp
A complete Rust implementation of the Model Context Protocol (MCP), providing both client and server capabilities for building AI-integrated applications.
Overview
tmcp offers an ergonomic API for implementing MCP servers and clients with support for tools, resources, and prompts. The library uses async/await patterns with Tokio and provides procedural macros to eliminate boilerplate.
Features
- Derive Macros: Simple
#[mcp_server]attribute for automatic implementation - Multiple Transports: TCP, HTTP (with SSE), and stdio support
- Type Safety: Strongly typed protocol messages with serde
- Async-First: Built on Tokio for high-performance async I/O
Quick Example
use ;
use ;
;
// Tool input schema is automatically derived from the struct using serde and schemars.
// The mcp_server macro generates the necessary boilerplate to expose methods as MCP tools.
async
Transport Options
- TCP:
server.listen_tcp("127.0.0.1:3000") - HTTP:
server.listen_http("127.0.0.1:3000")(uses SSE for server->client) - Stdio:
server.listen_stdio()for subprocess integration