Skip to content

Commit cdce2a0

Browse files
committed
docs: single-source SEP-2260 caller requirements on OriginatingRequestId
1 parent 5a5de82 commit cdce2a0

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

crates/rmcp/src/service.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ pub(crate) fn in_request_handler_scope() -> bool {
183183
/// originating request's SSE stream. Never on the wire (SEP-2260 defines no
184184
/// wire field), so session managers that serialize messages between processes
185185
/// lose it and such requests fall back to the standalone stream with a warning.
186+
///
187+
/// # Caller requirements
188+
///
189+
/// From protocol version `2026-07-28`, server-to-client sampling, roots, and
190+
/// elicitation requests must be issued while handling a client request;
191+
/// outside a handler they return an `invalid_request` error. The association
192+
/// is task-local and does not cross `tokio::spawn`, so use the task manager
193+
/// for long-running work.
186194
#[derive(Debug, Clone, PartialEq, Eq)]
187195
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
188196
pub struct OriginatingRequestId(pub RequestId);

crates/rmcp/src/service/server.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,7 @@ impl Peer<RoleServer> {
772772
/// # SEP-2260: request association
773773
///
774774
/// 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.
775+
/// client request; see [`OriginatingRequestId`].
778776
#[deprecated(
779777
since = "1.8.0",
780778
note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577"
@@ -812,9 +810,7 @@ impl Peer<RoleServer> {
812810
/// # SEP-2260: request association
813811
///
814812
/// 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.
813+
/// client request; see [`OriginatingRequestId`].
818814
#[deprecated(
819815
since = "1.8.0",
820816
note = "Roots is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577"
@@ -826,19 +822,15 @@ impl Peer<RoleServer> {
826822
/// # SEP-2260: request association
827823
///
828824
/// 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.
825+
/// client request; see [`OriginatingRequestId`].
832826
peer_req create_elicitation ElicitRequest(ElicitRequestParams) => ElicitResult
833827
);
834828
#[cfg(feature = "elicitation")]
835829
method!(
836830
/// # SEP-2260: request association
837831
///
838832
/// 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.
833+
/// client request; see [`OriginatingRequestId`].
842834
peer_req_with_timeout create_elicitation_with_timeout ElicitRequest(ElicitRequestParams) => ElicitResult
843835
);
844836

@@ -1071,9 +1063,7 @@ impl Peer<RoleServer> {
10711063
/// # SEP-2260: request association
10721064
///
10731065
/// 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.
1066+
/// client request; see [`OriginatingRequestId`].
10771067
#[cfg(all(feature = "schemars", feature = "elicitation"))]
10781068
pub async fn elicit<T>(&self, message: impl Into<String>) -> Result<Option<T>, ElicitationError>
10791069
where
@@ -1139,9 +1129,7 @@ impl Peer<RoleServer> {
11391129
/// # SEP-2260: request association
11401130
///
11411131
/// 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.
1132+
/// client request; see [`OriginatingRequestId`].
11451133
#[cfg(all(feature = "schemars", feature = "elicitation"))]
11461134
pub async fn elicit_with_timeout<T>(
11471135
&self,
@@ -1241,9 +1229,7 @@ impl Peer<RoleServer> {
12411229
/// # SEP-2260: request association
12421230
///
12431231
/// 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.
1232+
/// client request; see [`OriginatingRequestId`].
12471233
#[cfg(feature = "elicitation")]
12481234
pub async fn elicit_url(
12491235
&self,
@@ -1299,9 +1285,7 @@ impl Peer<RoleServer> {
12991285
/// # SEP-2260: request association
13001286
///
13011287
/// 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.
1288+
/// client request; see [`OriginatingRequestId`].
13051289
#[cfg(feature = "elicitation")]
13061290
pub async fn elicit_url_with_timeout(
13071291
&self,

0 commit comments

Comments
 (0)