Expand description
§rmcp
The official Rust SDK for the Model Context Protocol. Build MCP servers that expose tools, resources, and prompts to AI assistants — or build clients that connect to them.
For getting started, usage guides, and full MCP feature documentation (resources, prompts, sampling, roots, logging, completions, subscriptions, etc.), see the main README.
§Feature Flags
| Feature | Description | Default |
|---|---|---|
server | Server functionality and the tool system | ✅ |
client | Client functionality | |
macros | #[tool] / #[prompt] macros (re-exports rmcp-macros) | ✅ |
schemars | JSON Schema generation for tool definitions | |
auth | OAuth 2.0 authentication support | |
elicitation | Elicitation support |
§Transport features
| Feature | Description |
|---|---|
transport-io | Server-side stdio transport |
transport-child-process | Client-side stdio transport (spawns a child process) |
transport-async-rw | Generic async read/write transport |
transport-streamable-http-client | Streamable HTTP client (transport-agnostic) |
transport-streamable-http-client-reqwest | Streamable HTTP client with default reqwest backend |
transport-streamable-http-server | Streamable HTTP server transport |
§TLS backend options (for HTTP transports)
| Feature | Description |
|---|---|
reqwest | Uses rustls — pure Rust TLS (recommended default) |
reqwest-native-tls | Uses platform-native TLS (OpenSSL / Secure Transport / SChannel) |
reqwest-tls-no-provider | Uses rustls without a default crypto provider (bring your own) |
§Transports
The transport layer is pluggable. Two built-in pairs cover the most common cases:
| Client | Server | |
|---|---|---|
| stdio | TokioChildProcess | stdio |
| Streamable HTTP | StreamableHttpClientTransport | StreamableHttpService |
Any type that implements the Transport trait can be used. The IntoTransport helper trait provides automatic conversions from:
(Sink, Stream)or a combinedSink + Stream(AsyncRead, AsyncWrite)or a combinedAsyncRead + AsyncWrite- A
Workerimplementation - A
Transportimplementation directly
§License
This project is licensed under the terms specified in the repository’s LICENSE file.
Re-exports§
pub use error::ErrorData;pub use handler::client::ClientHandler;clientpub use handler::server::ServerHandler;serverpub use handler::server::wrapper::Json;serverpub use service::Peer;clientorserverpub use service::Service;clientorserverpub use service::ServiceError;clientorserverpub use service::ServiceExt;clientorserverpub use service::RoleClient;clientpub use service::serve_client;clientpub use service::RoleServer;serverpub use service::serve_server;serverpub use schemars;serverorschemarspub use serde;macrospub use serde_json;macros
Modules§
- handler
- model
- Basic data types in MCP specification
- service
clientorserver - task_
manager server - transport
clientorserver - Transport
Macros§
- const_
string - elicit_
safe elicitation - Macro to mark types as safe for elicitation by verifying they generate object schemas.
- object
macros - Use this macro just like
serde_json::json! - paste
macrosandserver
Enums§
- Rmcp
Error - This is an unified error type for the errors could be returned by the service.
Type Aliases§
- Error
Deprecated
Attribute Macros§
- prompt
macrosandserver - prompt
- prompt_
handler macrosandserver - prompt_handler
- prompt_
router macrosandserver - prompt_router
- task_
handler macrosandserver - task_handler
- tool
macrosandserver - tool
- tool_
handler macrosandserver - tool_handler
- tool_
router macrosandserver - tool_router