From 4ff41ba62e183c930abe542671598fbe7c39813c Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Mon, 9 Jun 2025 13:03:47 +0200 Subject: [PATCH] context_server: Update types to reflect latest protocol version (`2025-03-26`) (#32377) This updates the `types.rs` file to reflect the latest version of the MCP spec. Next up is making use of some of these new capabilities. Would also be great to add support for [Streamable HTTP Transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) Release Notes: - N/A --- crates/agent/src/context_server_tool.rs | 3 ++ crates/context_server/src/protocol.rs | 7 +++-- crates/context_server/src/types.rs | 40 +++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/crates/agent/src/context_server_tool.rs b/crates/agent/src/context_server_tool.rs index 2de43d157f..026911128e 100644 --- a/crates/agent/src/context_server_tool.rs +++ b/crates/agent/src/context_server_tool.rs @@ -123,6 +123,9 @@ impl Tool for ContextServerTool { types::ToolResponseContent::Image { .. } => { log::warn!("Ignoring image content from tool response"); } + types::ToolResponseContent::Audio { .. } => { + log::warn!("Ignoring audio content from tool response"); + } types::ToolResponseContent::Resource { .. } => { log::warn!("Ignoring resource content from tool response"); } diff --git a/crates/context_server/src/protocol.rs b/crates/context_server/src/protocol.rs index 233df048d6..8f50cd8fa5 100644 --- a/crates/context_server/src/protocol.rs +++ b/crates/context_server/src/protocol.rs @@ -20,9 +20,10 @@ impl ModelContextProtocol { } fn supported_protocols() -> Vec { - vec![types::ProtocolVersion( - types::LATEST_PROTOCOL_VERSION.to_string(), - )] + vec![ + types::ProtocolVersion(types::LATEST_PROTOCOL_VERSION.to_string()), + types::ProtocolVersion(types::VERSION_2024_11_05.to_string()), + ] } pub async fn initialize( diff --git a/crates/context_server/src/types.rs b/crates/context_server/src/types.rs index 9c36c40228..1ab3225e1e 100644 --- a/crates/context_server/src/types.rs +++ b/crates/context_server/src/types.rs @@ -3,7 +3,8 @@ use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use url::Url; -pub const LATEST_PROTOCOL_VERSION: &str = "2024-11-05"; +pub const LATEST_PROTOCOL_VERSION: &str = "2025-03-26"; +pub const VERSION_2024_11_05: &str = "2024-11-05"; pub mod request { use super::*; @@ -291,13 +292,20 @@ pub enum MessageContent { #[serde(skip_serializing_if = "Option::is_none")] annotations: Option, }, - #[serde(rename = "image")] + #[serde(rename = "image", rename_all = "camelCase")] Image { data: String, mime_type: String, #[serde(skip_serializing_if = "Option::is_none")] annotations: Option, }, + #[serde(rename = "audio", rename_all = "camelCase")] + Audio { + data: String, + mime_type: String, + #[serde(skip_serializing_if = "Option::is_none")] + annotations: Option, + }, #[serde(rename = "resource")] Resource { resource: ResourceContents, @@ -394,6 +402,8 @@ pub struct ServerCapabilities { #[serde(skip_serializing_if = "Option::is_none")] pub logging: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub completions: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub prompts: Option, #[serde(skip_serializing_if = "Option::is_none")] pub resources: Option, @@ -438,6 +448,28 @@ pub struct Tool { #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, pub input_schema: serde_json::Value, + #[serde(skip_serializing_if = "Option::is_none")] + pub annotations: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ToolAnnotations { + /// A human-readable title for the tool. + #[serde(skip_serializing_if = "Option::is_none")] + pub title: Option, + /// If true, the tool does not modify its environment. + #[serde(skip_serializing_if = "Option::is_none")] + pub read_only_hint: Option, + /// If true, the tool may perform destructive updates to its environment. + #[serde(skip_serializing_if = "Option::is_none")] + pub destructive_hint: Option, + /// If true, calling the tool repeatedly with the same arguments will have no additional effect on its environment. + #[serde(skip_serializing_if = "Option::is_none")] + pub idempotent_hint: Option, + /// If true, this tool may interact with an "open world" of external entities. + #[serde(skip_serializing_if = "Option::is_none")] + pub open_world_hint: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -582,6 +614,8 @@ pub struct ProgressParams { pub progress_token: ProgressToken, pub progress: f64, #[serde(skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub total: Option, #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")] pub meta: Option>, @@ -625,6 +659,8 @@ pub enum ToolResponseContent { Text { text: String }, #[serde(rename = "image", rename_all = "camelCase")] Image { data: String, mime_type: String }, + #[serde(rename = "audio", rename_all = "camelCase")] + Audio { data: String, mime_type: String }, #[serde(rename = "resource")] Resource { resource: ResourceContents }, }