6 releases
Uses new Rust 2024
| 3.0.0-exp.2 | Jan 13, 2026 |
|---|---|
| 3.0.0-exp | Jan 12, 2026 |
| 3.0.0-beta.3 | Jan 22, 2026 |
| 3.0.0-beta.2 | Jan 21, 2026 |
| 3.0.0-beta.1 | Jan 19, 2026 |
#1654 in Network programming
1MB
21K
SLoC
turbomcp-grpc
High-performance gRPC transport for the Model Context Protocol (MCP).
Features
- Server: Full gRPC server implementation with streaming notifications
- Client: gRPC client with automatic initialization and reconnection
- Tower Integration: Composable middleware via Tower layers
- TLS: Optional TLS 1.3 support via rustls
- Streaming: Server-streaming for real-time notifications
Installation
Add to your Cargo.toml:
[dependencies]
turbomcp-grpc = "3.0.0-alpha.1"
Quick Start
Server
use turbomcp_grpc::server::McpGrpcServer;
use turbomcp_core::types::tools::Tool;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = McpGrpcServer::builder()
.server_info("my-server", "1.0.0")
.add_tool(Tool {
name: "hello".to_string(),
description: Some("Says hello".to_string()),
input_schema: serde_json::json!({
"type": "object",
"properties": {
"name": {"type": "string"}
}
}),
annotations: None,
})
.build();
tonic::transport::Server::builder()
.add_service(server.into_service())
.serve("[::1]:50051".parse()?)
.await?;
Ok(())
}
Client
use turbomcp_grpc::client::McpGrpcClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = McpGrpcClient::connect("http://[::1]:50051").await?;
// Initialize the session
let init_result = client.initialize().await?;
println!("Connected to: {:?}", init_result.server_info);
// List available tools
let tools = client.list_tools().await?;
println!("Available tools: {:?}", tools);
// Call a tool
let result = client.call_tool("hello", Some(serde_json::json!({"name": "World"}))).await?;
println!("Result: {:?}", result);
Ok(())
}
Protocol Definition
The gRPC service is defined in src/proto/mcp.proto and includes:
Initialize- Session initializationPing- Health checkListTools/CallTool- Tool operationsListResources/ReadResource- Resource operationsListPrompts/GetPrompt- Prompt operationsSubscribe- Streaming notificationsComplete- Autocomplete suggestionsSetLoggingLevel- Logging configuration
Tower Integration
Use with Tower layers for composable middleware:
use turbomcp_grpc::layer::McpGrpcLayer;
use tower::ServiceBuilder;
let layer = McpGrpcLayer::new()
.timeout(Duration::from_secs(30))
.logging(true)
.timing(true);
let service = ServiceBuilder::new()
.layer(layer)
.service(inner_service);
Features
server(default) - Enable server implementationclient(default) - Enable client implementationhealth- Enable gRPC health checking servicereflection- Enable gRPC reflection for debuggingtls- Enable TLS support
License
MIT
Dependencies
~32–51MB
~777K SLoC