From 1a1d3f52573323bc1fb8c6725bf9b951f2861cdd Mon Sep 17 00:00:00 2001 From: Dale Seo <5466341+DaleSeo@users.noreply.github.com> Date: Tue, 23 Jun 2026 17:50:24 -0400 Subject: [PATCH] feat: deprecate roots/sampling/logging types --- crates/rmcp/src/handler/client.rs | 2 + crates/rmcp/src/handler/server.rs | 2 + crates/rmcp/src/model.rs | 67 +++++++++++++++++++ crates/rmcp/src/model/content.rs | 10 +++ crates/rmcp/src/service/client.rs | 2 + crates/rmcp/src/service/server.rs | 2 + crates/rmcp/tests/common/handlers.rs | 2 + crates/rmcp/tests/test_message_protocol.rs | 1 + .../client_json_rpc_message_schema.json | 8 +++ ...lient_json_rpc_message_schema_current.json | 8 +++ .../server_json_rpc_message_schema.json | 16 ++++- ...erver_json_rpc_message_schema_current.json | 16 ++++- 12 files changed, 130 insertions(+), 6 deletions(-) diff --git a/crates/rmcp/src/handler/client.rs b/crates/rmcp/src/handler/client.rs index 886268073..90f7ed4a9 100644 --- a/crates/rmcp/src/handler/client.rs +++ b/crates/rmcp/src/handler/client.rs @@ -1,3 +1,5 @@ +// Sampling/Roots/Logging are SEP-2577-deprecated; internal references are expected. +#![expect(deprecated)] pub mod progress; use std::sync::Arc; diff --git a/crates/rmcp/src/handler/server.rs b/crates/rmcp/src/handler/server.rs index 54964559d..0fb4bf891 100644 --- a/crates/rmcp/src/handler/server.rs +++ b/crates/rmcp/src/handler/server.rs @@ -1,3 +1,5 @@ +// Sampling/Roots/Logging are SEP-2577-deprecated; internal references are expected. +#![expect(deprecated)] use std::sync::Arc; use crate::{ diff --git a/crates/rmcp/src/model.rs b/crates/rmcp/src/model.rs index cf2fe5900..fc45f1efa 100644 --- a/crates/rmcp/src/model.rs +++ b/crates/rmcp/src/model.rs @@ -1,3 +1,6 @@ +// Internal references to the SEP-2577-deprecated Roots/Sampling/Logging types +// defined in this module are expected; the deprecation is advisory for downstream users. +#![expect(deprecated)] use std::{ borrow::Cow, ops::{Deref, DerefMut}, @@ -1488,6 +1491,10 @@ pub type ToolListChangedNotification = NotificationNoParam; const_string!(LoggingMessageNotificationMethod = "notifications/message"); @@ -1542,6 +1557,10 @@ const_string!(LoggingMessageNotificationMethod = "notifications/message"); #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Logging is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct LoggingMessageNotificationParam { /// The severity level of this log message pub level: LoggingLevel, @@ -1573,6 +1592,10 @@ impl LoggingMessageNotificationParam { } /// Notification containing a log message +#[deprecated( + since = "2.0.0", + note = "Logging is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub type LoggingMessageNotification = Notification; @@ -1581,6 +1604,10 @@ pub type LoggingMessageNotification = // ============================================================================= const_string!(CreateMessageRequestMethod = "sampling/createMessage"); +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub type CreateMessageRequest = Request; /// Represents the role of a participant in a conversation or message exchange. @@ -1618,6 +1645,10 @@ pub enum ToolChoiceMode { #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct ToolChoice { #[serde(skip_serializing_if = "Option::is_none")] pub mode: Option, @@ -1750,6 +1781,10 @@ impl From> for SamplingContent { #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct SamplingMessage { /// The role of the message sender (User or Assistant) pub role: Role, @@ -1764,6 +1799,10 @@ pub struct SamplingMessage { #[serde(tag = "type", rename_all = "snake_case")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub enum SamplingMessageContentBlock { Text(TextContent), Image(ImageContent), @@ -1912,6 +1951,10 @@ pub enum ContextInclusion { #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct CreateMessageRequestParams { /// Protocol-level metadata for this request (SEP-1319) #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")] @@ -2125,6 +2168,10 @@ pub type CreateMessageRequestParam = CreateMessageRequestParams; #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct ModelPreferences { /// Specific model names or families to prefer (e.g., "claude", "gpt") #[serde(skip_serializing_if = "Option::is_none")] @@ -2189,6 +2236,10 @@ impl Default for ModelPreferences { #[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct ModelHint { /// The suggested model name or family identifier #[serde(skip_serializing_if = "Option::is_none")] @@ -2522,6 +2573,10 @@ impl ArgumentInfo { #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Roots is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct Root { pub uri: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -2554,12 +2609,20 @@ impl Root { } const_string!(ListRootsRequestMethod = "roots/list"); +#[deprecated( + since = "2.0.0", + note = "Roots is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub type ListRootsRequest = RequestNoParam; #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)] #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Roots is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct ListRootsResult { pub roots: Vec, #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")] @@ -3167,6 +3230,10 @@ pub type CallToolRequest = Request #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct CreateMessageResult { /// The identifier of the model that generated the response pub model: String, diff --git a/crates/rmcp/src/model/content.rs b/crates/rmcp/src/model/content.rs index c32f81b3d..680136f8e 100644 --- a/crates/rmcp/src/model/content.rs +++ b/crates/rmcp/src/model/content.rs @@ -7,6 +7,8 @@ //! [`SamplingMessageContentBlock`] extends the union with `tool_use` and `tool_result` //! variants for sampling messages (SEP-1577). +// ToolUseContent/ToolResultContent are SEP-2577-deprecated; internal references are expected. +#![expect(deprecated)] use serde::{Deserialize, Serialize}; use serde_json::json; @@ -178,6 +180,10 @@ impl EmbeddedResource { #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct ToolUseContent { pub id: String, pub name: String, @@ -191,6 +197,10 @@ pub struct ToolUseContent { #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[non_exhaustive] +#[deprecated( + since = "2.0.0", + note = "Sampling is deprecated by SEP-2577 and will be removed in a future release. See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577" +)] pub struct ToolResultContent { #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")] pub meta: Option, diff --git a/crates/rmcp/src/service/client.rs b/crates/rmcp/src/service/client.rs index 7bb5d8238..05c2749fe 100644 --- a/crates/rmcp/src/service/client.rs +++ b/crates/rmcp/src/service/client.rs @@ -1,3 +1,5 @@ +// Sampling/Roots/Logging are SEP-2577-deprecated; internal references are expected. +#![expect(deprecated)] use std::borrow::Cow; use thiserror::Error; diff --git a/crates/rmcp/src/service/server.rs b/crates/rmcp/src/service/server.rs index 160d5b324..c369e5aca 100644 --- a/crates/rmcp/src/service/server.rs +++ b/crates/rmcp/src/service/server.rs @@ -1,3 +1,5 @@ +// Sampling/Roots/Logging are SEP-2577-deprecated; internal references are expected. +#![expect(deprecated)] use std::borrow::Cow; #[cfg(feature = "elicitation")] use std::collections::HashSet; diff --git a/crates/rmcp/tests/common/handlers.rs b/crates/rmcp/tests/common/handlers.rs index 276e1bd23..7928fa6eb 100644 --- a/crates/rmcp/tests/common/handlers.rs +++ b/crates/rmcp/tests/common/handlers.rs @@ -1,3 +1,5 @@ +// Sampling/Roots/Logging are SEP-2577-deprecated; this test handler exercises them. +#![expect(deprecated)] use std::{ future::Future, sync::{Arc, Mutex}, diff --git a/crates/rmcp/tests/test_message_protocol.rs b/crates/rmcp/tests/test_message_protocol.rs index 6fdb4285d..f42cfe0a1 100644 --- a/crates/rmcp/tests/test_message_protocol.rs +++ b/crates/rmcp/tests/test_message_protocol.rs @@ -1,5 +1,6 @@ //cargo test --test test_message_protocol --features "client server" #![cfg(not(feature = "local"))] +#![expect(deprecated)] // exercises SEP-2577-deprecated Sampling/Roots/Logging types mod common; use common::handlers::{TestClientHandler, TestServer}; diff --git a/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema.json b/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema.json index 46378bc9c..3bfdb7c43 100644 --- a/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema.json +++ b/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema.json @@ -494,6 +494,7 @@ ] } }, + "deprecated": true, "required": [ "model", "role", @@ -1152,6 +1153,7 @@ } } }, + "deprecated": true, "required": [ "roots" ] @@ -1169,6 +1171,7 @@ "LoggingLevel": { "description": "Logging levels supported by the MCP protocol", "type": "string", + "deprecated": true, "enum": [ "debug", "info", @@ -1894,6 +1897,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "uri" ] @@ -1953,6 +1957,7 @@ }, "SamplingMessageContentBlock": { "description": "Content types for sampling messages (SEP-1577).", + "deprecated": true, "oneOf": [ { "type": "object", @@ -2082,6 +2087,7 @@ ] } }, + "deprecated": true, "required": [ "level" ] @@ -2357,6 +2363,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "toolUseId", "content" @@ -2384,6 +2391,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "id", "name", diff --git a/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema_current.json b/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema_current.json index 46378bc9c..3bfdb7c43 100644 --- a/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema_current.json +++ b/crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema_current.json @@ -494,6 +494,7 @@ ] } }, + "deprecated": true, "required": [ "model", "role", @@ -1152,6 +1153,7 @@ } } }, + "deprecated": true, "required": [ "roots" ] @@ -1169,6 +1171,7 @@ "LoggingLevel": { "description": "Logging levels supported by the MCP protocol", "type": "string", + "deprecated": true, "enum": [ "debug", "info", @@ -1894,6 +1897,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "uri" ] @@ -1953,6 +1957,7 @@ }, "SamplingMessageContentBlock": { "description": "Content types for sampling messages (SEP-1577).", + "deprecated": true, "oneOf": [ { "type": "object", @@ -2082,6 +2087,7 @@ ] } }, + "deprecated": true, "required": [ "level" ] @@ -2357,6 +2363,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "toolUseId", "content" @@ -2384,6 +2391,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "id", "name", diff --git a/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json b/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json index 2b3b41732..fcf821f52 100644 --- a/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json +++ b/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json @@ -565,6 +565,7 @@ } } }, + "deprecated": true, "required": [ "messages", "maxTokens" @@ -1577,6 +1578,7 @@ "LoggingLevel": { "description": "Logging levels supported by the MCP protocol", "type": "string", + "deprecated": true, "enum": [ "debug", "info", @@ -1623,6 +1625,7 @@ ] } }, + "deprecated": true, "required": [ "level", "data" @@ -1639,7 +1642,8 @@ "null" ] } - } + }, + "deprecated": true }, "ModelPreferences": { "description": "Preferences for model selection and behavior in sampling requests.\n\nThis allows servers to express their preferences for which model to use\nand how to balance different priorities when the client has multiple\nmodel options available.", @@ -1679,7 +1683,8 @@ ], "format": "float" } - } + }, + "deprecated": true }, "MultiSelectEnumSchema": { "description": "Multi-select enum options", @@ -2494,6 +2499,7 @@ ] } }, + "deprecated": true, "required": [ "role", "content" @@ -2501,6 +2507,7 @@ }, "SamplingMessageContentBlock": { "description": "Content types for sampling messages (SEP-1577).", + "deprecated": true, "oneOf": [ { "type": "object", @@ -3379,7 +3386,8 @@ } ] } - } + }, + "deprecated": true }, "ToolChoiceMode": { "description": "Tool selection mode (SEP-1577).", @@ -3457,6 +3465,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "toolUseId", "content" @@ -3484,6 +3493,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "id", "name", diff --git a/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json b/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json index 2b3b41732..fcf821f52 100644 --- a/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json +++ b/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json @@ -565,6 +565,7 @@ } } }, + "deprecated": true, "required": [ "messages", "maxTokens" @@ -1577,6 +1578,7 @@ "LoggingLevel": { "description": "Logging levels supported by the MCP protocol", "type": "string", + "deprecated": true, "enum": [ "debug", "info", @@ -1623,6 +1625,7 @@ ] } }, + "deprecated": true, "required": [ "level", "data" @@ -1639,7 +1642,8 @@ "null" ] } - } + }, + "deprecated": true }, "ModelPreferences": { "description": "Preferences for model selection and behavior in sampling requests.\n\nThis allows servers to express their preferences for which model to use\nand how to balance different priorities when the client has multiple\nmodel options available.", @@ -1679,7 +1683,8 @@ ], "format": "float" } - } + }, + "deprecated": true }, "MultiSelectEnumSchema": { "description": "Multi-select enum options", @@ -2494,6 +2499,7 @@ ] } }, + "deprecated": true, "required": [ "role", "content" @@ -2501,6 +2507,7 @@ }, "SamplingMessageContentBlock": { "description": "Content types for sampling messages (SEP-1577).", + "deprecated": true, "oneOf": [ { "type": "object", @@ -3379,7 +3386,8 @@ } ] } - } + }, + "deprecated": true }, "ToolChoiceMode": { "description": "Tool selection mode (SEP-1577).", @@ -3457,6 +3465,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "toolUseId", "content" @@ -3484,6 +3493,7 @@ "type": "string" } }, + "deprecated": true, "required": [ "id", "name",