rust-mcp-sdk MCP server
2026년 11월 9일 커밋async transport, 매크로, OAuth 지원을 통해 Rust로 MCP server 및 client를 구축합니다.
다른 이름 rust-mcp-stack/rust-mcp-sdk
- 스타
- 200
- Tools
- —
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 11월 9일
- 라이선스
- MIT
rust-mcp-sdk MCP란?
async transport, 매크로, OAuth 지원을 통해 Rust로 MCP server 및 client를 구축합니다.
프로젝트 README에서 생성된 요약
rust-mcp-sdk MCP server 정보
이 비동기 Rust 툴킷의 주요 목적은 고성능 Model Context Protocol server 및 client를 개발하는 것입니다. 개발자에게 MCP 2026-07-28 stateless protocol을 구현하는 데 필요한 구성 요소를 제공하며, 엄격한 테스트를 통해 완전한 준수를 보장합니다. SDK는 Stdio, Streamable HTTP 및 하위 호환되는 SSE를 포함한 다양한 transport 방식을 지원하므로 로컬 및 원격 배포 모두에 적합합니다.
엔지니어는 Axum 또는 Actix backend를 사용하여 기존 애플리케이션에 툴킷을 통합하거나 BYO-server 방식을 사용할 수 있습니다. 이 라이브러리는 mcp_tool, mcp_resource, mcp_prompt와 같은 procedural macro를 통해 개발을 간소화하므로, 사용자는 프로토콜 구현 대신 애플리케이션 로직에 집중할 수 있습니다. 또한 Keycloak, WorkOS, Scalekit과 같은 provider를 통한 OAuth 인증 및 server-to-client input request를 위한 mid-request turn-around 기능과 같은 고급 기능을 포함합니다.
활용 사례
- 1로컬 MCP server 구축개발자가 표준 입출력을 통해 통신하는 최소 기능의 tool 기반 server를 생성할 수 있습니다.
- 2원격 HTTP server 배포Axum 또는 Actix 웹 프레임워크를 사용하여 원격 client가 접속할 수 있는 stateless MCP server를 호스팅할 수 있습니다.
- 3OAuth를 이용한 server 보안 강화개발자는 검증된 identity provider를 사용하여 MCP server에 안전한 인증을 구현할 수 있습니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능rust-mcp-stack/rust-mcp-sdk is public and reachablegithub.com/rust-mcp-stack/rust-mcp-sdk ↗통과
- 패키지가 이 저장소를 소스로 명시검사되지 않음
- 빌드 출처(Sigstore 증명)검사되지 않음
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-11-09github.com/rust-mcp-stack/rust-mcp-sdk ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 패키지 및 해당 종속성에 중요한 보안 권고 없음검사되지 않음
- 모델에 대한 숨겨진 지침 없음0 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨검사되지 않음
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기A high-performance, asynchronous Rust toolkit for building MCP servers and clients.
📖 Documentation · Tutorials · Examples · Upgrade Guide · Changelog Contributing · Report a bug · Request a Feature
🥇 Tier 1 SDK: passes 100% of scored conformance scenarios, and the official MCP conformance tool's tier-check reports Tier 1 under SEP-1730. Tier-check runs · release reports
✅ This SDK fully implements the MCP 2026-07-28 stateless protocol and passes 100% of official MCP conformance tests.
rust-mcp-sdk provides the necessary components for developing both servers and clients in the MCP ecosystem. It leverages the rust-mcp-schema crate for type-safe schema objects and includes powerful procedural macros.
Focus on your application logic, rust-mcp-sdk handles the protocol, transports, and the rest.
Version notice: This is rust-mcp-sdk 2.x, implementing the new MCP 2026-07-28 (stateless) specification.
For the previous MCP 2025-11-25 specification, use rust-mcp-sdk 1.x.
See the upgrade guide to migrate from 1.x to 2.0.
Version matrix:
| SDK version | Protocol | Branch |
|---|---|---|
| 2.0 | MCP 2026-07-28 (stateless) | main |
| 1.x (LTS) | MCP 2025-11-25 | release-1.x |
Upgrading? See the upgrade guide.
Key Features
- ✅ Latest MCP protocol specification supported: 2026-07-28
- 🥇 Tier 1 SDK - official MCP conformance tool's
tier-checkreports Tier 1 under SEP-1730. see tier-check runs· - ✅ 100% MCP Conformance - passes all official client (254/254) and server (40/40) conformance tests
- ✅ Transports: Stdio, Streamable HTTP, and backward-compatible SSE support
- ✅ Framework Agnostic: Axum, Actix, and BYO Server integrations
- ✅ MRTR (Mid-Request Turn-Around) for server→client input requests
- ✅ Response cache (SEP-2549) with principal-scoped privacy + auto-pagination
- ✅ Per-request
_metawithRequestContext - ✅ Multi-client concurrency
- ✅ DNS Rebinding Protection
- ✅ Message Observer (Telemetry & Monitoring)
- ✅ HTTP Health Checks (for load balancers & container orchestration)
- ✅ OAuth Authentication for MCP Servers
- ✅ Remote Oauth Provider
- Keycloak Provider (via rust-mcp-extra)
- WorkOS Authkit Provider (via rust-mcp-extra)
- Scalekit Authkit Provider (via rust-mcp-extra)
- ✅ Remote Oauth Provider
- ✅ OAuth Authentication for MCP Clients (metadata discovery, CIMD, PKCE, token refresh, pluggable storage)
- ✅ Issuer-bound credentials (SEP-2352), strict
issvalidation (SEP-2468)
Table of Contents
- Quick Start
- Minimal MCP Server (Stdio)
- Minimal MCP Server (Streamable HTTP)
- Minimal MCP Client (Stdio)
- Usage Examples
- Macros
- Authentication
- HTTP Server Backends (Axum & Actix)
- Cargo features
- Handler Traits
- Message Observer (Telemetry & Monitoring)
- Health Check Endpoint
- Contributing
- Development
- License
Quick Start
Add to your Cargo.toml:
[dependencies]
rust-mcp-sdk = "2.0.0" # Check crates.io for the latest version
Minimal MCP Server (Stdio)
use async_trait::async_trait;
use rust_mcp_sdk::{
error::SdkResult, macros, mcp_icon,
mcp_server::{server_runtime, McpServerOptions, ServerHandler},
schema::*,
McpServer, RequestContext, ServerDetails, StdioTransport, ToMcpServerHandler,
TransportOptions,
};
// Define an MCP tool
#[macros::mcp_tool(name = "say_hello", description = "returns \"Hello from Rust MCP SDK!\" message")]
#[derive(Debug, ::serde::Deserialize, ::serde::Serialize, macros::JsonSchema)]
pub struct SayHelloTool {}
// Define a custom handler
#[derive(Default)]
struct HelloHandler;
#[async_trait]
impl ServerHandler for HelloHandler {
async fn handle_list_tools_request(
&self,
_request: Option<PaginatedRequestParams>,
_context: &RequestContext,
_runtime: std::sync::Arc<dyn McpServer>,
) -> std::result::Result<ListToolsResult, RpcError> {
Ok(ListToolsResult {
tools: vec![SayHelloTool::tool()],
meta: None,
next_cursor: None,
cache_scope: Default::default(),
result_type: "complete".to_string(),
ttl_ms: 0,
})
}
async fn handle_call_tool_request(
&self,
params: CallToolRequestParams,
_context: &RequestContext,
_runtime: std::sync::Arc<dyn McpServer>,
) -> std::result::Result<ServerResult, CallToolError> {
if params.name == "say_hello" {
Ok(ServerResult::CallToolResult(CallToolResult {
content: vec![ContentBlock::TextContent(TextContent::new(
"Hello from Rust MCP SDK!".to_string(),
None,
None,
))],
is_error: None,
meta: None,
result_type: "complete".to_string(),
}))
} else {
Err(CallToolError::unknown_tool(params.name))
}
}
}
#[tokio::main]
async fn main() -> SdkResult<()> {
let server_details = ServerDetails {
server_info: Implementation {
name: "hello-rust-mcp".into(),
version: "0.1.0".into(),
title: Some("Hello World MCP Server".into()),
description: Some("A minimal Rust MCP server".into()),
icons: vec![mcp_icon!(
src = "https://raw.githubusercontent.com/rust-mcp-stack/rust-mcp-sdk/main/assets/rust-mcp-icon.png",
mime_type = "image/png",
sizes = ["128x128"],
theme = "light"
)],
website_url: Some("https://github.com/rust-mcp-stack/rust-mcp-sdk".into()),
},
capabilities: ServerCapabilities {
tools: Some(ServerCapabilitiesTools { list_changed: None }),
..Default::default()
},
instructions: None,
meta: None,
};
let transport = StdioTransport::new(TransportOptions::default())?;
let handler = HelloHandler::default().to_mcp_server_handler();
let server = server_runtime::create_server(McpServerOptions {
server_details,
transport,
handler,
message_observer: None,
});
server.start().await
}
HTTP Server Backends (Axum & Actix)
Creating a Streamable HTTP MCP server in rust-mcp-sdk allows multiple clients to connect simultaneously with no additional setup. The setup is nearly identical to the stdio example , the only difference is which HTTP backend crate you install and which function you call to create the server.
Post only - the 2026-07-28 protocol is stateless. GET and DELETE endpoints return 405 Method Not Allowed.
Axum Backend (rust-mcp-axum)
Add rust-mcp-axum to your dependencies and use create_axum_server() with AxumServerOptions.
use async_trait::async_trait;
use rust_mcp_axum::{create_axum_server, AxumServerOptions};
use rust_mcp_sdk::{
error::SdkResult, macros,
mcp_server::ServerHandler, schema::*,
};
// ... (define SayHelloTool and HelloHandler as shown above)
#[tokio::main]
async fn main() -> SdkResult<()> {
let server_details = ServerDetails { /* ... */ };
let handler = HelloHandler::default().to_mcp_server_handler();
let server = create_axum_server(
server_details,
handler,
AxumServerOptions {
host: "127.0.0.1".to_string(),
..Default::default()
},
);
server.start().await?;
Ok(())
}
Actix-web Backend (rust-mcp-actix)
Add rust-mcp-actix to your dependencies and use create_actix_server() with ActixServerOptions.
use rust_mcp_actix::{create_actix_server, ActixServerOptions};
use rust_mcp_sdk::{
error::SdkResult,
mcp_server::ServerHandler, schema::*,
};
// ... (define SayHelloTool and HelloHandler as shown above)
#[tokio::main]
async fn main() -> SdkResult<()> {
let server_details = ServerDetails { /* ... */ };
let handler = HelloHandler::default().to_mcp_server_handler();
let server = create_actix_server(
server_details,
handler,
ActixServerOptions {
host: "127.0.0.1".to_string(),
..Default::default()
},
);
server.start().await?;
Ok(())
}
BYO-server: Embed MCP in your Existing App
Both backends support a BYO-server (Bring Your Own Server) mode, letting you mount MCP endpoints onto a router or app you already control - no need to hand over the server lifecycle.
| Backend | Function | Docs |
|---|---|---|
| Axum | mcp_routes(state, &mount_opts, http_handler) |
rust-mcp-axum README |
| Actix-web | mcp_scope(state, http_handler, &mount_opts) |
rust-mcp-actix README |
Custom HTTP Framework Integrations
The SDK is completely framework-agnostic. If you are using a different HTTP framework (like Rocket, Salvo, or Warp), you can build a custom integration by adapting your framework's native Request/Response types to the SDK's core HTTP handling logic.
See the Custom HTTP Framework Integration Guide for architectural details.
AxumServerOptions
Axum server is highly customizable through AxumServerOptions:
let server = create_axum_server(
server_details,
handler.to_mcp_server_handler(),
AxumServerOptions {
host: "127.0.0.1".to_string(),
port: 8080,
auth: Some(Arc::new(auth_provider)), // enable authentication
health_endpoint: Some("/health".into()), // health check
sse_support: true, // backward-compat SSE
..Default::default()
},
);
server.start().await?;
Security Considerations
- DNS rebinding protection is enabled by default. If
allowed_hostsis not set, it auto-derives fromhost:port. - When running locally, bind only to localhost (127.0.0.1 / localhost) rather than all network interfaces (0.0.0.0)
- Use TLS/HTTPS for production deployments
Following is implementation of an MCP client that starts the @modelcontextprotocol/server-everything server, discovers the server's capabilities, lists available tools, and calls a tool.
use async_trait::async_trait;
use rust_mcp_sdk::{
error::SdkResult,
mcp_client::{client_runtime, ClientHandler, McpClientOptions},
schema::*,
ClientDetails, McpClient, StdioTransport, ToMcpClientHandler, TransportOptions,
};
pub struct MyClientHandler;
#[async_trait]
impl ClientHandler for MyClientHandler {
// Override handler methods as needed.
// See: crates/rust-mcp-sdk/src/mcp_handlers/mcp_client_handler.rs
}
#[tokio::main]
async fn main() -> SdkResult<()> {
let client_details = ClientDetails {
client_info: Implementation {
name: "simple-rust-mcp-client".into(),
version: "0.1.0".into(),
description: None,
icons: vec![],
title: None,
website_url: None,
},
capabilities: ClientCapabilities::default(),
};
let transport = StdioTransport::create_with_server_launch(
"npx",
vec!["-y".to_string(), "@modelcontextprotocol/server-everything@latest".to_string()],
None,
TransportOptions::default(),
)?;
let handler = MyClientHandler {};
let client = client_runtime::create_client(McpClientOptions::new(
client_details,
transport,
handler.to_mcp_client_handler(),
));
client.clone().start().await?;
// Discover the server
let discover = client.request_discover(Default::default()).await?;
println!("Supported protocol versions: {:?}", discover.supported_versions);
// List tools
let tools = client.request_tool_list(None).await?.tools;
tools.iter().enumerate().for_each(|(i, tool)| {
println!(" {}. {} : {}", i + 1, tool.name, tool.description.unwrap_or_default());
});
// Call a tool (supports MRTR auto-retry)
let result = client.call_tool(CallToolRequestParams {
name: "say_hello".to_string(),
arguments: None,
input_responses: None,
request_state: None,
meta: RequestMetaObject::default(),
}).await?;
client.shut_down().await?;
Ok(())
}
Usage Examples
For more examples (stdio, Streamable HTTP, clients, auth, etc.), see the examples/ directory.
👉 For step-by-step tutorials (server, client, HTTP deployment, OAuth, and more), see the documentation site.
See the hello-world-mcp-server-stdio example running in the MCP Inspector:
Macros
Enable with the macros feature.
mcp_tool
Generate a Tool from a struct, with metadata (icons, hints, etc.).
#[mcp_tool(
name = "write_file",
title = "Write File Tool",
description = "Create or overwrite a file with new content.",
destructive_hint = false, idempotent_hint = false, open_world_hint = false, read_only_hint = false,
meta = r#"{ "key": "value" }"#,
icons = [(src = "https://website.com/write.png", mime_type = "image/png", sizes = ["128x128"], theme = "light")]
)]
#[derive(rust_mcp_macros::JsonSchema)]
pub struct WriteFileTool {
/// The target file's path for writing content.
pub path: String,
/// The string content to be written to the file
pub content: String,
}
tool_box!()
Automatically generates an enum based on the provided list of tools.
tool_box!(GreetingTools, [SayHelloTool, SayGoodbyeTool]);
let tools: Vec<Tool> = GreetingTools::tools();
mcp_elicit()
Generates type-safe elicitation (Form or URL mode) for user input.
#[mcp_elicit(message = "Please enter your info", mode = form)]
#[derive(JsonSchema)]
pub struct UserInfo {
#[json_schema(title = "Name", min_length = 5, max_length = 100)]
pub name: String,
#[json_schema(title = "Email", format = "email")]
pub email: Option<String>,
#[json_schema(title = "Age", minimum = 15, maximum = 125)]
pub age: i32,
#[json_schema(title = "Tags")]
pub tags: Vec<String>,
}
◾ mcp_resource()
A procedural macro attribute that generates utility methods to create fully populated Resource instances from compile-time metadata , usually used for exposing static assets like files, images, or documents. Also generates a RESOURCE_URI associated constant, usable in match patterns, and a resource_mime_type() accessor.
📝 For complete documentation, example usage, and a list of all available attributes, please refer to https://crates.io/crates/rust-mcp-macros.
◾ mcp_resource_template()
A procedural macro attribute that generates utility methods to create fully populated ResourceTemplate instances from compile-time metadata for exposing parameterized server resources. Also generates a RESOURCE_URI_TEMPLATE associated constant, usable in match patterns, and a resource_template_mime_type() accessor.
📝 For complete documentation, example usage, and a list of all available attributes, please refer to https://crates.io/crates/rust-mcp-macros.
◾ mcp_prompt()
A procedural macro attribute that generates utility methods to create fully populated Prompt instances from compile-time metadata, and , when the optional messages attribute is provided , to parse request arguments (from_arguments) and render them into a GetPromptResult (render). Struct fields become typed prompt arguments (String = required, Option<String> = optional, String + default = fallback), the prompts/get handler itself is left to the user.
📝 For complete documentation, example usage, and a list of all available attributes, please refer to https://crates.io/crates/rust-mcp-macros.
◾ mcp_icon!()
A convenient icon builder for implementations and tools, offering full attribute support including theme, size, mime, and more.
example usage:
let icon: crate::schema::Icon = mcp_icon!(
src = "http://website.com/icon.png",
mime_type = "image/png",
sizes = ["64x64"],
theme = "dark"
);
Authentication
MCP servers can verify tokens issued by other systems, integrate with external identity providers, or manage the entire authentication process.
RemoteAuthProvider
RemoteAuthProvider enables authentication with identity providers that support Dynamic Client Registration (DCR), letting MCP clients auto-register and obtain credentials.
OAuthProxy
OAuthProxy enables authentication with OAuth providers that don't support DCR.
Cargo Features
Available Features
server: Activates MCP server capabilitiesclient: Activates MCP client capabilitiesmacros: Procedural macros for Tool, Elicit, Resource structuressse: Server-Sent Events (SSE) transportstreamable-http: Streamable HTTP transportstdio: Standard input/output (stdio) transportauth: OAuth authentication support for MCP serverstls-no-provider: TLS without a crypto provider
Default Features
All features are enabled by default:
[dependencies]
rust-mcp-sdk = "2.0.0"
Using Only the Server Features
[dependencies]
rust-mcp-sdk = { version = "2.0.0", default-features = false, features = ["server", "macros", "stdio"] }
Using Only the Client Features
[dependencies]
rust-mcp-sdk = { version = "2.0.0", default-features = false, features = ["client", "stdio"] }
Handler Traits
Choosing Between ServerHandler and ServerHandlerCore
- ServerHandler: Recommended. Default implementations for all MCP messages. Override only what you need.
- ServerHandlerCore: Full control over request/notification/error dispatch.
Note: Use server_runtime::create_server() or server_runtime_core::create_server() depending on which handler you implement.
Choosing Between ClientHandler and ClientHandlerCore
Same principles apply on the client side: use client_runtime::create_client() with ClientHandler, or client_runtime_core::create_client() with ClientHandlerCore.
Message Observer (Telemetry & Monitoring)
Implement McpObserver to intercept all incoming and outgoing MCP messages for telemetry, logging, debugging, or monitoring.
let server = server_runtime::create_server(McpServerOptions {
server_details,
transport,
handler: handler.to_mcp_server_handler(),
message_observer: Some(SimpleServerObserver::new()),
});
rust-mcp-sdk MCP 질문
rust-mcp-sdk란 무엇인가요?
MCP server 및 client 구축을 위한 고성능 비동기 Rust 툴킷으로, 프로토콜, transport, schema type을 처리합니다.
rust-mcp-sdk는 어떤 transport를 지원하나요?
Stdio, Streamable HTTP 및 하위 호환되는 SSE transport를 지원합니다.
rust-mcp-sdk는 어떤 MCP protocol 버전을 구현하나요?
Version 2.x는 MCP 2026-07-28 stateless specification을 구현하며, version 1.x는 MCP 2025-11-25를 대상으로 합니다.
rust-mcp-sdk에서 OAuth 인증을 지원하나요?
네, PKCE, 토큰 갱신, Keycloak과 같은 원격 provider를 포함하여 MCP server 및 client 모두에 대한 OAuth 인증을 제공합니다.
Axum이나 Actix와 함께 rust-mcp-sdk를 사용할 수 있나요?
네, Axum 및 Actix backend와 프레임워크에 구애받지 않는 통합을 제공하며, 기존 앱에 MCP를 임베딩할 수도 있습니다.