| Crates.io | mcp_daemon |
| lib.rs | mcp_daemon |
| version | 0.2.1 |
| created_at | 2025-02-23 20:37:54.576079+00 |
| updated_at | 2025-02-24 04:49:33.215322+00 |
| description | Diverged Implementation of Model Context Protocol (MCP) with Extended Functionality |
| homepage | https://github.com/entrepeneur4lyf/mcp-daemon |
| repository | https://github.com/entrepeneur4lyf/mcp-daemon |
| max_upload_size | |
| id | 1566626 |
| size | 306,848 |
The most advanced and complete implementation of the Model Context Protocol (MCP) specification. This Rust implementation goes beyond the standard specification to provide:
This library sets the standard for MCP implementations with its comprehensive feature set and robust error handling.
Note: While this implementation provides the most complete coverage of the MCP specification, including features like sampling, roots, and completion that are not yet available in other implementations, it is still under active development.
Add this to your Cargo.toml:
[dependencies]
mcp-daemon = "0.2.0"
This is an implementation of the Model Context Protocol defined by Anthropic, with extensive modifications and improvements.
The mcp-daemon repository can be found at: https://github.com/entrepeneur4lyf/mcp-daemon
The HTTP transport layer provides a unified interface for both SSE and WebSocket connections:
actix-web-lab for robust server implementationtokio-tungstenite for async WebSocket supportTLS Support
CORS Configuration
The implementation provides a seamless bridge between MCP tools and LLM provider function calling formats:
The bridge layer automatically handles conversion between MCP tools and provider-specific formats:
OpenAI Integration
Ollama Integration
The bridge abstracts away provider differences, allowing you to write provider-agnostic code while the bridge handles the specific requirements and limitations of each LLM provider.
let server = Server::builder(StdioTransport)
.capabilities(ServerCapabilities {
tools: Some(json!({})),
..Default::default()
})
.request_handler("tools/list", list_tools)
.request_handler("tools/call", call_tool)
.request_handler("resources/list", |_req: ListRequest| {
Ok(ResourcesListResponse {
resources: vec![],
next_cursor: None,
meta: None,
})
})
.build();
// Server configuration with TLS and CORS
let config = ServerConfig {
port: 3004,
cors: Some(CorsConfig {
allowed_origin: "https://example.com".to_string(),
allow_credentials: true,
max_age: Some(3600),
}),
tls: Some(TlsConfig {
cert_path: "path/to/cert.pem".to_string(),
key_path: "path/to/key.pem".to_string(),
}),
..Default::default()
};
// Run server with configuration
run_http_server(config, None, |transport| async move {
let server = build_server(transport);
Ok(server)
})
.await?;
Local Endpoints
// With TLS enabled:
WebSocket endpoint: wss://127.0.0.1:3004/ws
SSE endpoint: https://127.0.0.1:3004/sse
// Without TLS:
WebSocket endpoint: ws://127.0.0.1:3004/ws
SSE endpoint: http://127.0.0.1:3004/sse
// Stdio Transport
let transport = ClientStdioTransport::new("<CMD>", &[])?;
// In-Memory Transport
let transport = ClientInMemoryTransport::new(|t| tokio::spawn(inmemory_server(t)));
// SSE Transport
let transport = ClientSseTransportBuilder::new(server_url).build();
// WS Transport
let transport = mcp-daemon::transport::ClientWsTransportBuilder::new("ws://localhost:3004/ws".to_string()).build();
// Initialize transport
transport.open().await?;
// Create and start client
let client = mcp-daemon::client::ClientBuilder::new(transport.clone()).build();
let client_clone = client.clone();
let _client_handle = tokio::spawn(async move { client_clone.start().await });
// Make a request
client
.request(
"tools/call",
Some(json!({"name": "ping", "arguments": {}})),
RequestOptions::default().timeout(Duration::from_secs(5)),
)
.await?
MCP servers can be installed and run using npm. For example:
# Install and run Brave Search MCP server
npx -y @modelcontextprotocol/server-brave-search
# Install and run GitHub MCP server
npx -y @modelcontextprotocol/server-github
# Install and run NPM Search server
npx -y npm-search-mcp-server
Once servers are running, you can connect to them using the client:
// Example: Using Brave Search server
let transport = ClientSseTransportBuilder::new("http://localhost:3000/sse").build();
let client = mcp-daemon::client::ClientBuilder::new(transport.clone()).build();
// Make a search request
let response = client
.request(
"tools/call",
Some(json!({
"name": "brave_web_search",
"arguments": {
"query": "Rust programming language",
"count": 5
}
})),
RequestOptions::default(),
)
.await?;
Common MCP servers include:
Each server provides its own set of tools and resources that can be used through the MCP protocol. Check individual server documentation for specific capabilities and usage details.
For the complete feature set, please refer to the MCP specification.
Progress Notifications
Progress Tokens
Progress Values
This project is licensed under the Apache License 2.0, as was the original async-mcp project.
Special thanks to the original author of async-mcp, v3g42, for laying the foundation for this project.