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 via a stdio-based transport layer.
Located at https://github.com/darinkishore/mcp_client_rust
§Features
- Full implementation of MCP protocol specification
- Stdio transport layer
- Async/await support using Tokio
- Type-safe message handling
- Comprehensive error handling
§Example
use std::sync::Arc;
use mcp_client_rs::client::Client;
use mcp_client_rs::transport::stdio::StdioTransport;
use tokio::io::{stdin, stdout};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a Stdio transport using standard input/output
let transport = StdioTransport::with_streams(stdin(), stdout())?;
// Create the client with Arc-wrapped transport
let client = Client::new(Arc::new(transport));
// Use the client...
Ok(())
}
§Usage
The client can be used to send requests and notifications to an MCP-compliant server. See the client module for details on initialization and tool usage.
Re-exports§
pub use error::Error;
pub use protocol::Notification;
pub use protocol::Request;
pub use protocol::Response;
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 (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