mcp_sdk_rs/lib.rs
1//! # Model Context Protocol (MCP) Rust SDK
2//!
3//! This SDK provides a Rust implementation of the Model Context Protocol (MCP), a protocol designed
4//! for communication between AI models and their runtime environments. The SDK supports both client
5//! and server implementations with multiple transport layers.
6//!
7//! ## Features
8//!
9//! - Full implementation of MCP protocol specification
10//! - Multiple transport layers (WebSocket, stdio)
11//! - Async/await support using Tokio
12//! - Type-safe message handling
13//! - Comprehensive error handling
14//!
15//! ## Example
16//!
17//! ```no_run
18//! use std::sync::Arc;
19//! use mcp_sdk_rs::client::{Client, Session};
20//! use mcp_sdk_rs::transport::websocket::WebSocketTransport;
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//! // Create WebSocket transport
25//! let transport = WebSocketTransport::new("ws://127.0.0.1:8780").await?;
26//!
27//! // Create client communication channel
28//! let (request_tx, response_rx) = tokio::sync::mpsc::unbounded_channel();
29//! let (response_tx, request_rx) = tokio::sync::mpsc::unbounded_channel();
30//!
31//! // Create a session and start listening for requests and notifications
32//! let session = Session::new(Arc::new(transport), response_tx, request_rx, None);
33//! session.start().await?;
34//!
35//! // Create MCP client
36//! let client = Client::new(request_tx, response_rx);
37//!
38//! // Use the client...
39//!
40//! Ok(())
41//! }
42//! ```
43
44/// Client module provides the MCP client implementation
45pub mod client;
46/// Error types and handling for the SDK
47pub mod error;
48/// Protocol-specific types and implementations
49pub mod protocol;
50/// Server module provides the MCP server implementation
51pub mod server;
52/// Transport layer implementations (WebSocket, stdio)
53pub mod transport;
54/// Common types used throughout the SDK
55pub mod types;
56
57// Re-export commonly used types for convenience
58pub use error::Error;
59pub use protocol::{
60 Notification, Request, Response, JSONRPC_VERSION, LATEST_PROTOCOL_VERSION,
61 SUPPORTED_PROTOCOL_VERSIONS,
62};
63pub use types::*;