Expand description
§Model Context Protocol (MCP) Rust SDK
This SDK provides a Rust implementation of the Model Context Protocol (MCP), a protocol designed for communication between AI models and their runtime environments. The SDK supports both client and server implementations with multiple transport layers.
§Features
- Full implementation of MCP protocol specification
- Multiple transport layers (WebSocket, stdio)
- Async/await support using Tokio
- Type-safe message handling
- Comprehensive error handling
§Example
use std::sync::Arc;
use mcp_rust_sdk::client::Client;
use mcp_rust_sdk::transport::websocket::WebSocketTransport;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a WebSocket transport
let transport = WebSocketTransport::new("ws://localhost:8080").await?;
// Create the client with Arc-wrapped transport
let client = Client::new(Arc::new(transport));
// Use the client...
Ok(())
}
Re-exports§
pub use error::Error;
pub use protocol::Request;
pub use protocol::Response;
pub use protocol::Notification;
pub use types::*;
Modules§
- client
- Client module provides the MCP client implementation
- error
- Error types and handling for the SDK Error types for the MCP protocol.
- protocol
- Protocol-specific types and implementations
- server
- Server module provides the MCP server implementation
- transport
- Transport layer implementations (WebSocket, stdio)
- types
- Common types used throughout the SDK
Constants§
- JSONRPC_
VERSION - JSON-RPC version used by the MCP protocol
- LATEST_
PROTOCOL_ VERSION - The latest supported protocol version of MCP
- SUPPORTED_
PROTOCOL_ VERSIONS - List of all protocol versions supported by this SDK