Skip to content

Commit 5554a41

Browse files
authored
docs: update for 2026-07-28 version (#1032)
1 parent 397d416 commit 5554a41

4 files changed

Lines changed: 211 additions & 1048 deletions

File tree

README.md

Lines changed: 208 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<div align = "right">
2-
<a href="docs/readme/README.zh-cn.md">简体中文</a>
3-
</div>
4-
51
# RMCP
62
[![Crates.io Version](https://img.shields.io/crates/v/rmcp)](https://crates.io/crates/rmcp)
73
[![docs.rs](https://img.shields.io/docsrs/rmcp)](https://docs.rs/rmcp/latest/rmcp)
@@ -17,7 +13,13 @@ This repository contains the following crates:
1713
- [rmcp](crates/rmcp): The core crate providing the RMCP protocol implementation - see [rmcp](crates/rmcp/README.md)
1814
- [rmcp-macros](crates/rmcp-macros): A procedural macro crate for generating RMCP tool implementations - see [rmcp-macros](crates/rmcp-macros/README.md)
1915

20-
For the full MCP specification, see [modelcontextprotocol.io](https://modelcontextprotocol.io/specification/2025-11-25).
16+
This SDK tracks the MCP **`2026-07-28`** draft (the current development spec)
17+
while remaining fully compatible with the stable **`2025-11-25`** release and
18+
earlier versions. New `2026-07-28` features — server discovery & negotiation,
19+
transport-neutral subscriptions, long-running tasks, response caching,
20+
multi-round-trip requests, and standard HTTP routing headers — are documented
21+
below alongside the stable feature set. For the full MCP specification, see
22+
[modelcontextprotocol.io](https://modelcontextprotocol.io/specification/draft).
2123

2224
## Table of Contents
2325

@@ -31,8 +33,11 @@ For the full MCP specification, see [modelcontextprotocol.io](https://modelconte
3133
- [Completions](#completions)
3234
- [Notifications](#notifications)
3335
- [Subscriptions](#subscriptions)
36+
- [Multi-Round-Trip Requests](#multi-round-trip-requests)
3437
- [Tasks](#tasks-long-running-tool-invocations)
3538
- [Caching](#caching)
39+
- [Standard HTTP Headers](#standard-http-headers)
40+
- [Stateless Streamable HTTP](#stateless-streamable-http)
3641
- [Examples](#examples)
3742
- [OAuth Support](#oauth-support)
3843
- [Related Resources](#related-resources)
@@ -43,10 +48,16 @@ For the full MCP specification, see [modelcontextprotocol.io](https://modelconte
4348

4449
### Import the crate
4550

46-
```toml
47-
rmcp = { version = "0.16.0", features = ["server"] }
48-
## or dev channel
49-
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main" }
51+
Add the latest published version with cargo:
52+
53+
```sh
54+
cargo add rmcp --features server
55+
```
56+
57+
Or use the dev channel:
58+
59+
```sh
60+
cargo add rmcp --features server --git https://github.com/modelcontextprotocol/rust-sdk --branch main
5061
```
5162
### Third Dependencies
5263

@@ -174,7 +185,7 @@ let quit_reason = server.cancel().await?;
174185

175186
Tools let servers expose callable functions to clients. Each tool has a name, description, and a JSON Schema for its parameters. Clients discover tools via `list_tools` and invoke them via `call_tool`.
176187

177-
**MCP Spec:** [Tools](https://modelcontextprotocol.io/specification/2025-11-25/server/tools)
188+
**MCP Spec:** [Tools](https://modelcontextprotocol.io/specification/draft/server/tools)
178189

179190
### Server-side
180191

@@ -210,6 +221,11 @@ async fn main() -> anyhow::Result<()> {
210221

211222
The generated tool `inputSchema` and `outputSchema` are derived from the fields of `T`. The type name and documentation on `T` are ignored; only field names, field types, and field documentation are used.
212223

224+
> **`2026-07-28` (SEP-2106):** `outputSchema` may now be any JSON Schema type
225+
> (not just `object`), and a tool result's `structuredContent` may be any JSON
226+
> value (string, array, number, …) rather than only an object. Existing
227+
> object-typed tools are unaffected.
228+
213229
When you need custom server metadata or multiple capabilities (tools + prompts), use explicit `#[tool_handler]`:
214230

215231
```rust,ignore
@@ -258,7 +274,7 @@ let result = client.call_tool(CallToolRequestParams::new("add")).await?;
258274

259275
Resources let servers expose data (files, database records, API responses) that clients can read. Each resource is identified by a URI and returns content as text or binary (base64-encoded) data. Resource templates allow servers to declare URI patterns with dynamic parameters.
260276

261-
**MCP Spec:** [Resources](https://modelcontextprotocol.io/specification/2025-11-25/server/resources)
277+
**MCP Spec:** [Resources](https://modelcontextprotocol.io/specification/draft/server/resources)
262278

263279
### Server-side
264280

@@ -393,7 +409,7 @@ impl ClientHandler for MyClient {
393409

394410
Prompts are reusable message templates that servers expose to clients. They accept typed arguments and return conversation messages. The `#[prompt]` macro handles argument validation and routing automatically.
395411

396-
**MCP Spec:** [Prompts](https://modelcontextprotocol.io/specification/2025-11-25/server/prompts)
412+
**MCP Spec:** [Prompts](https://modelcontextprotocol.io/specification/draft/server/prompts)
397413

398414
### Server-side
399415

@@ -507,7 +523,7 @@ context.peer.notify_prompt_list_changed().await?;
507523
508524
Sampling flips the usual direction: the server asks the client to run an LLM completion. The server sends a `create_message` request, the client processes it through its LLM, and returns the result.
509525

510-
**MCP Spec:** [Sampling](https://modelcontextprotocol.io/specification/2025-11-25/client/sampling)
526+
**MCP Spec:** [Sampling](https://modelcontextprotocol.io/specification/draft/client/sampling)
511527

512528
### Server-side (requesting sampling)
513529

@@ -579,7 +595,7 @@ impl ClientHandler for MyClient {
579595
580596
Roots tell servers which directories or projects the client is working in. A root is a URI (typically `file://`) pointing to a workspace or repository. Servers can query roots to know where to look for files and how to scope their work.
581597

582-
**MCP Spec:** [Roots](https://modelcontextprotocol.io/specification/2025-11-25/client/roots)
598+
**MCP Spec:** [Roots](https://modelcontextprotocol.io/specification/draft/client/roots)
583599

584600
### Server-side
585601

@@ -644,7 +660,7 @@ client.notify_roots_list_changed().await?;
644660
645661
Servers can send structured log messages to clients. The client sets a minimum severity level, and the server sends messages through the peer notification interface.
646662

647-
**MCP Spec:** [Logging](https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging)
663+
**MCP Spec:** [Logging](https://modelcontextprotocol.io/specification/draft/server/utilities/logging)
648664

649665
### Server-side
650666

@@ -717,7 +733,7 @@ client.set_level(SetLevelRequestParams::new(LoggingLevel::Warning)).await?;
717733

718734
Completions give auto-completion suggestions for prompt or resource template arguments. As a user fills in arguments, the client can ask the server for suggestions based on what's already been entered.
719735

720-
**MCP Spec:** [Completions](https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/completion)
736+
**MCP Spec:** [Completions](https://modelcontextprotocol.io/specification/draft/server/utilities/completion)
721737

722738
### Server-side
723739

@@ -799,7 +815,7 @@ let result = client.complete(CompleteRequestParams::new(
799815

800816
Notifications are fire-and-forget messages -- no response is expected. They cover progress updates, cancellation, and lifecycle events. Both sides can send and receive them.
801817

802-
**MCP Spec:** [Notifications](https://modelcontextprotocol.io/specification/2025-11-25/basic/notifications)
818+
**MCP Spec:** [Notifications](https://modelcontextprotocol.io/specification/draft/basic#notifications)
803819

804820
### Progress notifications
805821

@@ -970,6 +986,81 @@ and [client](examples/clients/src/subscriptions_streamhttp.rs) examples.
970986

971987
---
972988

989+
## Multi-Round-Trip Requests
990+
991+
Protocol `2026-07-28` adds Multi-Round-Trip Requests (MRTR, SEP-2322): a server
992+
can answer a `tools/call`, `prompts/get`, or `resources/read` with an
993+
`InputRequiredResult` instead of a final result, asking the client to fulfill
994+
one or more embedded server requests (elicitation, sampling, or roots) and then
995+
retry. The exchange is stateless — the server carries its progress in an opaque
996+
`requestState` that the client echoes back verbatim.
997+
998+
**MCP Spec:** [Multiple Round-Trip Requests](https://modelcontextprotocol.io/specification/draft/server/tools#multiple-round-trip-requests)
999+
1000+
### Server-side
1001+
1002+
Return an `InputRequiredResult` via the outcome enum for the method
1003+
(`CallToolResponse`, `GetPromptResponse`, or `ReadResourceResponse`). The SDK
1004+
only forwards it to peers that negotiated `2026-07-28` or newer — older peers
1005+
get a protocol error instead.
1006+
1007+
```rust, ignore
1008+
async fn call_tool(&self, request: CallToolRequestParams, _ctx: RequestContext<RoleServer>)
1009+
-> Result<CallToolResponse, ErrorData>
1010+
{
1011+
match request.request_state {
1012+
// First round: ask the client for input, seal progress into requestState.
1013+
None => {
1014+
let mut input_requests = InputRequests::new();
1015+
input_requests.insert("city".into(), InputRequest::Elicitation(elicit_city()));
1016+
let sealed = self.codec.seal_json(&json!({ "awaiting": "city" }))?;
1017+
Ok(InputRequiredResult::new(Some(input_requests), Some(sealed)).into())
1018+
}
1019+
// Retry round: verify the echoed state, read the responses, finish.
1020+
Some(sealed) => {
1021+
let _state = self.codec.open_json(&sealed)
1022+
.map_err(|_| ErrorData::invalid_params("tampered request state", None))?;
1023+
let city = request.input_responses.as_ref()
1024+
.and_then(|r| r.get("city"));
1025+
Ok(CallToolResult::success(vec![ContentBlock::text("It is sunny.")]).into())
1026+
}
1027+
}
1028+
}
1029+
```
1030+
1031+
> **`requestState` is untrusted.** The client echoes it back verbatim, so a
1032+
> stateless server that stores meaningful data in it MUST verify integrity
1033+
> first. Enable the `request-state` feature and use `RequestStateCodec` to seal
1034+
> and open it (HMAC-tagged), or keep state server-side and use `requestState`
1035+
> only as an opaque handle.
1036+
1037+
### Client-side
1038+
1039+
The high-level `call_tool`, `get_prompt`, and `read_resource` helpers drive MRTR
1040+
automatically: they fulfill each embedded request through the local
1041+
`ClientHandler` and retry, up to `DEFAULT_MRTR_MAX_ROUNDS` (10).
1042+
1043+
```rust, ignore
1044+
// Auto mode: the SDK fulfills embedded requests and retries for you.
1045+
let result = client.call_tool(CallToolRequestParams::new("weather")).await?;
1046+
1047+
// Choose a custom round cap.
1048+
let result = client
1049+
.call_tool_with_mrtr_max_rounds(CallToolRequestParams::new("weather"), 3)
1050+
.await?;
1051+
1052+
// Manual mode: get the intermediate InputRequiredResult and drive rounds yourself.
1053+
match client.call_tool_once(CallToolRequestParams::new("weather")).await? {
1054+
CallToolResponse::InputRequired(input_required) => { /* fulfill + retry */ }
1055+
CallToolResponse::Complete(result) => { /* done */ }
1056+
_ => {}
1057+
}
1058+
```
1059+
1060+
**Example:** [`examples/servers/src/mrtr.rs`](examples/servers/src/mrtr.rs) (end-to-end server + client)
1061+
1062+
---
1063+
9731064
## Tasks (long-running tool invocations)
9741065

9751066
`rmcp` implements the [MCP Tasks extension](https://modelcontextprotocol.io/extensions/tasks/overview)
@@ -1050,6 +1141,104 @@ peer.clear_response_cache().await;
10501141
> last cached response (even if expired) as `Ok(..)` instead of an error. Set
10511142
> `with_serve_stale_on_error(false)` if callers must observe fetch failures.
10521143
1144+
## Standard HTTP Headers
1145+
1146+
Protocol `2026-07-28` standardizes a set of Streamable HTTP request headers
1147+
(SEP-2243) so proxies and gateways can route MCP traffic without parsing the
1148+
JSON body: `Mcp-Method`, `Mcp-Name`, and `Mcp-Param-*`. `rmcp` emits and
1149+
validates these automatically once a connection negotiates `2026-07-28` or
1150+
newer — no call-site changes are required, and older negotiated versions are
1151+
untouched.
1152+
1153+
**MCP Spec:** [Header standardization](https://modelcontextprotocol.io/specification/draft/basic/transports#header)
1154+
1155+
- `Mcp-Method` — the JSON-RPC method (e.g. `tools/call`).
1156+
- `Mcp-Name` — the target name, sourced from `params.name` (`tools/call`,
1157+
`prompts/get`), `params.uri` (`resources/*`), or `params.taskId` (`tasks/*`).
1158+
- `Mcp-Param-*` — selected `tools/call` arguments, promoted from the tool's
1159+
input schema.
1160+
1161+
To promote a tool argument into a routing header, annotate the top-level schema
1162+
property with `x-mcp-header`:
1163+
1164+
```rust, ignore
1165+
// A `region` argument surfaces as the `Mcp-Param-Region` request header.
1166+
let schema = serde_json::json!({
1167+
"type": "object",
1168+
"properties": {
1169+
"region": { "type": "string", "x-mcp-header": "Region" }
1170+
}
1171+
});
1172+
```
1173+
1174+
Annotations must be non-empty RFC 9110 tokens, case-insensitively unique, and
1175+
applied only to top-level primitive (`string`/`integer`/`boolean`) properties.
1176+
Values that cannot travel as a bare header (leading/trailing whitespace,
1177+
control/non-ASCII characters) are transparently Base64-wrapped as
1178+
`=?base64?<b64>?=`.
1179+
1180+
---
1181+
1182+
## Stateless Streamable HTTP
1183+
1184+
Per SEP-2567, `rmcp` serves the `2026-07-28` draft statelessly **automatically**:
1185+
no `Mcp-Session-Id`, no standalone GET/DELETE stream, and no `Last-Event-ID`
1186+
resumption. The `legacy_session_mode` flag below only controls behavior for
1187+
*legacy* protocol versions (`< 2026-07-28`).
1188+
1189+
**MCP Spec:** [Transports](https://modelcontextprotocol.io/specification/draft/basic/transports)
1190+
1191+
### Server-side
1192+
1193+
A default server already serves `2026-07-28` clients statelessly. To also serve
1194+
*legacy* clients without sessions, disable `legacy_session_mode` (formerly
1195+
`stateful_mode`; builder `with_stateful_mode`). Optionally set
1196+
`with_json_response(true)` so simple request/response tools reply with a single
1197+
`application/json` body instead of an SSE stream (the server still falls back to
1198+
`text/event-stream` if a handler emits a notification or server request first):
1199+
1200+
```rust, ignore
1201+
use rmcp::transport::streamable_http_server::{
1202+
StreamableHttpService, StreamableHttpServerConfig,
1203+
session::local::LocalSessionManager,
1204+
};
1205+
1206+
let config = StreamableHttpServerConfig::default()
1207+
.with_legacy_session_mode(false) // stateless for legacy versions too
1208+
.with_json_response(true); // plain JSON replies for simple tools
1209+
1210+
let service = StreamableHttpService::new(
1211+
|| Ok(Counter::new()), // a fresh handler per request
1212+
LocalSessionManager::default().into(),
1213+
config,
1214+
);
1215+
1216+
// `StreamableHttpService` is a Tower service — mount it on any router.
1217+
let router = axum::Router::new().nest_service("/mcp", service);
1218+
```
1219+
1220+
> Because there is no per-session state, the `service_factory` runs per request.
1221+
> Keep shared state (DB pools, caches) in a `Clone` handle captured by the
1222+
> closure; don't rely on in-memory state surviving between requests.
1223+
1224+
### Client-side
1225+
1226+
The Streamable HTTP client transport allows stateless operation by default
1227+
(`allow_stateless: true`), so no configuration is needed to talk to a stateless
1228+
server — it simply omits the session header when the server doesn't issue one:
1229+
1230+
```rust, ignore
1231+
use rmcp::transport::StreamableHttpClientTransport;
1232+
1233+
// Defaults are stateless-friendly.
1234+
let transport = StreamableHttpClientTransport::from_uri("http://localhost:8000/mcp");
1235+
let client = ClientInfo::default().serve(transport).await?;
1236+
```
1237+
1238+
**Example:** [`examples/servers/src/counter_streamhttp.rs`](examples/servers/src/counter_streamhttp.rs) (server), [`examples/clients/src/streamable_http.rs`](examples/clients/src/streamable_http.rs) (client)
1239+
1240+
---
1241+
10531242
## Examples
10541243

10551244
See [examples](examples/README.md).
@@ -1060,8 +1249,8 @@ See [Oauth_support](docs/OAUTH_SUPPORT.md) for details.
10601249

10611250
## Related Resources
10621251

1063-
- [MCP Specification](https://modelcontextprotocol.io/specification/2025-11-25)
1064-
- [Schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2025-11-25/schema.ts)
1252+
- [MCP Specification](https://modelcontextprotocol.io/specification/draft)
1253+
- [Schema](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/draft/schema.ts)
10651254

10661255
## Related Projects
10671256

crates/rmcp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
</div>
1313

14-
The official Rust SDK for the [Model Context Protocol](https://modelcontextprotocol.io/specification/2025-11-25). Build MCP servers that expose tools, resources, and prompts to AI assistants — or build clients that connect to them.
14+
The official Rust SDK for the [Model Context Protocol](https://modelcontextprotocol.io/specification/draft). Build MCP servers that expose tools, resources, and prompts to AI assistants — or build clients that connect to them.
1515

1616
For **getting started**, **usage guides**, and **full MCP feature documentation** (resources, prompts, sampling, roots, logging, completions, subscriptions, etc.), see the [main README](../../README.md).
1717

docs/OAUTH_SUPPORT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Model Context Protocol OAuth Authorization
22

3-
This document describes the OAuth 2.1 authorization implementation for Model Context Protocol (MCP), following the [MCP 2025-11-25 Authorization Specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization/).
3+
This document describes the OAuth 2.1 authorization implementation for Model Context Protocol (MCP), following the [MCP Authorization Specification](https://modelcontextprotocol.io/specification/draft/basic/authorization/).
44

55
## Features
66

@@ -231,7 +231,7 @@ If you encounter authorization issues, check the following:
231231

232232
## References
233233

234-
- [MCP Authorization Specification (2025-11-25)](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization/)
234+
- [MCP Authorization Specification](https://modelcontextprotocol.io/specification/draft/basic/authorization/)
235235
- [OAuth 2.1 Specification Draft](https://oauth.net/2.1/)
236236
- [RFC 8414: OAuth 2.0 Authorization Server Metadata](https://datatracker.ietf.org/doc/html/rfc8414)
237237
- [RFC 7591: OAuth 2.0 Dynamic Client Registration Protocol](https://datatracker.ietf.org/doc/html/rfc7591)

0 commit comments

Comments
 (0)