Skip to content

Commit 3e8d939

Browse files
committed
docs: condense SEP-2260 rustdoc sections
Tightens the duplicated per-method association section from eleven lines to five, and trims the marker and SessionManager docs to the same information in fewer words.
1 parent b69ef3f commit 3e8d939

3 files changed

Lines changed: 44 additions & 93 deletions

File tree

crates/rmcp/src/service.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,13 @@ pub(crate) fn in_request_handler_scope() -> bool {
176176
ORIGINATING_REQUEST.try_with(|_| ()).is_ok()
177177
}
178178

179-
/// Marker stored in an outbound request's [`Extensions`]
180-
/// identifying the in-flight peer request it was issued from (SEP-2260).
181-
///
182-
/// Attached automatically whenever a request is sent from within a request
183-
/// handler, for both roles; currently only the streamable HTTP server reads
184-
/// it, to deliver server-initiated requests on the originating client
185-
/// request's SSE stream.
186-
///
187-
/// # In-memory only
188-
///
189-
/// `Extensions` are never serialized, so this marker does not appear on the
190-
/// wire (SEP-2260 defines no wire field). Session managers that serialize
191-
/// messages between processes lose it; such requests fall back to the
192-
/// standalone stream (logged as a warning).
179+
/// Marker in an outbound request's non-serialized [`Extensions`] identifying
180+
/// the in-flight peer request it was issued from (SEP-2260). Attached for both
181+
/// roles whenever a request is sent from within a request handler; the
182+
/// streamable HTTP server reads it to deliver server-initiated requests on the
183+
/// originating request's SSE stream. Never on the wire (SEP-2260 defines no
184+
/// wire field), so session managers that serialize messages between processes
185+
/// lose it and such requests fall back to the standalone stream with a warning.
193186
#[derive(Debug, Clone, PartialEq, Eq)]
194187
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
195188
pub struct OriginatingRequestId(pub RequestId);

crates/rmcp/src/service/server.rs

Lines changed: 32 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -771,15 +771,10 @@ impl Peer<RoleServer> {
771771

772772
/// # SEP-2260: request association
773773
///
774-
/// From protocol version `2026-07-28`, this request must be issued while
775-
/// handling a client request — call it on the [`Peer`] from a
776-
/// [`RequestContext`], from the handler's
777-
/// own task. Calling it outside a handler returns an
778-
/// `invalid_request` error. Note that task-local association does not
779-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
780-
/// outside the handler — use the task manager for long-running work.
781-
/// Requests issued in-handler are delivered on the originating request's
782-
/// SSE stream in the streamable HTTP transport.
774+
/// From protocol version `2026-07-28` this must be issued while handling a
775+
/// client request; outside a handler it returns an `invalid_request` error.
776+
/// The association does not cross `tokio::spawn`, so use the task manager
777+
/// for long-running work.
783778
#[deprecated(
784779
since = "1.8.0",
785780
note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577"
@@ -816,15 +811,10 @@ impl Peer<RoleServer> {
816811
method!(
817812
/// # SEP-2260: request association
818813
///
819-
/// From protocol version `2026-07-28`, this request must be issued while
820-
/// handling a client request — call it on the [`Peer`] from a
821-
/// [`RequestContext`], from the handler's
822-
/// own task. Calling it outside a handler returns an
823-
/// `invalid_request` error. Note that task-local association does not
824-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
825-
/// outside the handler — use the task manager for long-running work.
826-
/// Requests issued in-handler are delivered on the originating request's
827-
/// SSE stream in the streamable HTTP transport.
814+
/// From protocol version `2026-07-28` this must be issued while handling a
815+
/// client request; outside a handler it returns an `invalid_request` error.
816+
/// The association does not cross `tokio::spawn`, so use the task manager
817+
/// for long-running work.
828818
#[deprecated(
829819
since = "1.8.0",
830820
note = "Roots is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577"
@@ -835,30 +825,20 @@ impl Peer<RoleServer> {
835825
method!(
836826
/// # SEP-2260: request association
837827
///
838-
/// From protocol version `2026-07-28`, this request must be issued while
839-
/// handling a client request — call it on the [`Peer`] from a
840-
/// [`RequestContext`], from the handler's
841-
/// own task. Calling it outside a handler returns an
842-
/// `invalid_request` error. Note that task-local association does not
843-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
844-
/// outside the handler — use the task manager for long-running work.
845-
/// Requests issued in-handler are delivered on the originating request's
846-
/// SSE stream in the streamable HTTP transport.
828+
/// From protocol version `2026-07-28` this must be issued while handling a
829+
/// client request; outside a handler it returns an `invalid_request` error.
830+
/// The association does not cross `tokio::spawn`, so use the task manager
831+
/// for long-running work.
847832
peer_req create_elicitation ElicitRequest(ElicitRequestParams) => ElicitResult
848833
);
849834
#[cfg(feature = "elicitation")]
850835
method!(
851836
/// # SEP-2260: request association
852837
///
853-
/// From protocol version `2026-07-28`, this request must be issued while
854-
/// handling a client request — call it on the [`Peer`] from a
855-
/// [`RequestContext`], from the handler's
856-
/// own task. Calling it outside a handler returns an
857-
/// `invalid_request` error. Note that task-local association does not
858-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
859-
/// outside the handler — use the task manager for long-running work.
860-
/// Requests issued in-handler are delivered on the originating request's
861-
/// SSE stream in the streamable HTTP transport.
838+
/// From protocol version `2026-07-28` this must be issued while handling a
839+
/// client request; outside a handler it returns an `invalid_request` error.
840+
/// The association does not cross `tokio::spawn`, so use the task manager
841+
/// for long-running work.
862842
peer_req_with_timeout create_elicitation_with_timeout ElicitRequest(ElicitRequestParams) => ElicitResult
863843
);
864844

@@ -1090,15 +1070,10 @@ impl Peer<RoleServer> {
10901070
///
10911071
/// # SEP-2260: request association
10921072
///
1093-
/// From protocol version `2026-07-28`, this request must be issued while
1094-
/// handling a client request — call it on the [`Peer`] from a
1095-
/// [`RequestContext`], from the handler's
1096-
/// own task. Calling it outside a handler returns an
1097-
/// `invalid_request` error. Note that task-local association does not
1098-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
1099-
/// outside the handler — use the task manager for long-running work.
1100-
/// Requests issued in-handler are delivered on the originating request's
1101-
/// SSE stream in the streamable HTTP transport.
1073+
/// From protocol version `2026-07-28` this must be issued while handling a
1074+
/// client request; outside a handler it returns an `invalid_request` error.
1075+
/// The association does not cross `tokio::spawn`, so use the task manager
1076+
/// for long-running work.
11021077
#[cfg(all(feature = "schemars", feature = "elicitation"))]
11031078
pub async fn elicit<T>(&self, message: impl Into<String>) -> Result<Option<T>, ElicitationError>
11041079
where
@@ -1163,15 +1138,10 @@ impl Peer<RoleServer> {
11631138
///
11641139
/// # SEP-2260: request association
11651140
///
1166-
/// From protocol version `2026-07-28`, this request must be issued while
1167-
/// handling a client request — call it on the [`Peer`] from a
1168-
/// [`RequestContext`], from the handler's
1169-
/// own task. Calling it outside a handler returns an
1170-
/// `invalid_request` error. Note that task-local association does not
1171-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
1172-
/// outside the handler — use the task manager for long-running work.
1173-
/// Requests issued in-handler are delivered on the originating request's
1174-
/// SSE stream in the streamable HTTP transport.
1141+
/// From protocol version `2026-07-28` this must be issued while handling a
1142+
/// client request; outside a handler it returns an `invalid_request` error.
1143+
/// The association does not cross `tokio::spawn`, so use the task manager
1144+
/// for long-running work.
11751145
#[cfg(all(feature = "schemars", feature = "elicitation"))]
11761146
pub async fn elicit_with_timeout<T>(
11771147
&self,
@@ -1270,15 +1240,10 @@ impl Peer<RoleServer> {
12701240
///
12711241
/// # SEP-2260: request association
12721242
///
1273-
/// From protocol version `2026-07-28`, this request must be issued while
1274-
/// handling a client request — call it on the [`Peer`] from a
1275-
/// [`RequestContext`], from the handler's
1276-
/// own task. Calling it outside a handler returns an
1277-
/// `invalid_request` error. Note that task-local association does not
1278-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
1279-
/// outside the handler — use the task manager for long-running work.
1280-
/// Requests issued in-handler are delivered on the originating request's
1281-
/// SSE stream in the streamable HTTP transport.
1243+
/// From protocol version `2026-07-28` this must be issued while handling a
1244+
/// client request; outside a handler it returns an `invalid_request` error.
1245+
/// The association does not cross `tokio::spawn`, so use the task manager
1246+
/// for long-running work.
12821247
#[cfg(feature = "elicitation")]
12831248
pub async fn elicit_url(
12841249
&self,
@@ -1333,15 +1298,10 @@ impl Peer<RoleServer> {
13331298
///
13341299
/// # SEP-2260: request association
13351300
///
1336-
/// From protocol version `2026-07-28`, this request must be issued while
1337-
/// handling a client request — call it on the [`Peer`] from a
1338-
/// [`RequestContext`], from the handler's
1339-
/// own task. Calling it outside a handler returns an
1340-
/// `invalid_request` error. Note that task-local association does not
1341-
/// cross `tokio::spawn`: a task spawned inside a handler is treated as
1342-
/// outside the handler — use the task manager for long-running work.
1343-
/// Requests issued in-handler are delivered on the originating request's
1344-
/// SSE stream in the streamable HTTP transport.
1301+
/// From protocol version `2026-07-28` this must be issued while handling a
1302+
/// client request; outside a handler it returns an `invalid_request` error.
1303+
/// The association does not cross `tokio::spawn`, so use the task manager
1304+
/// for long-running work.
13451305
#[cfg(feature = "elicitation")]
13461306
pub async fn elicit_url_with_timeout(
13471307
&self,

crates/rmcp/src/transport/streamable_http_server/session.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ pub enum RestoreOutcome<T> {
7777
///
7878
/// Server-initiated requests issued while handling a client request carry an
7979
/// [`OriginatingRequestId`](crate::service::OriginatingRequestId) marker in
80-
/// their non-serialized `Extensions`. Implementations that keep messages
81-
/// in-memory (like the bundled local session manager) deliver such requests on
82-
/// the originating request's SSE stream, per SEP-2260. Implementations that
83-
/// serialize messages between processes lose the marker; those requests then
84-
/// fall back to the standalone stream, which violates SEP-2260 for protocol
85-
/// version 2026-07-28+ clients — distributed session managers need their own
86-
/// association mechanism.
80+
/// their non-serialized `Extensions`; the bundled local session manager uses
81+
/// it to deliver such requests on the originating request's SSE stream.
82+
/// Implementations that serialize messages between processes lose the marker
83+
/// and fall back to the standalone stream, violating SEP-2260 for 2026-07-28+
84+
/// clients; they need their own association mechanism.
8785
pub trait SessionManager: Send + Sync + 'static {
8886
type Error: std::error::Error + Send + 'static;
8987
type Transport: crate::transport::Transport<RoleServer>;

0 commit comments

Comments
 (0)