Skip to main content

Crate rmcp

Crate rmcp 

Source
Expand description

§rmcp

Crates.io Documentation

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

FeatureDescriptionDefault
serverServer functionality and the tool system
clientClient functionality
macros#[tool] / #[prompt] macros (re-exports rmcp-macros)
schemarsJSON Schema generation for tool definitions
authOAuth 2.0 authentication support
elicitationElicitation support

§Transport features

FeatureDescription
transport-ioServer-side stdio transport
transport-child-processClient-side stdio transport (spawns a child process)
transport-async-rwGeneric async read/write transport
transport-streamable-http-clientStreamable HTTP client (transport-agnostic)
transport-streamable-http-client-reqwestStreamable HTTP client with default reqwest backend
transport-streamable-http-serverStreamable HTTP server transport

§TLS backend options (for HTTP transports)

FeatureDescription
reqwestUses rustls — pure Rust TLS (recommended default)
reqwest-native-tlsUses platform-native TLS (OpenSSL / Secure Transport / SChannel)
reqwest-tls-no-providerUses rustls without a default crypto provider (bring your own)

§Transports

The transport layer is pluggable. Two built-in pairs cover the most common cases:

Any type that implements the Transport trait can be used. The IntoTransport helper trait provides automatic conversions from:

  1. (Sink, Stream) or a combined Sink + Stream
  2. (AsyncRead, AsyncWrite) or a combined AsyncRead + AsyncWrite
  3. A Worker implementation
  4. A Transport implementation 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;client
pub use handler::server::ServerHandler;server
pub use handler::server::wrapper::Json;server
pub use service::Peer;client or server
pub use service::Service;client or server
pub use service::ServiceError;client or server
pub use service::ServiceExt;client or server
pub use service::RoleClient;client
pub use service::serve_client;client
pub use service::RoleServer;server
pub use service::serve_server;server
pub use schemars;server or schemars
pub use serde;macros
pub use serde_json;macros

Modules§

handler
model
Basic data types in MCP specification
serviceclient or server
task_managerserver
transportclient or server
Transport

Macros§

const_string
elicit_safeelicitation
Macro to mark types as safe for elicitation by verifying they generate object schemas.
objectmacros
Use this macro just like serde_json::json!
pastemacros and server

Enums§

RmcpError
This is an unified error type for the errors could be returned by the service.

Type Aliases§

ErrorDeprecated

Attribute Macros§

promptmacros and server
prompt
prompt_handlermacros and server
prompt_handler
prompt_routermacros and server
prompt_router
task_handlermacros and server
task_handler
toolmacros and server
tool
tool_handlermacros and server
tool_handler
tool_routermacros and server
tool_router