mcp-core
Core MCP (Model Context Protocol) types, traits, and transport implementations for Rust.
Overview
mcp-core provides the fundamental building blocks for implementing MCP clients and servers in Rust. It includes:
- Protocol Types: All MCP message types, including initialization, tools, resources, and prompts
- Transport Layer: Pluggable transport implementations (stdio, HTTP SSE, HTTP streaming)
- Client Implementation: High-level MCP client with automatic session management
- Error Handling: Comprehensive error types for robust MCP implementations
Features
- 🚀 High Performance: Built on Tokio for async I/O
- 🔌 Pluggable Transports: Support for stdio, HTTP SSE, and HTTP streaming
- 🛡️ Type Safety: Fully typed MCP protocol implementation
- 🔄 Session Management: Automatic session handling and reconnection
- 📝 Comprehensive Logging: Detailed tracing for debugging
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic Client Usage
use ;
async
Transport Configuration
Stdio Transport
let config = stdio;
HTTP SSE Transport
let config = http_sse?;
HTTP Stream Transport
let config = http_stream?;
Architecture
The crate is organized into several modules:
client: High-level MCP client implementationmessages: All MCP protocol message types and serializationtransport: Transport layer abstractions and implementationserror: Error types and handling
Transport Layer
The transport layer uses a trait-based design for extensibility:
This allows for easy implementation of custom transports while maintaining a consistent interface.
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.