| Crates.io | mcp_rs |
| lib.rs | mcp_rs |
| version | 0.1.0 |
| created_at | 2024-11-29 09:09:02.005934+00 |
| updated_at | 2024-11-29 09:09:02.005934+00 |
| description | a library for making MCP (Model Context Protocol) compatible programs with rust |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1465319 |
| size | 136,599 |
A Rust implementation of the Model Context Protocol (MCP), providing a standardized way for AI models to access external context and resources.
For sse transport:
# Terminal 1 - Start server
cargo run --bin server -- -t sse -p 3000
# Terminal 2 - Run test client
cargo test test_sse_client -- --nocapture
For STDIO transport:
# Terminal 1 - Start server
cargo run --bin server -- -t stdio
# Terminal 2 - Run CLI client
cargo run --example cli_client
mcp.rs is a high-performance, type-safe Rust implementation of the Model Context Protocol, designed to enable seamless communication between AI applications and their integrations. It provides a robust foundation for building MCP servers that can expose various types of resources (files, data, APIs) to AI models.
Multiple Transport Types:
Resource Management:
Flexible Configuration:
Security:
Add mcp.rs to your project's Cargo.toml:
[dependencies]
mcp = "0.1.0"
use mcp::{McpServer, ServerConfig};
#[tokio::main]
async fn main() -> Result<(), mcp::error::McpError> {
// Create server with default configuration
let server = McpServer::new(ServerConfig::default());
// Run the server
server.run().await
}
# Run with stdio transport
mcp-server -t stdio
# Run with SSE transport on port 3000
mcp-server -t sse -p 3000
# Enable debug logging
mcp-server -l debug
server:
name: "my-mcp-server"
version: "1.0.0"
transport: sse
port: 3000
resources:
root_path: "./resources"
allowed_schemes:
- file
max_file_size: 10485760
security:
enable_auth: false
allowed_origins:
- "*"
logging:
level: "info"
format: "pretty"
mcp.rs follows a modular architecture:
| Option | Description | Default |
|---|---|---|
transport |
Transport type (stdio, sse) | stdio |
port |
Server port for network transports | 3000 |
log_level |
Logging level | info |
resource_root |
Root directory for resources | ./resources |
For detailed API documentation, run:
cargo doc --open
Check out the /examples directory for:
Contributions are welcome! Please read our Contributing Guidelines before submitting pull requests.
# Run all tests
cargo test
# Run with logging
RUST_LOG=debug cargo test
This project is licensed under the MIT License.
This implementation is based on the Model Context Protocol specification and inspired by the reference implementation.