| Crates.io | mcp-probe-core |
| lib.rs | mcp-probe-core |
| version | 0.3.0 |
| created_at | 2025-06-21 04:53:31.800602+00 |
| updated_at | 2025-06-30 06:21:59.521178+00 |
| description | Core MCP (Model Context Protocol) types, traits, and transport implementations |
| homepage | https://github.com/conikeec/mcp-probe |
| repository | https://github.com/conikeec/mcp-probe |
| max_upload_size | |
| id | 1720520 |
| size | 393,226 |
Core MCP (Model Context Protocol) types, traits, and transport implementations for Rust.
mcp-core provides the fundamental building blocks for implementing MCP clients and servers in Rust. It includes:
Add this to your Cargo.toml:
[dependencies]
mcp-core = "0.1.0"
use mcp_core::{
client::McpClient,
transport::TransportConfig,
messages::Implementation,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure transport (stdio example)
let config = TransportConfig::stdio("my-mcp-server", &["--arg1", "value1"]);
// Create client
let mut client = McpClient::with_defaults(config).await?;
// Connect with client info
let client_info = Implementation {
name: "my-client".to_string(),
version: "1.0.0".to_string(),
metadata: Default::default(),
};
let _server_info = client.connect(client_info).await?;
// List available tools
let tools = client.list_tools().await?;
println!("Available tools: {}", tools.len());
// Call a tool
if let Some(tool) = tools.first() {
let params = serde_json::json!({"param": "value"});
let result = client.call_tool(&tool.name, params).await?;
println!("Tool result: {:?}", result);
}
Ok(())
}
let config = TransportConfig::stdio("python", &["-m", "my_mcp_server"]);
let config = TransportConfig::http_sse("http://localhost:3000/sse")?;
let config = TransportConfig::http_stream("http://localhost:3000/stream")?;
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 handlingThe transport layer uses a trait-based design for extensibility:
#[async_trait]
pub trait Transport: Send + Sync {
async fn send_request(&mut self, request: JsonRpcRequest) -> Result<JsonRpcResponse>;
async fn start_session(&mut self, client_info: Implementation) -> Result<TransportInfo>;
// ... other methods
}
This allows for easy implementation of custom transports while maintaining a consistent interface.
Contributions are welcome! Please see the main repository for contribution guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.