Expand description
§MCP Core Library
mcp-core provides the foundational types, traits, and implementations for the
Model Context Protocol (MCP). This crate is the core building block for MCP
clients and debugging tools.
§Features
- Complete MCP Message Types: All JSON-RPC message structures defined by the MCP specification
- Transport Abstraction: Unified interface for stdio, HTTP+SSE, and HTTP streaming transports
- Type-Safe Configuration: Compile-time validated configuration for all transport types
- Comprehensive Error Handling: Structured error types for all failure modes
- Async-First Design: Built on tokio for high-performance async I/O
- High-Level Client: Ready-to-use MCP client with protocol handling
§Quick Start
use mcp_probe_core::{
client::{McpClient, ClientConfig},
transport::TransportConfig,
messages::Implementation,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure a stdio transport
let config = TransportConfig::stdio("python", &["server.py"]);
// Create and connect client
let mut client = McpClient::with_defaults(config).await?;
let client_info = Implementation {
name: "mcp-probe".to_string(),
version: "0.1.0".to_string(),
metadata: std::collections::HashMap::new(),
};
let server_info = client.connect(client_info).await?;
println!("Connected to: {}", server_info.implementation.name);
Ok(())
}§Architecture
The library is organized into several key modules:
error: Comprehensive error types for all MCP operationsmessages: Complete MCP message type definitionstransport: Transport abstraction and implementationsclient: High-level MCP client interface
§Transport Support
This crate supports all three MCP transport mechanisms:
- stdio: Local process communication (enabled by default)
- http-sse: HTTP + Server-Sent Events (enabled by default)
- http-stream: Full-duplex HTTP streaming (enabled by default)
Transport support can be controlled via feature flags.
Re-exports§
pub use client::ClientConfig;pub use client::ClientState;pub use client::ClientStats;pub use client::McpClient;pub use client::ServerInfo;pub use error::McpError;pub use error::McpResult;pub use messages::Capabilities;pub use messages::Implementation;pub use messages::InitializeRequest;pub use messages::InitializeResponse;pub use messages::InitializedNotification;pub use messages::JsonRpcMessage;pub use messages::JsonRpcNotification;pub use messages::JsonRpcRequest;pub use messages::JsonRpcResponse;pub use messages::ProtocolVersion;pub use transport::Transport;pub use transport::TransportConfig;pub use transport::TransportFactory;pub use transport::TransportInfo;
Modules§
- client
- MCP Client Implementation
- error
- Error types for MCP (Model Context Protocol) operations.
- messages
- MCP (Model Context Protocol) message types and JSON-RPC structures.
- transport
- MCP transport layer abstraction and implementations.
Constants§
- PROTOCOL_
VERSION - Current MCP protocol version supported by this library
- VERSION
- Current version of the mcp-core library