turbomcp_grpc/lib.rs
1//! `TurboMCP` gRPC Transport
2//!
3//! High-performance gRPC transport for the Model Context Protocol (MCP).
4//! Built on [tonic](https://github.com/hyperium/tonic) for async/await support
5//! and full HTTP/2 capabilities.
6//!
7//! # Features
8//!
9//! - **Server**: gRPC server implementation with streaming notifications
10//! - **Client**: gRPC client with automatic reconnection
11//! - **Tower Integration**: Composable middleware via Tower
12//! - **TLS**: Optional TLS 1.3 support via rustls
13//!
14//! # Quick Start
15//!
16//! ## Server
17//!
18//! ```ignore
19//! use turbomcp_grpc::server::McpGrpcServer;
20//! use turbomcp_types::Tool;
21//!
22//! let server = McpGrpcServer::builder()
23//! .add_tool(Tool { name: "hello".into(), ..Default::default() })
24//! // .tool_handler(MyHandler) // implements ToolHandler
25//! .build();
26//!
27//! tonic::transport::Server::builder()
28//! .add_service(server.into_service())
29//! .serve("[::1]:50051".parse()?)
30//! .await?;
31//! ```
32//!
33//! ## Client
34//!
35//! ```ignore
36//! use turbomcp_grpc::client::McpGrpcClient;
37//!
38//! let mut client = McpGrpcClient::connect("http://[::1]:50051").await?;
39//! client.initialize().await?;
40//! let result = client
41//! .call_tool("hello", Some(serde_json::json!({"name": "World"})))
42//! .await?;
43//! ```
44
45#![cfg_attr(docsrs, feature(doc_cfg))]
46#![warn(missing_docs)]
47#![warn(clippy::all)]
48#![warn(clippy::pedantic)]
49#![allow(clippy::module_name_repetitions)]
50
51/// Generated protobuf types for MCP
52pub mod proto {
53 #![allow(missing_docs)]
54 #![allow(clippy::all)]
55 #![allow(clippy::pedantic)]
56 tonic::include_proto!("turbomcp.mcp.v1");
57}
58
59pub mod convert;
60pub mod error;
61
62#[cfg(feature = "server")]
63#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
64pub mod server;
65
66#[cfg(feature = "client")]
67#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
68pub mod client;
69
70pub mod layer;
71
72// Re-exports for convenience
73pub use error::{GrpcError, GrpcResult};
74
75#[cfg(feature = "server")]
76pub use server::McpGrpcServer;
77
78#[cfg(feature = "client")]
79pub use client::McpGrpcClient;
80
81pub use layer::McpGrpcLayer;