diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 64d79d392f..ca852fc2ee 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -70,10 +70,9 @@ use futures::future::BoxFuture; use futures::prelude::*; use futures::stream::FuturesOrdered; use mcp_types::CallToolResult; -use mcp_types::ListResourceTemplatesRequestParams; use mcp_types::ListResourceTemplatesResult; -use mcp_types::ListResourcesRequestParams; use mcp_types::ListResourcesResult; +use mcp_types::PaginatedRequestParams; use mcp_types::ReadResourceRequestParams; use mcp_types::ReadResourceResult; use mcp_types::RequestId; @@ -2196,7 +2195,7 @@ impl Session { pub async fn list_resources( &self, server: &str, - params: Option, + params: Option, ) -> anyhow::Result { self.services .mcp_connection_manager @@ -2209,7 +2208,7 @@ impl Session { pub async fn list_resource_templates( &self, server: &str, - params: Option, + params: Option, ) -> anyhow::Result { self.services .mcp_connection_manager @@ -5108,6 +5107,7 @@ mod tests { #[test] fn prefers_structured_content_when_present() { let ctr = CallToolResult { + _meta: None, // Content present but should be ignored because structured_content is set. content: vec![text_block("ignored")], is_error: None, @@ -5154,6 +5154,7 @@ mod tests { #[test] fn falls_back_to_content_when_structured_is_null() { let ctr = CallToolResult { + _meta: None, content: vec![text_block("hello"), text_block("world")], is_error: None, structured_content: Some(serde_json::Value::Null), @@ -5173,6 +5174,7 @@ mod tests { #[test] fn success_flag_reflects_is_error_true() { let ctr = CallToolResult { + _meta: None, content: vec![text_block("unused")], is_error: Some(true), structured_content: Some(json!({ "message": "bad" })), @@ -5191,6 +5193,7 @@ mod tests { #[test] fn success_flag_true_with_no_error_and_content_used() { let ctr = CallToolResult { + _meta: None, content: vec![text_block("alpha")], is_error: Some(false), structured_content: None, @@ -5246,6 +5249,7 @@ mod tests { fn text_block(s: &str) -> ContentBlock { ContentBlock::TextContent(TextContent { + _meta: None, annotations: None, text: s.to_string(), r#type: "text".to_string(), diff --git a/codex-rs/core/src/mcp/mod.rs b/codex-rs/core/src/mcp/mod.rs index 12c61ddaf1..9be3ef1bd8 100644 --- a/codex-rs/core/src/mcp/mod.rs +++ b/codex-rs/core/src/mcp/mod.rs @@ -249,9 +249,13 @@ mod tests { fn make_tool(name: &str) -> McpTool { McpTool { + _meta: None, annotations: None, description: None, + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: None, required: None, r#type: "object".to_string(), diff --git a/codex-rs/core/src/mcp_connection_manager.rs b/codex-rs/core/src/mcp_connection_manager.rs index 1b5048ab0c..da78be2d7d 100644 --- a/codex-rs/core/src/mcp_connection_manager.rs +++ b/codex-rs/core/src/mcp_connection_manager.rs @@ -38,11 +38,11 @@ use futures::future::BoxFuture; use futures::future::FutureExt; use futures::future::Shared; use mcp_types::ClientCapabilities; +use mcp_types::ClientCapabilitiesElicitation; use mcp_types::Implementation; -use mcp_types::ListResourceTemplatesRequestParams; use mcp_types::ListResourceTemplatesResult; -use mcp_types::ListResourcesRequestParams; use mcp_types::ListResourcesResult; +use mcp_types::PaginatedRequestParams; use mcp_types::ReadResourceRequestParams; use mcp_types::ReadResourceResult; use mcp_types::RequestId; @@ -52,7 +52,6 @@ use mcp_types::Tool; use serde::Deserialize; use serde::Serialize; -use serde_json::json; use sha1::Digest; use sha1::Sha1; use tokio::sync::Mutex; @@ -493,7 +492,8 @@ impl McpConnectionManager { let mut cursor: Option = None; loop { - let params = cursor.as_ref().map(|next| ListResourcesRequestParams { + let params = cursor.as_ref().map(|next| PaginatedRequestParams { + _meta: None, cursor: Some(next.clone()), }); let response = match client.list_resources(params, timeout).await { @@ -558,11 +558,10 @@ impl McpConnectionManager { let mut cursor: Option = None; loop { - let params = cursor - .as_ref() - .map(|next| ListResourceTemplatesRequestParams { - cursor: Some(next.clone()), - }); + let params = cursor.as_ref().map(|next| PaginatedRequestParams { + _meta: None, + cursor: Some(next.clone()), + }); let response = match client.list_resource_templates(params, timeout).await { Ok(result) => result, Err(err) => return (server_name_cloned, Err(err)), @@ -634,7 +633,7 @@ impl McpConnectionManager { pub async fn list_resources( &self, server: &str, - params: Option, + params: Option, ) -> Result { let managed = self.client_by_name(server).await?; let timeout = managed.tool_timeout; @@ -650,7 +649,7 @@ impl McpConnectionManager { pub async fn list_resource_templates( &self, server: &str, - params: Option, + params: Option, ) -> Result { let managed = self.client_by_name(server).await?; let client = managed.client.clone(); @@ -850,18 +849,24 @@ async fn start_server_task( elicitation_requests: ElicitationRequestManager, ) -> Result { let params = mcp_types::InitializeRequestParams { + _meta: None, capabilities: ClientCapabilities { + elicitation: Some(ClientCapabilitiesElicitation { + form: None, + url: None, + }), experimental: None, roots: None, sampling: None, - // https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#capabilities - // indicates this should be an empty object. - elicitation: Some(json!({})), + tasks: None, }, client_info: Implementation { + description: None, + icons: None, name: "codex-mcp-client".to_owned(), version: env!("CARGO_PKG_VERSION").to_owned(), title: Some("Codex".into()), + website_url: None, // This field is used by Codex when it is an MCP // server: it should not be used when Codex is // an MCP client. @@ -1055,9 +1060,13 @@ mod tests { server_name: server_name.to_string(), tool_name: tool_name.to_string(), tool: Tool { + _meta: None, annotations: None, description: Some(format!("Test tool: {tool_name}")), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: None, required: None, r#type: "object".to_string(), diff --git a/codex-rs/core/src/tools/handlers/mcp_resource.rs b/codex-rs/core/src/tools/handlers/mcp_resource.rs index 62f7a83e1a..ffa52f9768 100644 --- a/codex-rs/core/src/tools/handlers/mcp_resource.rs +++ b/codex-rs/core/src/tools/handlers/mcp_resource.rs @@ -6,10 +6,9 @@ use std::time::Instant; use async_trait::async_trait; use mcp_types::CallToolResult; use mcp_types::ContentBlock; -use mcp_types::ListResourceTemplatesRequestParams; use mcp_types::ListResourceTemplatesResult; -use mcp_types::ListResourcesRequestParams; use mcp_types::ListResourcesResult; +use mcp_types::PaginatedRequestParams; use mcp_types::ReadResourceRequestParams; use mcp_types::ReadResourceResult; use mcp_types::Resource; @@ -264,7 +263,8 @@ async fn handle_list_resources( let payload_result: Result = async { if let Some(server_name) = server.clone() { - let params = cursor.clone().map(|value| ListResourcesRequestParams { + let params = cursor.clone().map(|value| PaginatedRequestParams { + _meta: None, cursor: Some(value), }); let result = session @@ -371,11 +371,10 @@ async fn handle_list_resource_templates( let payload_result: Result = async { if let Some(server_name) = server.clone() { - let params = cursor - .clone() - .map(|value| ListResourceTemplatesRequestParams { - cursor: Some(value), - }); + let params = cursor.clone().map(|value| PaginatedRequestParams { + _meta: None, + cursor: Some(value), + }); let result = session .list_resource_templates(&server_name, params) .await @@ -482,7 +481,13 @@ async fn handle_read_resource( let payload_result: Result = async { let result = session - .read_resource(&server, ReadResourceRequestParams { uri: uri.clone() }) + .read_resource( + &server, + ReadResourceRequestParams { + _meta: None, + uri: uri.clone(), + }, + ) .await .map_err(|err| { FunctionCallError::RespondToModel(format!("resources/read failed: {err:#}")) @@ -551,7 +556,9 @@ async fn handle_read_resource( fn call_tool_result_from_content(content: &str, success: Option) -> CallToolResult { CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, annotations: None, text: content.to_string(), r#type: "text".to_string(), @@ -685,8 +692,10 @@ mod tests { fn resource(uri: &str, name: &str) -> Resource { Resource { + _meta: None, annotations: None, description: None, + icons: None, mime_type: None, name: name.to_string(), size: None, @@ -697,8 +706,10 @@ mod tests { fn template(uri_template: &str, name: &str) -> ResourceTemplate { ResourceTemplate { + _meta: None, annotations: None, description: None, + icons: None, mime_type: None, name: name.to_string(), title: None, @@ -719,6 +730,7 @@ mod tests { #[test] fn list_resources_payload_from_single_server_copies_next_cursor() { let result = ListResourcesResult { + _meta: None, next_cursor: Some("cursor-1".to_string()), resources: vec![resource("memo://id", "memo")], }; diff --git a/codex-rs/core/src/tools/spec.rs b/codex-rs/core/src/tools/spec.rs index a51372b9b3..a582c1d71d 100644 --- a/codex-rs/core/src/tools/spec.rs +++ b/codex-rs/core/src/tools/spec.rs @@ -2027,8 +2027,12 @@ mod tests { Some(HashMap::from([( "test_server/do_something_cool".to_string(), mcp_types::Tool { + _meta: None, name: "do_something_cool".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({ "string_argument": { "type": "string", @@ -2124,8 +2128,12 @@ mod tests { ( "test_server/do".to_string(), mcp_types::Tool { + _meta: None, name: "a".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({})), required: None, r#type: "object".to_string(), @@ -2139,8 +2147,12 @@ mod tests { ( "test_server/something".to_string(), mcp_types::Tool { + _meta: None, name: "b".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({})), required: None, r#type: "object".to_string(), @@ -2154,8 +2166,12 @@ mod tests { ( "test_server/cool".to_string(), mcp_types::Tool { + _meta: None, name: "c".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({})), required: None, r#type: "object".to_string(), @@ -2201,8 +2217,12 @@ mod tests { Some(HashMap::from([( "dash/search".to_string(), mcp_types::Tool { + _meta: None, name: "search".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({ "query": { "description": "search query" @@ -2259,8 +2279,12 @@ mod tests { Some(HashMap::from([( "dash/paginate".to_string(), mcp_types::Tool { + _meta: None, name: "paginate".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({ "page": { "type": "integer" } })), @@ -2314,8 +2338,12 @@ mod tests { Some(HashMap::from([( "dash/tags".to_string(), mcp_types::Tool { + _meta: None, name: "tags".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({ "tags": { "type": "array" } })), @@ -2371,8 +2399,12 @@ mod tests { Some(HashMap::from([( "dash/value".to_string(), mcp_types::Tool { + _meta: None, name: "value".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({ "value": { "anyOf": [ { "type": "string" }, { "type": "number" } ] } })), @@ -2483,8 +2515,12 @@ Examples of valid command strings: Some(HashMap::from([( "test_server/do_something_cool".to_string(), mcp_types::Tool { + _meta: None, name: "do_something_cool".to_string(), + execution: None, + icons: None, input_schema: ToolInputSchema { + schema: None, properties: Some(serde_json::json!({ "string_argument": { "type": "string", diff --git a/codex-rs/mcp-server/src/codex_tool_config.rs b/codex-rs/mcp-server/src/codex_tool_config.rs index 8131d7da52..d4a1b0f9b1 100644 --- a/codex-rs/mcp-server/src/codex_tool_config.rs +++ b/codex-rs/mcp-server/src/codex_tool_config.rs @@ -125,6 +125,7 @@ pub(crate) fn create_tool_for_codex_tool_call_param() -> Tool { }); Tool { + _meta: None, name: "codex".to_string(), title: Some("Codex".to_string()), input_schema: tool_input_schema, @@ -133,11 +134,14 @@ pub(crate) fn create_tool_for_codex_tool_call_param() -> Tool { "Run a Codex session. Accepts configuration parameters matching the Codex Config struct.".to_string(), ), annotations: None, + execution: None, + icons: None, } } fn codex_tool_output_schema() -> ToolOutputSchema { ToolOutputSchema { + schema: None, properties: Some(serde_json::json!({ "threadId": { "type": "string" }, "content": { "type": "string" } @@ -247,6 +251,7 @@ pub(crate) fn create_tool_for_codex_tool_call_reply_param() -> Tool { }); Tool { + _meta: None, name: "codex-reply".to_string(), title: Some("Codex Reply".to_string()), input_schema: tool_input_schema, @@ -255,6 +260,8 @@ pub(crate) fn create_tool_for_codex_tool_call_reply_param() -> Tool { "Continue a Codex conversation by providing the thread id and prompt.".to_string(), ), annotations: None, + execution: None, + icons: None, } } @@ -281,6 +288,7 @@ mod tests { let expected_tool_json = serde_json::json!({ "description": "Run a Codex session. Accepts configuration parameters matching the Codex Config struct.", "inputSchema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "approval-policy": { "description": "Approval policy for shell commands generated by the model: `untrusted`, `on-failure`, `on-request`, `never`.", @@ -368,6 +376,7 @@ mod tests { let expected_tool_json = serde_json::json!({ "description": "Continue a Codex conversation by providing the thread id and prompt.", "inputSchema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "conversationId": { "description": "DEPRECATED: use threadId instead.", diff --git a/codex-rs/mcp-server/src/codex_tool_runner.rs b/codex-rs/mcp-server/src/codex_tool_runner.rs index 1dbdbc767b..30f173a139 100644 --- a/codex-rs/mcp-server/src/codex_tool_runner.rs +++ b/codex-rs/mcp-server/src/codex_tool_runner.rs @@ -43,6 +43,7 @@ pub(crate) fn create_call_tool_result_with_thread_id( ) -> CallToolResult { let content_text = text; let content = vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_string(), text: content_text.clone(), annotations: None, @@ -52,6 +53,7 @@ pub(crate) fn create_call_tool_result_with_thread_id( "content": content_text, }); CallToolResult { + _meta: None, content, is_error, structured_content: Some(structured_content), @@ -78,7 +80,9 @@ pub async fn run_codex_tool_session( Ok(res) => res, Err(e) => { let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_string(), text: format!("Failed to start Codex session: {e}"), annotations: None, diff --git a/codex-rs/mcp-server/src/exec_approval.rs b/codex-rs/mcp-server/src/exec_approval.rs index a98099dcf2..b78ad12638 100644 --- a/codex-rs/mcp-server/src/exec_approval.rs +++ b/codex-rs/mcp-server/src/exec_approval.rs @@ -7,8 +7,8 @@ use codex_core::protocol::ReviewDecision; use codex_protocol::ThreadId; use codex_protocol::parse_command::ParsedCommand; use mcp_types::ElicitRequest; -use mcp_types::ElicitRequestParamsRequestedSchema; -use mcp_types::JSONRPCErrorError; +use mcp_types::ElicitRequestFormParamsRequestedSchema; +use mcp_types::Error; use mcp_types::ModelContextProtocolRequest; use mcp_types::RequestId; use serde::Deserialize; @@ -27,7 +27,7 @@ pub struct ExecApprovalElicitRequestParams { pub message: String, #[serde(rename = "requestedSchema")] - pub requested_schema: ElicitRequestParamsRequestedSchema, + pub requested_schema: ElicitRequestFormParamsRequestedSchema, // These are additional fields the client can use to // correlate the request with the codex tool call. @@ -73,7 +73,8 @@ pub(crate) async fn handle_exec_approval_request( let params = ExecApprovalElicitRequestParams { message, - requested_schema: ElicitRequestParamsRequestedSchema { + requested_schema: ElicitRequestFormParamsRequestedSchema { + schema: None, r#type: "object".to_string(), properties: json!({}), required: None, @@ -96,7 +97,7 @@ pub(crate) async fn handle_exec_approval_request( outgoing .send_error( request_id.clone(), - JSONRPCErrorError { + Error { code: INVALID_PARAMS_ERROR_CODE, message, data: None, diff --git a/codex-rs/mcp-server/src/lib.rs b/codex-rs/mcp-server/src/lib.rs index dabd7cca0f..36a5d99e6a 100644 --- a/codex-rs/mcp-server/src/lib.rs +++ b/codex-rs/mcp-server/src/lib.rs @@ -107,9 +107,9 @@ pub async fn run_main( while let Some(msg) = incoming_rx.recv().await { match msg { JSONRPCMessage::Request(r) => processor.process_request(r).await, - JSONRPCMessage::Response(r) => processor.process_response(r).await, + JSONRPCMessage::ResultResponse(r) => processor.process_response(r).await, JSONRPCMessage::Notification(n) => processor.process_notification(n).await, - JSONRPCMessage::Error(e) => processor.process_error(e), + JSONRPCMessage::ErrorResponse(e) => processor.process_error(e), } } diff --git a/codex-rs/mcp-server/src/message_processor.rs b/codex-rs/mcp-server/src/message_processor.rs index 9d947cda3f..2b702856d1 100644 --- a/codex-rs/mcp-server/src/message_processor.rs +++ b/codex-rs/mcp-server/src/message_processor.rs @@ -20,11 +20,11 @@ use mcp_types::CallToolRequestParams; use mcp_types::CallToolResult; use mcp_types::ClientRequest as McpClientRequest; use mcp_types::ContentBlock; -use mcp_types::JSONRPCError; -use mcp_types::JSONRPCErrorError; +use mcp_types::Error; +use mcp_types::JSONRPCErrorResponse; use mcp_types::JSONRPCNotification; use mcp_types::JSONRPCRequest; -use mcp_types::JSONRPCResponse; +use mcp_types::JSONRPCResultResponse; use mcp_types::ListToolsResult; use mcp_types::ModelContextProtocolRequest; use mcp_types::RequestId; @@ -125,13 +125,29 @@ impl MessageProcessor { McpClientRequest::CompleteRequest(params) => { self.handle_complete(params); } + McpClientRequest::GetTaskRequest(_) => { + self.handle_unsupported_request(request_id, "tasks/get") + .await; + } + McpClientRequest::GetTaskPayloadRequest(_) => { + self.handle_unsupported_request(request_id, "tasks/result") + .await; + } + McpClientRequest::CancelTaskRequest(_) => { + self.handle_unsupported_request(request_id, "tasks/cancel") + .await; + } + McpClientRequest::ListTasksRequest(_) => { + self.handle_unsupported_request(request_id, "tasks/list") + .await; + } } } /// Handle a standalone JSON-RPC response originating from the peer. - pub(crate) async fn process_response(&mut self, response: JSONRPCResponse) { + pub(crate) async fn process_response(&mut self, response: JSONRPCResultResponse) { tracing::info!("<- response: {:?}", response); - let JSONRPCResponse { id, result, .. } = response; + let JSONRPCResultResponse { id, result, .. } = response; self.outgoing.notify_client_response(id, result).await } @@ -169,11 +185,17 @@ impl MessageProcessor { ServerNotification::LoggingMessageNotification(params) => { self.handle_logging_message(params); } + ServerNotification::TaskStatusNotification(params) => { + self.handle_task_status_notification(params); + } + ServerNotification::ElicitationCompleteNotification(params) => { + self.handle_elicitation_complete_notification(params); + } } } /// Handle an error object received from the peer. - pub(crate) fn process_error(&mut self, err: JSONRPCError) { + pub(crate) fn process_error(&mut self, err: JSONRPCErrorResponse) { tracing::error!("<- error: {:?}", err); } @@ -186,7 +208,7 @@ impl MessageProcessor { if self.initialized { // Already initialised: send JSON-RPC error response. - let error = JSONRPCErrorError { + let error = Error { code: INVALID_REQUEST_ERROR_CODE, message: "initialize called more than once".to_string(), data: None, @@ -207,12 +229,14 @@ impl MessageProcessor { // Build a minimal InitializeResult. Fill with placeholders. let result = mcp_types::InitializeResult { + _meta: None, capabilities: mcp_types::ServerCapabilities { completions: None, experimental: None, logging: None, prompts: None, resources: None, + tasks: None, tools: Some(ServerCapabilitiesTools { list_changed: Some(true), }), @@ -220,9 +244,12 @@ impl MessageProcessor { instructions: None, protocol_version: params.protocol_version.clone(), server_info: mcp_types::Implementation { + description: None, + icons: None, name: "codex-mcp-server".to_string(), version: env!("CARGO_PKG_VERSION").to_string(), title: Some("Codex".to_string()), + website_url: None, user_agent: Some(get_codex_user_agent()), }, }; @@ -238,6 +265,19 @@ impl MessageProcessor { self.outgoing.send_response(id, result).await; } + async fn handle_unsupported_request(&self, id: RequestId, method: &str) { + self.outgoing + .send_error( + id, + Error { + code: INVALID_REQUEST_ERROR_CODE, + message: format!("method `{method}` is not supported"), + data: None, + }, + ) + .await; + } + async fn handle_ping( &self, id: RequestId, @@ -306,6 +346,7 @@ impl MessageProcessor { ) { tracing::trace!("tools/list -> {params:?}"); let result = ListToolsResult { + _meta: None, tools: vec![ create_tool_for_codex_tool_call_param(), create_tool_for_codex_tool_call_reply_param(), @@ -323,7 +364,9 @@ impl MessageProcessor { params: ::Params, ) { tracing::info!("tools/call -> params: {:?}", params); - let CallToolRequestParams { name, arguments } = params; + let CallToolRequestParams { + name, arguments, .. + } = params; match name.as_str() { "codex" => self.handle_tool_call_codex(id, arguments).await, @@ -333,7 +376,9 @@ impl MessageProcessor { } _ => { let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_string(), text: format!("Unknown tool '{name}'"), annotations: None, @@ -356,7 +401,9 @@ impl MessageProcessor { Ok(cfg) => cfg, Err(e) => { let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_owned(), text: format!( "Failed to load Codex configuration from overrides: {e}" @@ -373,7 +420,9 @@ impl MessageProcessor { }, Err(e) => { let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_owned(), text: format!("Failed to parse configuration for Codex tool: {e}"), annotations: None, @@ -388,7 +437,9 @@ impl MessageProcessor { }, None => { let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_string(), text: "Missing arguments for codex tool-call; the `prompt` field is required." @@ -439,7 +490,9 @@ impl MessageProcessor { Err(e) => { tracing::error!("Failed to parse Codex tool call reply parameters: {e}"); let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_owned(), text: format!("Failed to parse configuration for Codex tool: {e}"), annotations: None, @@ -457,7 +510,9 @@ impl MessageProcessor { "Missing arguments for codex-reply tool-call; the `thread_id` and `prompt` fields are required." ); let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_owned(), text: "Missing arguments for codex-reply tool-call; the `thread_id` and `prompt` fields are required.".to_owned(), annotations: None, @@ -476,7 +531,9 @@ impl MessageProcessor { Err(e) => { tracing::error!("Failed to parse thread_id: {e}"); let result = CallToolResult { + _meta: None, content: vec![ContentBlock::TextContent(TextContent { + _meta: None, r#type: "text".to_owned(), text: format!("Failed to parse thread_id: {e}"), annotations: None, @@ -550,7 +607,10 @@ impl MessageProcessor { &self, params: ::Params, ) { - let request_id = params.request_id; + let Some(request_id) = params.request_id else { + tracing::warn!("notifications/cancelled received without requestId"); + return; + }; // Create a stable string form early for logging and submission id. let request_id_string = match &request_id { RequestId::String(s) => s.clone(), @@ -641,4 +701,18 @@ impl MessageProcessor { ) { tracing::info!("notifications/message -> params: {:?}", params); } + + fn handle_task_status_notification( + &self, + params: ::Params, + ) { + tracing::info!("notifications/tasks/status -> params: {:?}", params); + } + + fn handle_elicitation_complete_notification( + &self, + params: ::Params, + ) { + tracing::info!("notifications/elicitation/complete -> params: {:?}", params); + } } diff --git a/codex-rs/mcp-server/src/outgoing_message.rs b/codex-rs/mcp-server/src/outgoing_message.rs index 954e50d9de..4370734e9c 100644 --- a/codex-rs/mcp-server/src/outgoing_message.rs +++ b/codex-rs/mcp-server/src/outgoing_message.rs @@ -4,13 +4,13 @@ use std::sync::atomic::Ordering; use codex_core::protocol::Event; use codex_protocol::ThreadId; +use mcp_types::Error; use mcp_types::JSONRPC_VERSION; -use mcp_types::JSONRPCError; -use mcp_types::JSONRPCErrorError; +use mcp_types::JSONRPCErrorResponse; use mcp_types::JSONRPCMessage; use mcp_types::JSONRPCNotification; use mcp_types::JSONRPCRequest; -use mcp_types::JSONRPCResponse; +use mcp_types::JSONRPCResultResponse; use mcp_types::RequestId; use mcp_types::Result; use serde::Serialize; @@ -86,7 +86,7 @@ impl OutgoingMessageSender { Err(err) => { self.send_error( id, - JSONRPCErrorError { + Error { code: INTERNAL_ERROR_CODE, message: format!("failed to serialize response: {err}"), data: None, @@ -130,7 +130,7 @@ impl OutgoingMessageSender { let _ = self.sender.send(outgoing_message); } - pub(crate) async fn send_error(&self, id: RequestId, error: JSONRPCErrorError) { + pub(crate) async fn send_error(&self, id: RequestId, error: Error) { let outgoing_message = OutgoingMessage::Error(OutgoingError { id, error }); let _ = self.sender.send(outgoing_message); } @@ -164,17 +164,19 @@ impl From for JSONRPCMessage { }) } Response(OutgoingResponse { id, result }) => { - JSONRPCMessage::Response(JSONRPCResponse { + JSONRPCMessage::ResultResponse(JSONRPCResultResponse { jsonrpc: JSONRPC_VERSION.into(), id, result, }) } - Error(OutgoingError { id, error }) => JSONRPCMessage::Error(JSONRPCError { - jsonrpc: JSONRPC_VERSION.into(), - id, - error, - }), + Error(OutgoingError { id, error }) => { + JSONRPCMessage::ErrorResponse(JSONRPCErrorResponse { + jsonrpc: JSONRPC_VERSION.into(), + id: Some(id), + error, + }) + } } } } @@ -225,7 +227,7 @@ pub(crate) struct OutgoingResponse { #[derive(Debug, Clone, PartialEq, Serialize)] pub(crate) struct OutgoingError { - pub error: JSONRPCErrorError, + pub error: Error, pub id: RequestId, } diff --git a/codex-rs/mcp-server/src/patch_approval.rs b/codex-rs/mcp-server/src/patch_approval.rs index 5c3073959d..a3f1557ef9 100644 --- a/codex-rs/mcp-server/src/patch_approval.rs +++ b/codex-rs/mcp-server/src/patch_approval.rs @@ -8,8 +8,8 @@ use codex_core::protocol::Op; use codex_core::protocol::ReviewDecision; use codex_protocol::ThreadId; use mcp_types::ElicitRequest; -use mcp_types::ElicitRequestParamsRequestedSchema; -use mcp_types::JSONRPCErrorError; +use mcp_types::ElicitRequestFormParamsRequestedSchema; +use mcp_types::Error; use mcp_types::ModelContextProtocolRequest; use mcp_types::RequestId; use serde::Deserialize; @@ -24,7 +24,7 @@ use crate::outgoing_message::OutgoingMessageSender; pub struct PatchApprovalElicitRequestParams { pub message: String, #[serde(rename = "requestedSchema")] - pub requested_schema: ElicitRequestParamsRequestedSchema, + pub requested_schema: ElicitRequestFormParamsRequestedSchema, #[serde(rename = "threadId")] pub thread_id: ThreadId, pub codex_elicitation: String, @@ -64,7 +64,8 @@ pub(crate) async fn handle_patch_approval_request( let params = PatchApprovalElicitRequestParams { message: message_lines.join("\n"), - requested_schema: ElicitRequestParamsRequestedSchema { + requested_schema: ElicitRequestFormParamsRequestedSchema { + schema: None, r#type: "object".to_string(), properties: json!({}), required: None, @@ -87,7 +88,7 @@ pub(crate) async fn handle_patch_approval_request( outgoing .send_error( request_id.clone(), - JSONRPCErrorError { + Error { code: INVALID_PARAMS_ERROR_CODE, message, data: None, diff --git a/codex-rs/mcp-server/tests/common/lib.rs b/codex-rs/mcp-server/tests/common/lib.rs index 364c708651..a38e74b991 100644 --- a/codex-rs/mcp-server/tests/common/lib.rs +++ b/codex-rs/mcp-server/tests/common/lib.rs @@ -6,14 +6,14 @@ pub use core_test_support::format_with_current_shell; pub use core_test_support::format_with_current_shell_display_non_login; pub use core_test_support::format_with_current_shell_non_login; pub use mcp_process::McpProcess; -use mcp_types::JSONRPCResponse; +use mcp_types::JSONRPCResultResponse; pub use mock_model_server::create_mock_chat_completions_server; pub use responses::create_apply_patch_sse_response; pub use responses::create_final_assistant_message_sse_response; pub use responses::create_shell_command_sse_response; use serde::de::DeserializeOwned; -pub fn to_response(response: JSONRPCResponse) -> anyhow::Result { +pub fn to_response(response: JSONRPCResultResponse) -> anyhow::Result { let value = serde_json::to_value(response.result)?; let codex_response = serde_json::from_value(value)?; Ok(codex_response) diff --git a/codex-rs/mcp-server/tests/common/mcp_process.rs b/codex-rs/mcp-server/tests/common/mcp_process.rs index 9a3f076fb1..d98f9ec1cc 100644 --- a/codex-rs/mcp-server/tests/common/mcp_process.rs +++ b/codex-rs/mcp-server/tests/common/mcp_process.rs @@ -14,13 +14,14 @@ use codex_mcp_server::CodexToolCallParam; use mcp_types::CallToolRequestParams; use mcp_types::ClientCapabilities; +use mcp_types::ClientCapabilitiesElicitation; use mcp_types::Implementation; use mcp_types::InitializeRequestParams; use mcp_types::JSONRPC_VERSION; use mcp_types::JSONRPCMessage; use mcp_types::JSONRPCNotification; use mcp_types::JSONRPCRequest; -use mcp_types::JSONRPCResponse; +use mcp_types::JSONRPCResultResponse; use mcp_types::ModelContextProtocolNotification; use mcp_types::ModelContextProtocolRequest; use mcp_types::RequestId; @@ -111,16 +112,24 @@ impl McpProcess { let request_id = self.next_request_id.fetch_add(1, Ordering::Relaxed); let params = InitializeRequestParams { + _meta: None, capabilities: ClientCapabilities { - elicitation: Some(json!({})), + elicitation: Some(ClientCapabilitiesElicitation { + form: None, + url: None, + }), experimental: None, roots: None, sampling: None, + tasks: None, }, client_info: Implementation { + description: None, + icons: None, name: "elicitation test".into(), title: Some("Elicitation Test".into()), version: "0.0.0".into(), + website_url: None, user_agent: None, }, protocol_version: mcp_types::MCP_SCHEMA_VERSION.into(), @@ -147,7 +156,7 @@ impl McpProcess { codex_core::terminal::user_agent() ); assert_eq!( - JSONRPCMessage::Response(JSONRPCResponse { + JSONRPCMessage::ResultResponse(JSONRPCResultResponse { jsonrpc: JSONRPC_VERSION.into(), id: RequestId::Integer(request_id), result: json!({ @@ -186,8 +195,10 @@ impl McpProcess { params: CodexToolCallParam, ) -> anyhow::Result { let codex_tool_call_params = CallToolRequestParams { + _meta: None, name: "codex".to_string(), arguments: Some(serde_json::to_value(params)?), + task: None, }; self.send_request( mcp_types::CallToolRequest::METHOD, @@ -218,7 +229,7 @@ impl McpProcess { id: RequestId, result: serde_json::Value, ) -> anyhow::Result<()> { - self.send_jsonrpc_message(JSONRPCMessage::Response(JSONRPCResponse { + self.send_jsonrpc_message(JSONRPCMessage::ResultResponse(JSONRPCResultResponse { jsonrpc: JSONRPC_VERSION.into(), id, result, @@ -256,11 +267,11 @@ impl McpProcess { JSONRPCMessage::Request(jsonrpc_request) => { return Ok(jsonrpc_request); } - JSONRPCMessage::Error(_) => { - anyhow::bail!("unexpected JSONRPCMessage::Error: {message:?}"); + JSONRPCMessage::ErrorResponse(_) => { + anyhow::bail!("unexpected JSONRPCMessage::ErrorResponse: {message:?}"); } - JSONRPCMessage::Response(_) => { - anyhow::bail!("unexpected JSONRPCMessage::Response: {message:?}"); + JSONRPCMessage::ResultResponse(_) => { + anyhow::bail!("unexpected JSONRPCMessage::ResultResponse: {message:?}"); } } } @@ -269,7 +280,7 @@ impl McpProcess { pub async fn read_stream_until_response_message( &mut self, request_id: RequestId, - ) -> anyhow::Result { + ) -> anyhow::Result { eprintln!("in read_stream_until_response_message({request_id:?})"); loop { @@ -281,10 +292,10 @@ impl McpProcess { JSONRPCMessage::Request(_) => { anyhow::bail!("unexpected JSONRPCMessage::Request: {message:?}"); } - JSONRPCMessage::Error(_) => { - anyhow::bail!("unexpected JSONRPCMessage::Error: {message:?}"); + JSONRPCMessage::ErrorResponse(_) => { + anyhow::bail!("unexpected JSONRPCMessage::ErrorResponse: {message:?}"); } - JSONRPCMessage::Response(jsonrpc_response) => { + JSONRPCMessage::ResultResponse(jsonrpc_response) => { if jsonrpc_response.id == request_id { return Ok(jsonrpc_response); } @@ -327,11 +338,11 @@ impl McpProcess { JSONRPCMessage::Request(_) => { anyhow::bail!("unexpected JSONRPCMessage::Request: {message:?}"); } - JSONRPCMessage::Error(_) => { - anyhow::bail!("unexpected JSONRPCMessage::Error: {message:?}"); + JSONRPCMessage::ErrorResponse(_) => { + anyhow::bail!("unexpected JSONRPCMessage::ErrorResponse: {message:?}"); } - JSONRPCMessage::Response(_) => { - anyhow::bail!("unexpected JSONRPCMessage::Response: {message:?}"); + JSONRPCMessage::ResultResponse(_) => { + anyhow::bail!("unexpected JSONRPCMessage::ResultResponse: {message:?}"); } } } diff --git a/codex-rs/mcp-server/tests/suite/codex_tool.rs b/codex-rs/mcp-server/tests/suite/codex_tool.rs index 31c451d24f..328af792f9 100644 --- a/codex-rs/mcp-server/tests/suite/codex_tool.rs +++ b/codex-rs/mcp-server/tests/suite/codex_tool.rs @@ -13,10 +13,10 @@ use codex_mcp_server::ExecApprovalResponse; use codex_mcp_server::PatchApprovalElicitRequestParams; use codex_mcp_server::PatchApprovalResponse; use mcp_types::ElicitRequest; -use mcp_types::ElicitRequestParamsRequestedSchema; +use mcp_types::ElicitRequestFormParamsRequestedSchema; use mcp_types::JSONRPC_VERSION; use mcp_types::JSONRPCRequest; -use mcp_types::JSONRPCResponse; +use mcp_types::JSONRPCResultResponse; use mcp_types::ModelContextProtocolRequest; use mcp_types::RequestId; use pretty_assertions::assert_eq; @@ -150,7 +150,7 @@ async fn shell_command_approval_triggers_elicitation() -> anyhow::Result<()> { ) .await??; assert_eq!( - JSONRPCResponse { + JSONRPCResultResponse { jsonrpc: JSONRPC_VERSION.into(), id: RequestId::Integer(codex_request_id), result: json!({ @@ -194,7 +194,8 @@ fn create_expected_elicitation_request( method: ElicitRequest::METHOD.to_string(), params: Some(serde_json::to_value(&ExecApprovalElicitRequestParams { message: expected_message, - requested_schema: ElicitRequestParamsRequestedSchema { + requested_schema: ElicitRequestFormParamsRequestedSchema { + schema: None, r#type: "object".to_string(), properties: json!({}), required: None, @@ -312,7 +313,7 @@ async fn patch_approval_triggers_elicitation() -> anyhow::Result<()> { ) .await??; assert_eq!( - JSONRPCResponse { + JSONRPCResultResponse { jsonrpc: JSONRPC_VERSION.into(), id: RequestId::Integer(codex_request_id), result: json!({ @@ -451,7 +452,8 @@ fn create_expected_patch_approval_elicitation_request( method: ElicitRequest::METHOD.to_string(), params: Some(serde_json::to_value(&PatchApprovalElicitRequestParams { message: message_lines.join("\n"), - requested_schema: ElicitRequestParamsRequestedSchema { + requested_schema: ElicitRequestFormParamsRequestedSchema { + schema: None, r#type: "object".to_string(), properties: json!({}), required: None, diff --git a/codex-rs/mcp-types/generate_mcp_types.py b/codex-rs/mcp-types/generate_mcp_types.py index 5aaac81cd7..e5b8c512b1 100755 --- a/codex-rs/mcp-types/generate_mcp_types.py +++ b/codex-rs/mcp-types/generate_mcp_types.py @@ -18,7 +18,7 @@ from shutil import copy2 from typing import Any, Literal -SCHEMA_VERSION = "2025-06-18" +SCHEMA_VERSION = "2025-11-25" JSONRPC_VERSION = "2.0" STANDARD_DERIVE = "#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)]\n" @@ -26,7 +26,8 @@ STANDARD_HASHABLE_DERIVE = ( "#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Hash, Eq, JsonSchema, TS)]\n" ) -# Will be populated with the schema's `definitions` map in `main()` so that +# Will be populated with the schema's definitions map (`definitions` in +# draft-07, `$defs` in 2020-12) in `main()` so that # helper functions (for example `define_any_of`) can perform look-ups while # generating code. DEFINITIONS: dict[str, Any] = {} @@ -85,7 +86,7 @@ def generate_lib_rs(schema_file: Path, lib_rs: Path, fmt: bool) -> None: with schema_file.open(encoding="utf-8") as f: schema_json = json.load(f) - DEFINITIONS = schema_json["definitions"] + DEFINITIONS = get_schema_definitions(schema_json) out = [ f""" @@ -124,7 +125,7 @@ fn default_jsonrpc() -> String {{ JSONRPC_VERSION.to_owned() }} """ ] - definitions = schema_json["definitions"] + definitions = get_schema_definitions(schema_json) # Keep track of every *Request type so we can generate the TryFrom impl at # the end. # The concrete *Request types referenced by the ClientRequest enum will be @@ -283,13 +284,25 @@ def add_definition(name: str, definition: dict[str, Any], out: list[str]) -> Non # Special carve-out for Result types: if name.endswith("Result"): - out.extend(f"impl From<{name}> for serde_json::Value {{\n") - out.append(f" fn from(value: {name}) -> Self {{\n") - out.append(" // Leave this as it should never fail\n") - out.append(" #[expect(clippy::unwrap_used)]\n") - out.append(" serde_json::to_value(value).unwrap()\n") - out.append(" }\n") - out.append("}\n\n") + append_result_value_impl(name, out) + return + + all_of = definition.get("allOf", []) + if all_of: + assert isinstance(all_of, list) + merged_properties: dict[str, Any] = {} + merged_required: set[str] = set() + for item in all_of: + if "$ref" in item: + ref_name = type_from_ref(item["$ref"]) + item = DEFINITIONS[ref_name] + merged_properties.update(item.get("properties", {})) + merged_required.update(item.get("required", [])) + + out.extend(define_struct(name, merged_properties, merged_required, description)) + + if name.endswith("Result"): + append_result_value_impl(name, out) return enum_values = definition.get("enum", []) @@ -333,6 +346,16 @@ def add_definition(name: str, definition: dict[str, Any], out: list[str]) -> Non extra_defs = [] +def append_result_value_impl(name: str, out: list[str]) -> None: + out.extend(f"impl From<{name}> for serde_json::Value {{\n") + out.append(f" fn from(value: {name}) -> Self {{\n") + out.append(" // Leave this as it should never fail\n") + out.append(" #[expect(clippy::unwrap_used)]\n") + out.append(" serde_json::to_value(value).unwrap()\n") + out.append(" }\n") + out.append("}\n\n") + + @dataclass class StructField: viz: Literal["pub"] | Literal["const"] @@ -384,10 +407,7 @@ def define_struct( fields: list[StructField] = [] for prop_name, prop in properties.items(): - if prop_name == "_meta": - # TODO? - continue - elif prop_name == "jsonrpc": + if prop_name == "jsonrpc": fields.append( StructField( "pub", @@ -400,6 +420,10 @@ def define_struct( prop_type = map_type(prop, prop_name, name) is_optional = prop_name not in required_props + if is_optional and prop_type.startswith("&'static str"): + # Optional `const` schema properties cannot be represented as a Rust + # associated const, so store them as optional strings. + prop_type = "String" if is_optional: prop_type = f"Option<{prop_type}>" rs_prop = rust_prop_name(prop_name, is_optional) @@ -539,8 +563,7 @@ def define_any_of(name: str, list_of_refs: list[Any], description: str | None = full `…Request` struct from the schema definition. """ - # Verify each item in list_of_refs is a dict with a $ref key. - refs = [item["$ref"] for item in list_of_refs if isinstance(item, dict)] + refs = [item["$ref"] for item in list_of_refs if isinstance(item, dict) and "$ref" in item] out: list[str] = [] if description: @@ -555,54 +578,67 @@ def define_any_of(name: str, list_of_refs: list[Any], description: str | None = out.append(f"pub enum {name} {{\n") if name == "ClientRequest": + if len(refs) != len(list_of_refs): + raise ValueError("ClientRequest anyOf must contain only $ref items.") # Record the set of request type names so we can later generate a # `TryFrom` implementation. global CLIENT_REQUEST_TYPE_NAMES CLIENT_REQUEST_TYPE_NAMES = [type_from_ref(r) for r in refs] if name == "ServerNotification": + if len(refs) != len(list_of_refs): + raise ValueError("ServerNotification anyOf must contain only $ref items.") global SERVER_NOTIFICATION_TYPE_NAMES SERVER_NOTIFICATION_TYPE_NAMES = [type_from_ref(r) for r in refs] - for ref in refs: - ref_name = type_from_ref(ref) + for idx, item in enumerate(list_of_refs): + if not isinstance(item, dict): + raise ValueError(f"Unexpected anyOf item for {name}: {item}") - # For JSONRPCMessage variants, drop the common "JSONRPC" prefix to - # make the enum easier to read (e.g. `Request` instead of - # `JSONRPCRequest`). The payload type remains unchanged. - variant_name = ( - ref_name[len("JSONRPC") :] - if name == "JSONRPCMessage" and ref_name.startswith("JSONRPC") - else ref_name - ) + ref = item.get("$ref") + if ref: + ref_name = type_from_ref(ref) - # Special-case for `ClientRequest` and `ServerNotification` so the enum - # variant's payload is the *Params type rather than the full *Request / - # *Notification marker type. - if name in ("ClientRequest", "ServerNotification"): - # Rely on the trait implementation to tell us the exact Rust type - # of the `params` payload. This guarantees we stay in sync with any - # special-case logic used elsewhere (e.g. objects with - # `additionalProperties` mapping to `serde_json::Value`). - if name == "ClientRequest": - payload_type = f"<{ref_name} as ModelContextProtocolRequest>::Params" - else: - payload_type = f"<{ref_name} as ModelContextProtocolNotification>::Params" - - # Determine the wire value for `method` so we can annotate the - # variant appropriately. If for some reason the schema does not - # specify a constant we fall back to the type name, which will at - # least compile (although deserialization will likely fail). - request_def = DEFINITIONS.get(ref_name, {}) - method_const = ( - request_def.get("properties", {}).get("method", {}).get("const", ref_name) + # For JSONRPCMessage variants, drop the common "JSONRPC" prefix to + # make the enum easier to read (e.g. `Request` instead of + # `JSONRPCRequest`). The payload type remains unchanged. + variant_name = ( + ref_name[len("JSONRPC") :] + if name == "JSONRPCMessage" and ref_name.startswith("JSONRPC") + else ref_name ) - out.append(f' #[serde(rename = "{method_const}")]\n') - out.append(f" {variant_name}({payload_type}),\n") - else: - # The regular/straight-forward case. - out.append(f" {variant_name}({ref_name}),\n") + # Special-case for `ClientRequest` and `ServerNotification` so the enum + # variant's payload is the *Params type rather than the full *Request / + # *Notification marker type. + if name in ("ClientRequest", "ServerNotification"): + # Rely on the trait implementation to tell us the exact Rust type + # of the `params` payload. This guarantees we stay in sync with any + # special-case logic used elsewhere (e.g. objects with + # `additionalProperties` mapping to `serde_json::Value`). + if name == "ClientRequest": + payload_type = f"<{ref_name} as ModelContextProtocolRequest>::Params" + else: + payload_type = f"<{ref_name} as ModelContextProtocolNotification>::Params" + + # Determine the wire value for `method` so we can annotate the + # variant appropriately. If for some reason the schema does not + # specify a constant we fall back to the type name, which will at + # least compile (although deserialization will likely fail). + request_def = DEFINITIONS.get(ref_name, {}) + method_const = ( + request_def.get("properties", {}).get("method", {}).get("const", ref_name) + ) + + out.append(f' #[serde(rename = "{method_const}")]\n') + out.append(f" {variant_name}({payload_type}),\n") + else: + # The regular/straight-forward case. + out.append(f" {variant_name}({ref_name}),\n") + continue + + inline_type = map_type(item, f"variant_{idx}", name) + out.append(f" Variant{idx}({inline_type}),\n") out.append("}\n\n") return out @@ -704,6 +740,11 @@ def rust_prop_name(name: str, is_optional: bool) -> RustProp: is_rename = False if name == "type": prop_name = "r#type" + elif name == "$schema": + prop_name = "schema" + is_rename = True + elif name == "const": + prop_name = "r#const" elif name == "ref": prop_name = "r#ref" elif name == "enum": @@ -758,9 +799,20 @@ def check_string_list(value: Any) -> list[str] | None: return value +def get_schema_definitions(schema_json: dict[str, Any]) -> dict[str, Any]: + """Return the schema definitions map across supported JSON Schema drafts.""" + definitions = schema_json.get("definitions") + if definitions is None: + definitions = schema_json.get("$defs") + if isinstance(definitions, dict): + return definitions + raise KeyError("Schema is missing a definitions map (`definitions` or `$defs`).") + + def type_from_ref(ref: str) -> str: """Convert a JSON reference to a Rust type.""" - assert ref.startswith("#/definitions/") + if not (ref.startswith("#/definitions/") or ref.startswith("#/$defs/")): + raise ValueError(f"Unsupported $ref format: {ref}") return ref.split("/")[-1] diff --git a/codex-rs/mcp-types/schema/2025-11-25/schema.json b/codex-rs/mcp-types/schema/2025-11-25/schema.json new file mode 100644 index 0000000000..17cdb3dbcc --- /dev/null +++ b/codex-rs/mcp-types/schema/2025-11-25/schema.json @@ -0,0 +1,4055 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "Annotations": { + "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", + "properties": { + "audience": { + "description": "Describes who the intended audience of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).", + "items": { + "$ref": "#/$defs/Role" + }, + "type": "array" + }, + "lastModified": { + "description": "The moment the resource was last modified, as an ISO 8601 formatted string.\n\nShould be an ISO 8601 formatted string (e.g., \"2025-01-12T15:00:58Z\").\n\nExamples: last activity timestamp in an open file, timestamp when the resource\nwas attached, etc.", + "type": "string" + }, + "priority": { + "description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.", + "maximum": 1, + "minimum": 0, + "type": "number" + } + }, + "type": "object" + }, + "AudioContent": { + "description": "Audio provided to or from an LLM.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "data": { + "description": "The base64-encoded audio data.", + "format": "byte", + "type": "string" + }, + "mimeType": { + "description": "The MIME type of the audio. Different providers may support different audio types.", + "type": "string" + }, + "type": { + "const": "audio", + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, + "BaseMetadata": { + "description": "Base interface for metadata with name (identifier) and title (display name) properties.", + "properties": { + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "BlobResourceContents": { + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "blob": { + "description": "A base64-encoded string representing the binary data of the item.", + "format": "byte", + "type": "string" + }, + "mimeType": { + "description": "The MIME type of this resource, if known.", + "type": "string" + }, + "uri": { + "description": "The URI of this resource.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "blob", + "uri" + ], + "type": "object" + }, + "BooleanSchema": { + "properties": { + "default": { + "type": "boolean" + }, + "description": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "const": "boolean", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "CallToolRequest": { + "description": "Used by the client to invoke a tool provided by the server.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "tools/call", + "type": "string" + }, + "params": { + "$ref": "#/$defs/CallToolRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "CallToolRequestParams": { + "description": "Parameters for a `tools/call` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "arguments": { + "additionalProperties": {}, + "description": "Arguments to use for the tool call.", + "type": "object" + }, + "name": { + "description": "The name of the tool.", + "type": "string" + }, + "task": { + "$ref": "#/$defs/TaskMetadata", + "description": "If specified, the caller is requesting task-augmented execution for this request.\nThe request will return a CreateTaskResult immediately, and the actual result can be\nretrieved later via tasks/result.\n\nTask augmentation is subject to capability negotiation - receivers MUST declare support\nfor task augmentation of specific request types in their capabilities." + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "CallToolResult": { + "description": "The server's response to a tool call.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "content": { + "description": "A list of content objects that represent the unstructured result of the tool call.", + "items": { + "$ref": "#/$defs/ContentBlock" + }, + "type": "array" + }, + "isError": { + "description": "Whether the tool call ended in an error.\n\nIf not set, this is assumed to be false (the call was successful).\n\nAny errors that originate from the tool SHOULD be reported inside the result\nobject, with `isError` set to true, _not_ as an MCP protocol-level error\nresponse. Otherwise, the LLM would not be able to see that an error occurred\nand self-correct.\n\nHowever, any errors in _finding_ the tool, an error indicating that the\nserver does not support tool calls, or any other exceptional conditions,\nshould be reported as an MCP error response.", + "type": "boolean" + }, + "structuredContent": { + "additionalProperties": {}, + "description": "An optional JSON object that represents the structured result of the tool call.", + "type": "object" + } + }, + "required": [ + "content" + ], + "type": "object" + }, + "CancelTaskRequest": { + "description": "A request to cancel a task.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "tasks/cancel", + "type": "string" + }, + "params": { + "properties": { + "taskId": { + "description": "The task identifier to cancel.", + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "CancelTaskResult": { + "allOf": [ + { + "$ref": "#/$defs/Result" + }, + { + "$ref": "#/$defs/Task" + } + ], + "description": "The response to a tasks/cancel request." + }, + "CancelledNotification": { + "description": "This notification can be sent by either side to indicate that it is cancelling a previously-issued request.\n\nThe request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.\n\nThis notification indicates that the result will be unused, so any associated processing SHOULD cease.\n\nA client MUST NOT attempt to cancel its `initialize` request.\n\nFor task cancellation, use the `tasks/cancel` request instead of this notification.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/cancelled", + "type": "string" + }, + "params": { + "$ref": "#/$defs/CancelledNotificationParams" + } + }, + "required": [ + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "CancelledNotificationParams": { + "description": "Parameters for a `notifications/cancelled` notification.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "reason": { + "description": "An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.", + "type": "string" + }, + "requestId": { + "$ref": "#/$defs/RequestId", + "description": "The ID of the request to cancel.\n\nThis MUST correspond to the ID of a request previously issued in the same direction.\nThis MUST be provided for cancelling non-task requests.\nThis MUST NOT be used for cancelling tasks (use the `tasks/cancel` request instead)." + } + }, + "type": "object" + }, + "ClientCapabilities": { + "description": "Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.", + "properties": { + "elicitation": { + "description": "Present if the client supports elicitation from the server.", + "properties": { + "form": { + "additionalProperties": true, + "properties": {}, + "type": "object" + }, + "url": { + "additionalProperties": true, + "properties": {}, + "type": "object" + } + }, + "type": "object" + }, + "experimental": { + "additionalProperties": { + "additionalProperties": true, + "properties": {}, + "type": "object" + }, + "description": "Experimental, non-standard capabilities that the client supports.", + "type": "object" + }, + "roots": { + "description": "Present if the client supports listing roots.", + "properties": { + "listChanged": { + "description": "Whether the client supports notifications for changes to the roots list.", + "type": "boolean" + } + }, + "type": "object" + }, + "sampling": { + "description": "Present if the client supports sampling from an LLM.", + "properties": { + "context": { + "additionalProperties": true, + "description": "Whether the client supports context inclusion via includeContext parameter.\nIf not declared, servers SHOULD only use `includeContext: \"none\"` (or omit it).", + "properties": {}, + "type": "object" + }, + "tools": { + "additionalProperties": true, + "description": "Whether the client supports tool use via tools and toolChoice parameters.", + "properties": {}, + "type": "object" + } + }, + "type": "object" + }, + "tasks": { + "description": "Present if the client supports task-augmented requests.", + "properties": { + "cancel": { + "additionalProperties": true, + "description": "Whether this client supports tasks/cancel.", + "properties": {}, + "type": "object" + }, + "list": { + "additionalProperties": true, + "description": "Whether this client supports tasks/list.", + "properties": {}, + "type": "object" + }, + "requests": { + "description": "Specifies which request types can be augmented with tasks.", + "properties": { + "elicitation": { + "description": "Task support for elicitation-related requests.", + "properties": { + "create": { + "additionalProperties": true, + "description": "Whether the client supports task-augmented elicitation/create requests.", + "properties": {}, + "type": "object" + } + }, + "type": "object" + }, + "sampling": { + "description": "Task support for sampling-related requests.", + "properties": { + "createMessage": { + "additionalProperties": true, + "description": "Whether the client supports task-augmented sampling/createMessage requests.", + "properties": {}, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "ClientNotification": { + "anyOf": [ + { + "$ref": "#/$defs/CancelledNotification" + }, + { + "$ref": "#/$defs/InitializedNotification" + }, + { + "$ref": "#/$defs/ProgressNotification" + }, + { + "$ref": "#/$defs/TaskStatusNotification" + }, + { + "$ref": "#/$defs/RootsListChangedNotification" + } + ] + }, + "ClientRequest": { + "anyOf": [ + { + "$ref": "#/$defs/InitializeRequest" + }, + { + "$ref": "#/$defs/PingRequest" + }, + { + "$ref": "#/$defs/ListResourcesRequest" + }, + { + "$ref": "#/$defs/ListResourceTemplatesRequest" + }, + { + "$ref": "#/$defs/ReadResourceRequest" + }, + { + "$ref": "#/$defs/SubscribeRequest" + }, + { + "$ref": "#/$defs/UnsubscribeRequest" + }, + { + "$ref": "#/$defs/ListPromptsRequest" + }, + { + "$ref": "#/$defs/GetPromptRequest" + }, + { + "$ref": "#/$defs/ListToolsRequest" + }, + { + "$ref": "#/$defs/CallToolRequest" + }, + { + "$ref": "#/$defs/GetTaskRequest" + }, + { + "$ref": "#/$defs/GetTaskPayloadRequest" + }, + { + "$ref": "#/$defs/CancelTaskRequest" + }, + { + "$ref": "#/$defs/ListTasksRequest" + }, + { + "$ref": "#/$defs/SetLevelRequest" + }, + { + "$ref": "#/$defs/CompleteRequest" + } + ] + }, + "ClientResult": { + "anyOf": [ + { + "$ref": "#/$defs/Result" + }, + { + "$ref": "#/$defs/GetTaskResult", + "description": "The response to a tasks/get request." + }, + { + "$ref": "#/$defs/GetTaskPayloadResult" + }, + { + "$ref": "#/$defs/CancelTaskResult", + "description": "The response to a tasks/cancel request." + }, + { + "$ref": "#/$defs/ListTasksResult" + }, + { + "$ref": "#/$defs/CreateMessageResult" + }, + { + "$ref": "#/$defs/ListRootsResult" + }, + { + "$ref": "#/$defs/ElicitResult" + } + ] + }, + "CompleteRequest": { + "description": "A request from the client to the server, to ask for completion options.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "completion/complete", + "type": "string" + }, + "params": { + "$ref": "#/$defs/CompleteRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "CompleteRequestParams": { + "description": "Parameters for a `completion/complete` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "argument": { + "description": "The argument's information", + "properties": { + "name": { + "description": "The name of the argument", + "type": "string" + }, + "value": { + "description": "The value of the argument to use for completion matching.", + "type": "string" + } + }, + "required": [ + "name", + "value" + ], + "type": "object" + }, + "context": { + "description": "Additional, optional context for completions", + "properties": { + "arguments": { + "additionalProperties": { + "type": "string" + }, + "description": "Previously-resolved variables in a URI template or prompt.", + "type": "object" + } + }, + "type": "object" + }, + "ref": { + "anyOf": [ + { + "$ref": "#/$defs/PromptReference" + }, + { + "$ref": "#/$defs/ResourceTemplateReference" + } + ] + } + }, + "required": [ + "argument", + "ref" + ], + "type": "object" + }, + "CompleteResult": { + "description": "The server's response to a completion/complete request", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "completion": { + "properties": { + "hasMore": { + "description": "Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.", + "type": "boolean" + }, + "total": { + "description": "The total number of completion options available. This can exceed the number of values actually sent in the response.", + "type": "integer" + }, + "values": { + "description": "An array of completion values. Must not exceed 100 items.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "values" + ], + "type": "object" + } + }, + "required": [ + "completion" + ], + "type": "object" + }, + "ContentBlock": { + "anyOf": [ + { + "$ref": "#/$defs/TextContent" + }, + { + "$ref": "#/$defs/ImageContent" + }, + { + "$ref": "#/$defs/AudioContent" + }, + { + "$ref": "#/$defs/ResourceLink" + }, + { + "$ref": "#/$defs/EmbeddedResource" + } + ] + }, + "CreateMessageRequest": { + "description": "A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "sampling/createMessage", + "type": "string" + }, + "params": { + "$ref": "#/$defs/CreateMessageRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "CreateMessageRequestParams": { + "description": "Parameters for a `sampling/createMessage` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "includeContext": { + "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.\nThe client MAY ignore this request.\n\nDefault is \"none\". Values \"thisServer\" and \"allServers\" are soft-deprecated. Servers SHOULD only use these values if the client\ndeclares ClientCapabilities.sampling.context. These values may be removed in future spec releases.", + "enum": [ + "allServers", + "none", + "thisServer" + ], + "type": "string" + }, + "maxTokens": { + "description": "The requested maximum number of tokens to sample (to prevent runaway completions).\n\nThe client MAY choose to sample fewer tokens than the requested maximum.", + "type": "integer" + }, + "messages": { + "items": { + "$ref": "#/$defs/SamplingMessage" + }, + "type": "array" + }, + "metadata": { + "additionalProperties": true, + "description": "Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.", + "properties": {}, + "type": "object" + }, + "modelPreferences": { + "$ref": "#/$defs/ModelPreferences", + "description": "The server's preferences for which model to select. The client MAY ignore these preferences." + }, + "stopSequences": { + "items": { + "type": "string" + }, + "type": "array" + }, + "systemPrompt": { + "description": "An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.", + "type": "string" + }, + "task": { + "$ref": "#/$defs/TaskMetadata", + "description": "If specified, the caller is requesting task-augmented execution for this request.\nThe request will return a CreateTaskResult immediately, and the actual result can be\nretrieved later via tasks/result.\n\nTask augmentation is subject to capability negotiation - receivers MUST declare support\nfor task augmentation of specific request types in their capabilities." + }, + "temperature": { + "type": "number" + }, + "toolChoice": { + "$ref": "#/$defs/ToolChoice", + "description": "Controls how the model uses tools.\nThe client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.\nDefault is `{ mode: \"auto\" }`." + }, + "tools": { + "description": "Tools that the model may use during generation.\nThe client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.", + "items": { + "$ref": "#/$defs/Tool" + }, + "type": "array" + } + }, + "required": [ + "maxTokens", + "messages" + ], + "type": "object" + }, + "CreateMessageResult": { + "description": "The client's response to a sampling/createMessage request from the server.\nThe client should inform the user before returning the sampled message, to allow them\nto inspect the response (human in the loop) and decide whether to allow the server to see it.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "content": { + "anyOf": [ + { + "$ref": "#/$defs/TextContent" + }, + { + "$ref": "#/$defs/ImageContent" + }, + { + "$ref": "#/$defs/AudioContent" + }, + { + "$ref": "#/$defs/ToolUseContent" + }, + { + "$ref": "#/$defs/ToolResultContent" + }, + { + "items": { + "$ref": "#/$defs/SamplingMessageContentBlock" + }, + "type": "array" + } + ] + }, + "model": { + "description": "The name of the model that generated the message.", + "type": "string" + }, + "role": { + "$ref": "#/$defs/Role" + }, + "stopReason": { + "description": "The reason why sampling stopped, if known.\n\nStandard values:\n- \"endTurn\": Natural end of the assistant's turn\n- \"stopSequence\": A stop sequence was encountered\n- \"maxTokens\": Maximum token limit was reached\n- \"toolUse\": The model wants to use one or more tools\n\nThis field is an open string to allow for provider-specific stop reasons.", + "type": "string" + } + }, + "required": [ + "content", + "model", + "role" + ], + "type": "object" + }, + "CreateTaskResult": { + "description": "A response to a task-augmented request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "task": { + "$ref": "#/$defs/Task" + } + }, + "required": [ + "task" + ], + "type": "object" + }, + "Cursor": { + "description": "An opaque token used to represent a cursor for pagination.", + "type": "string" + }, + "ElicitRequest": { + "description": "A request from the server to elicit additional information from the user via the client.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "elicitation/create", + "type": "string" + }, + "params": { + "$ref": "#/$defs/ElicitRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "ElicitRequestFormParams": { + "description": "The parameters for a request to elicit non-sensitive information from the user via a form in the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "message": { + "description": "The message to present to the user describing what information is being requested.", + "type": "string" + }, + "mode": { + "const": "form", + "description": "The elicitation mode.", + "type": "string" + }, + "requestedSchema": { + "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", + "properties": { + "$schema": { + "type": "string" + }, + "properties": { + "additionalProperties": { + "$ref": "#/$defs/PrimitiveSchemaDefinition" + }, + "type": "object" + }, + "required": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "const": "object", + "type": "string" + } + }, + "required": [ + "properties", + "type" + ], + "type": "object" + }, + "task": { + "$ref": "#/$defs/TaskMetadata", + "description": "If specified, the caller is requesting task-augmented execution for this request.\nThe request will return a CreateTaskResult immediately, and the actual result can be\nretrieved later via tasks/result.\n\nTask augmentation is subject to capability negotiation - receivers MUST declare support\nfor task augmentation of specific request types in their capabilities." + } + }, + "required": [ + "message", + "requestedSchema" + ], + "type": "object" + }, + "ElicitRequestParams": { + "anyOf": [ + { + "$ref": "#/$defs/ElicitRequestURLParams" + }, + { + "$ref": "#/$defs/ElicitRequestFormParams" + } + ], + "description": "The parameters for a request to elicit additional information from the user via the client." + }, + "ElicitRequestURLParams": { + "description": "The parameters for a request to elicit information from the user via a URL in the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "elicitationId": { + "description": "The ID of the elicitation, which must be unique within the context of the server.\nThe client MUST treat this ID as an opaque value.", + "type": "string" + }, + "message": { + "description": "The message to present to the user explaining why the interaction is needed.", + "type": "string" + }, + "mode": { + "const": "url", + "description": "The elicitation mode.", + "type": "string" + }, + "task": { + "$ref": "#/$defs/TaskMetadata", + "description": "If specified, the caller is requesting task-augmented execution for this request.\nThe request will return a CreateTaskResult immediately, and the actual result can be\nretrieved later via tasks/result.\n\nTask augmentation is subject to capability negotiation - receivers MUST declare support\nfor task augmentation of specific request types in their capabilities." + }, + "url": { + "description": "The URL that the user should navigate to.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "elicitationId", + "message", + "mode", + "url" + ], + "type": "object" + }, + "ElicitResult": { + "description": "The client's response to an elicitation request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "action": { + "description": "The user action in response to the elicitation.\n- \"accept\": User submitted the form/confirmed the action\n- \"decline\": User explicitly decline the action\n- \"cancel\": User dismissed without making an explicit choice", + "enum": [ + "accept", + "cancel", + "decline" + ], + "type": "string" + }, + "content": { + "additionalProperties": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": [ + "string", + "integer", + "boolean" + ] + } + ] + }, + "description": "The submitted form data, only present when action is \"accept\" and mode was \"form\".\nContains values matching the requested schema.\nOmitted for out-of-band mode responses.", + "type": "object" + } + }, + "required": [ + "action" + ], + "type": "object" + }, + "ElicitationCompleteNotification": { + "description": "An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/elicitation/complete", + "type": "string" + }, + "params": { + "properties": { + "elicitationId": { + "description": "The ID of the elicitation that completed.", + "type": "string" + } + }, + "required": [ + "elicitationId" + ], + "type": "object" + } + }, + "required": [ + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "EmbeddedResource": { + "description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit\nof the LLM and/or the user.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "resource": { + "anyOf": [ + { + "$ref": "#/$defs/TextResourceContents" + }, + { + "$ref": "#/$defs/BlobResourceContents" + } + ] + }, + "type": { + "const": "resource", + "type": "string" + } + }, + "required": [ + "resource", + "type" + ], + "type": "object" + }, + "EmptyResult": { + "$ref": "#/$defs/Result" + }, + "EnumSchema": { + "anyOf": [ + { + "$ref": "#/$defs/UntitledSingleSelectEnumSchema" + }, + { + "$ref": "#/$defs/TitledSingleSelectEnumSchema" + }, + { + "$ref": "#/$defs/UntitledMultiSelectEnumSchema" + }, + { + "$ref": "#/$defs/TitledMultiSelectEnumSchema" + }, + { + "$ref": "#/$defs/LegacyTitledEnumSchema" + } + ] + }, + "Error": { + "properties": { + "code": { + "description": "The error type that occurred.", + "type": "integer" + }, + "data": { + "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." + }, + "message": { + "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "type": "object" + }, + "GetPromptRequest": { + "description": "Used by the client to get a prompt provided by the server.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "prompts/get", + "type": "string" + }, + "params": { + "$ref": "#/$defs/GetPromptRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "GetPromptRequestParams": { + "description": "Parameters for a `prompts/get` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "arguments": { + "additionalProperties": { + "type": "string" + }, + "description": "Arguments to use for templating the prompt.", + "type": "object" + }, + "name": { + "description": "The name of the prompt or prompt template.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "GetPromptResult": { + "description": "The server's response to a prompts/get request from the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "description": { + "description": "An optional description for the prompt.", + "type": "string" + }, + "messages": { + "items": { + "$ref": "#/$defs/PromptMessage" + }, + "type": "array" + } + }, + "required": [ + "messages" + ], + "type": "object" + }, + "GetTaskPayloadRequest": { + "description": "A request to retrieve the result of a completed task.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "tasks/result", + "type": "string" + }, + "params": { + "properties": { + "taskId": { + "description": "The task identifier to retrieve results for.", + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "GetTaskPayloadResult": { + "additionalProperties": {}, + "description": "The response to a tasks/result request.\nThe structure matches the result type of the original request.\nFor example, a tools/call task would return the CallToolResult structure.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + } + }, + "type": "object" + }, + "GetTaskRequest": { + "description": "A request to retrieve the state of a task.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "tasks/get", + "type": "string" + }, + "params": { + "properties": { + "taskId": { + "description": "The task identifier to query.", + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "GetTaskResult": { + "allOf": [ + { + "$ref": "#/$defs/Result" + }, + { + "$ref": "#/$defs/Task" + } + ], + "description": "The response to a tasks/get request." + }, + "Icon": { + "description": "An optionally-sized icon that can be displayed in a user interface.", + "properties": { + "mimeType": { + "description": "Optional MIME type override if the source MIME type is missing or generic.\nFor example: `\"image/png\"`, `\"image/jpeg\"`, or `\"image/svg+xml\"`.", + "type": "string" + }, + "sizes": { + "description": "Optional array of strings that specify sizes at which the icon can be used.\nEach string should be in WxH format (e.g., `\"48x48\"`, `\"96x96\"`) or `\"any\"` for scalable formats like SVG.\n\nIf not provided, the client should assume that the icon can be used at any size.", + "items": { + "type": "string" + }, + "type": "array" + }, + "src": { + "description": "A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a\n`data:` URI with Base64-encoded image data.\n\nConsumers SHOULD takes steps to ensure URLs serving icons are from the\nsame domain as the client/server or a trusted domain.\n\nConsumers SHOULD take appropriate precautions when consuming SVGs as they can contain\nexecutable JavaScript.", + "format": "uri", + "type": "string" + }, + "theme": { + "description": "Optional specifier for the theme this icon is designed for. `light` indicates\nthe icon is designed to be used with a light background, and `dark` indicates\nthe icon is designed to be used with a dark background.\n\nIf not provided, the client should assume the icon can be used with any theme.", + "enum": [ + "dark", + "light" + ], + "type": "string" + } + }, + "required": [ + "src" + ], + "type": "object" + }, + "Icons": { + "description": "Base interface to add `icons` property.", + "properties": { + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + } + }, + "type": "object" + }, + "ImageContent": { + "description": "An image provided to or from an LLM.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "data": { + "description": "The base64-encoded image data.", + "format": "byte", + "type": "string" + }, + "mimeType": { + "description": "The MIME type of the image. Different providers may support different image types.", + "type": "string" + }, + "type": { + "const": "image", + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, + "Implementation": { + "description": "Describes the MCP implementation.", + "properties": { + "description": { + "description": "An optional human-readable description of what this implementation does.\n\nThis can be used by clients or servers to provide context about their purpose\nand capabilities. For example, a server might describe the types of resources\nor tools it provides, while a client might describe its intended use case.", + "type": "string" + }, + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + }, + "version": { + "type": "string" + }, + "websiteUrl": { + "description": "An optional URL of the website for this implementation.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "name", + "version" + ], + "type": "object" + }, + "InitializeRequest": { + "description": "This request is sent from the client to the server when it first connects, asking it to begin initialization.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "initialize", + "type": "string" + }, + "params": { + "$ref": "#/$defs/InitializeRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "InitializeRequestParams": { + "description": "Parameters for an `initialize` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "capabilities": { + "$ref": "#/$defs/ClientCapabilities" + }, + "clientInfo": { + "$ref": "#/$defs/Implementation" + }, + "protocolVersion": { + "description": "The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.", + "type": "string" + } + }, + "required": [ + "capabilities", + "clientInfo", + "protocolVersion" + ], + "type": "object" + }, + "InitializeResult": { + "description": "After receiving an initialize request from the client, the server sends this response.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "capabilities": { + "$ref": "#/$defs/ServerCapabilities" + }, + "instructions": { + "description": "Instructions describing how to use the server and its features.\n\nThis can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a \"hint\" to the model. For example, this information MAY be added to the system prompt.", + "type": "string" + }, + "protocolVersion": { + "description": "The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.", + "type": "string" + }, + "serverInfo": { + "$ref": "#/$defs/Implementation" + } + }, + "required": [ + "capabilities", + "protocolVersion", + "serverInfo" + ], + "type": "object" + }, + "InitializedNotification": { + "description": "This notification is sent from the client to the server after initialization has finished.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/initialized", + "type": "string" + }, + "params": { + "$ref": "#/$defs/NotificationParams" + } + }, + "required": [ + "jsonrpc", + "method" + ], + "type": "object" + }, + "JSONRPCErrorResponse": { + "description": "A response to a request that indicates an error occurred.", + "properties": { + "error": { + "$ref": "#/$defs/Error" + }, + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + } + }, + "required": [ + "error", + "jsonrpc" + ], + "type": "object" + }, + "JSONRPCMessage": { + "anyOf": [ + { + "$ref": "#/$defs/JSONRPCRequest" + }, + { + "$ref": "#/$defs/JSONRPCNotification" + }, + { + "$ref": "#/$defs/JSONRPCResultResponse" + }, + { + "$ref": "#/$defs/JSONRPCErrorResponse" + } + ], + "description": "Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent." + }, + "JSONRPCNotification": { + "description": "A notification which does not expect a response.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "type": "string" + }, + "params": { + "additionalProperties": {}, + "type": "object" + } + }, + "required": [ + "jsonrpc", + "method" + ], + "type": "object" + }, + "JSONRPCRequest": { + "description": "A request that expects a response.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "type": "string" + }, + "params": { + "additionalProperties": {}, + "type": "object" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "JSONRPCResponse": { + "anyOf": [ + { + "$ref": "#/$defs/JSONRPCResultResponse" + }, + { + "$ref": "#/$defs/JSONRPCErrorResponse" + } + ], + "description": "A response to a request, containing either the result or error." + }, + "JSONRPCResultResponse": { + "description": "A successful (non-error) response to a request.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "result": { + "$ref": "#/$defs/Result" + } + }, + "required": [ + "id", + "jsonrpc", + "result" + ], + "type": "object" + }, + "LegacyTitledEnumSchema": { + "description": "Use TitledSingleSelectEnumSchema instead.\nThis interface will be removed in a future version.", + "properties": { + "default": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enum": { + "items": { + "type": "string" + }, + "type": "array" + }, + "enumNames": { + "description": "(Legacy) Display names for enum values.\nNon-standard according to JSON schema 2020-12.", + "items": { + "type": "string" + }, + "type": "array" + }, + "title": { + "type": "string" + }, + "type": { + "const": "string", + "type": "string" + } + }, + "required": [ + "enum", + "type" + ], + "type": "object" + }, + "ListPromptsRequest": { + "description": "Sent from the client to request a list of prompts and prompt templates the server has.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "prompts/list", + "type": "string" + }, + "params": { + "$ref": "#/$defs/PaginatedRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "ListPromptsResult": { + "description": "The server's response to a prompts/list request from the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "nextCursor": { + "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", + "type": "string" + }, + "prompts": { + "items": { + "$ref": "#/$defs/Prompt" + }, + "type": "array" + } + }, + "required": [ + "prompts" + ], + "type": "object" + }, + "ListResourceTemplatesRequest": { + "description": "Sent from the client to request a list of resource templates the server has.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "resources/templates/list", + "type": "string" + }, + "params": { + "$ref": "#/$defs/PaginatedRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "ListResourceTemplatesResult": { + "description": "The server's response to a resources/templates/list request from the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "nextCursor": { + "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", + "type": "string" + }, + "resourceTemplates": { + "items": { + "$ref": "#/$defs/ResourceTemplate" + }, + "type": "array" + } + }, + "required": [ + "resourceTemplates" + ], + "type": "object" + }, + "ListResourcesRequest": { + "description": "Sent from the client to request a list of resources the server has.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "resources/list", + "type": "string" + }, + "params": { + "$ref": "#/$defs/PaginatedRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "ListResourcesResult": { + "description": "The server's response to a resources/list request from the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "nextCursor": { + "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", + "type": "string" + }, + "resources": { + "items": { + "$ref": "#/$defs/Resource" + }, + "type": "array" + } + }, + "required": [ + "resources" + ], + "type": "object" + }, + "ListRootsRequest": { + "description": "Sent from the server to request a list of root URIs from the client. Roots allow\nservers to ask for specific directories or files to operate on. A common example\nfor roots is providing a set of repositories or directories a server should operate\non.\n\nThis request is typically used when the server needs to understand the file system\nstructure or access specific locations that the client has permission to read from.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "roots/list", + "type": "string" + }, + "params": { + "$ref": "#/$defs/RequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "ListRootsResult": { + "description": "The client's response to a roots/list request from the server.\nThis result contains an array of Root objects, each representing a root directory\nor file that the server can operate on.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "roots": { + "items": { + "$ref": "#/$defs/Root" + }, + "type": "array" + } + }, + "required": [ + "roots" + ], + "type": "object" + }, + "ListTasksRequest": { + "description": "A request to retrieve a list of tasks.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "tasks/list", + "type": "string" + }, + "params": { + "$ref": "#/$defs/PaginatedRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "ListTasksResult": { + "description": "The response to a tasks/list request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "nextCursor": { + "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", + "type": "string" + }, + "tasks": { + "items": { + "$ref": "#/$defs/Task" + }, + "type": "array" + } + }, + "required": [ + "tasks" + ], + "type": "object" + }, + "ListToolsRequest": { + "description": "Sent from the client to request a list of tools the server has.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "tools/list", + "type": "string" + }, + "params": { + "$ref": "#/$defs/PaginatedRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "ListToolsResult": { + "description": "The server's response to a tools/list request from the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "nextCursor": { + "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", + "type": "string" + }, + "tools": { + "items": { + "$ref": "#/$defs/Tool" + }, + "type": "array" + } + }, + "required": [ + "tools" + ], + "type": "object" + }, + "LoggingLevel": { + "description": "The severity of a log message.\n\nThese map to syslog message severities, as specified in RFC-5424:\nhttps://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1", + "enum": [ + "alert", + "critical", + "debug", + "emergency", + "error", + "info", + "notice", + "warning" + ], + "type": "string" + }, + "LoggingMessageNotification": { + "description": "JSONRPCNotification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/message", + "type": "string" + }, + "params": { + "$ref": "#/$defs/LoggingMessageNotificationParams" + } + }, + "required": [ + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "LoggingMessageNotificationParams": { + "description": "Parameters for a `notifications/message` notification.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "data": { + "description": "The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here." + }, + "level": { + "$ref": "#/$defs/LoggingLevel", + "description": "The severity of this log message." + }, + "logger": { + "description": "An optional name of the logger issuing this message.", + "type": "string" + } + }, + "required": [ + "data", + "level" + ], + "type": "object" + }, + "ModelHint": { + "description": "Hints to use for model selection.\n\nKeys not declared here are currently left unspecified by the spec and are up\nto the client to interpret.", + "properties": { + "name": { + "description": "A hint for a model name.\n\nThe client SHOULD treat this as a substring of a model name; for example:\n - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`\n - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.\n - `claude` should match any Claude model\n\nThe client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example:\n - `gemini-1.5-flash` could match `claude-3-haiku-20240307`", + "type": "string" + } + }, + "type": "object" + }, + "ModelPreferences": { + "description": "The server's preferences for model selection, requested of the client during sampling.\n\nBecause LLMs can vary along multiple dimensions, choosing the \"best\" model is\nrarely straightforward. Different models excel in different areas—some are\nfaster but less capable, others are more capable but more expensive, and so\non. This interface allows servers to express their priorities across multiple\ndimensions to help clients make an appropriate selection for their use case.\n\nThese preferences are always advisory. The client MAY ignore them. It is also\nup to the client to decide how to interpret these preferences and how to\nbalance them against other considerations.", + "properties": { + "costPriority": { + "description": "How much to prioritize cost when selecting a model. A value of 0 means cost\nis not important, while a value of 1 means cost is the most important\nfactor.", + "maximum": 1, + "minimum": 0, + "type": "number" + }, + "hints": { + "description": "Optional hints to use for model selection.\n\nIf multiple hints are specified, the client MUST evaluate them in order\n(such that the first match is taken).\n\nThe client SHOULD prioritize these hints over the numeric priorities, but\nMAY still use the priorities to select from ambiguous matches.", + "items": { + "$ref": "#/$defs/ModelHint" + }, + "type": "array" + }, + "intelligencePriority": { + "description": "How much to prioritize intelligence and capabilities when selecting a\nmodel. A value of 0 means intelligence is not important, while a value of 1\nmeans intelligence is the most important factor.", + "maximum": 1, + "minimum": 0, + "type": "number" + }, + "speedPriority": { + "description": "How much to prioritize sampling speed (latency) when selecting a model. A\nvalue of 0 means speed is not important, while a value of 1 means speed is\nthe most important factor.", + "maximum": 1, + "minimum": 0, + "type": "number" + } + }, + "type": "object" + }, + "MultiSelectEnumSchema": { + "anyOf": [ + { + "$ref": "#/$defs/UntitledMultiSelectEnumSchema" + }, + { + "$ref": "#/$defs/TitledMultiSelectEnumSchema" + } + ] + }, + "Notification": { + "properties": { + "method": { + "type": "string" + }, + "params": { + "additionalProperties": {}, + "type": "object" + } + }, + "required": [ + "method" + ], + "type": "object" + }, + "NotificationParams": { + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + } + }, + "type": "object" + }, + "NumberSchema": { + "properties": { + "default": { + "type": "integer" + }, + "description": { + "type": "string" + }, + "maximum": { + "type": "integer" + }, + "minimum": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "type": { + "enum": [ + "integer", + "number" + ], + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "PaginatedRequest": { + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "type": "string" + }, + "params": { + "$ref": "#/$defs/PaginatedRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "PaginatedRequestParams": { + "description": "Common parameters for paginated requests.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "cursor": { + "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", + "type": "string" + } + }, + "type": "object" + }, + "PaginatedResult": { + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "nextCursor": { + "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", + "type": "string" + } + }, + "type": "object" + }, + "PingRequest": { + "description": "A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "ping", + "type": "string" + }, + "params": { + "$ref": "#/$defs/RequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method" + ], + "type": "object" + }, + "PrimitiveSchemaDefinition": { + "anyOf": [ + { + "$ref": "#/$defs/StringSchema" + }, + { + "$ref": "#/$defs/NumberSchema" + }, + { + "$ref": "#/$defs/BooleanSchema" + }, + { + "$ref": "#/$defs/UntitledSingleSelectEnumSchema" + }, + { + "$ref": "#/$defs/TitledSingleSelectEnumSchema" + }, + { + "$ref": "#/$defs/UntitledMultiSelectEnumSchema" + }, + { + "$ref": "#/$defs/TitledMultiSelectEnumSchema" + }, + { + "$ref": "#/$defs/LegacyTitledEnumSchema" + } + ], + "description": "Restricted schema definitions that only allow primitive types\nwithout nested objects or arrays." + }, + "ProgressNotification": { + "description": "An out-of-band notification used to inform the receiver of a progress update for a long-running request.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/progress", + "type": "string" + }, + "params": { + "$ref": "#/$defs/ProgressNotificationParams" + } + }, + "required": [ + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "ProgressNotificationParams": { + "description": "Parameters for a `notifications/progress` notification.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "message": { + "description": "An optional message describing the current progress.", + "type": "string" + }, + "progress": { + "description": "The progress thus far. This should increase every time progress is made, even if the total is unknown.", + "type": "number" + }, + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "The progress token which was given in the initial request, used to associate this notification with the request that is proceeding." + }, + "total": { + "description": "Total number of items to process (or total progress required), if known.", + "type": "number" + } + }, + "required": [ + "progress", + "progressToken" + ], + "type": "object" + }, + "ProgressToken": { + "description": "A progress token, used to associate progress notifications with the original request.", + "type": [ + "string", + "integer" + ] + }, + "Prompt": { + "description": "A prompt or prompt template that the server offers.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "arguments": { + "description": "A list of arguments to use for templating the prompt.", + "items": { + "$ref": "#/$defs/PromptArgument" + }, + "type": "array" + }, + "description": { + "description": "An optional description of what this prompt provides", + "type": "string" + }, + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "PromptArgument": { + "description": "Describes an argument that a prompt can accept.", + "properties": { + "description": { + "description": "A human-readable description of the argument.", + "type": "string" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "required": { + "description": "Whether this argument must be provided.", + "type": "boolean" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "PromptListChangedNotification": { + "description": "An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/prompts/list_changed", + "type": "string" + }, + "params": { + "$ref": "#/$defs/NotificationParams" + } + }, + "required": [ + "jsonrpc", + "method" + ], + "type": "object" + }, + "PromptMessage": { + "description": "Describes a message returned as part of a prompt.\n\nThis is similar to `SamplingMessage`, but also supports the embedding of\nresources from the MCP server.", + "properties": { + "content": { + "$ref": "#/$defs/ContentBlock" + }, + "role": { + "$ref": "#/$defs/Role" + } + }, + "required": [ + "content", + "role" + ], + "type": "object" + }, + "PromptReference": { + "description": "Identifies a prompt.", + "properties": { + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + }, + "type": { + "const": "ref/prompt", + "type": "string" + } + }, + "required": [ + "name", + "type" + ], + "type": "object" + }, + "ReadResourceRequest": { + "description": "Sent from the client to the server, to read a specific resource URI.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "resources/read", + "type": "string" + }, + "params": { + "$ref": "#/$defs/ReadResourceRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "ReadResourceRequestParams": { + "description": "Parameters for a `resources/read` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "uri": { + "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "ReadResourceResult": { + "description": "The server's response to a resources/read request from the client.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "contents": { + "items": { + "anyOf": [ + { + "$ref": "#/$defs/TextResourceContents" + }, + { + "$ref": "#/$defs/BlobResourceContents" + } + ] + }, + "type": "array" + } + }, + "required": [ + "contents" + ], + "type": "object" + }, + "RelatedTaskMetadata": { + "description": "Metadata for associating messages with a task.\nInclude this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.", + "properties": { + "taskId": { + "description": "The task identifier this message is associated with.", + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + }, + "Request": { + "properties": { + "method": { + "type": "string" + }, + "params": { + "additionalProperties": {}, + "type": "object" + } + }, + "required": [ + "method" + ], + "type": "object" + }, + "RequestId": { + "description": "A uniquely identifying ID for a request in JSON-RPC.", + "type": [ + "string", + "integer" + ] + }, + "RequestParams": { + "description": "Common params for any request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + } + }, + "type": "object" + }, + "Resource": { + "description": "A known resource that the server is capable of reading.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "description": { + "description": "A description of what this resource represents.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.", + "type": "string" + }, + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + }, + "mimeType": { + "description": "The MIME type of this resource, if known.", + "type": "string" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "size": { + "description": "The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.\n\nThis can be used by Hosts to display file sizes and estimate context window usage.", + "type": "integer" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + }, + "uri": { + "description": "The URI of this resource.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "name", + "uri" + ], + "type": "object" + }, + "ResourceContents": { + "description": "The contents of a specific resource or sub-resource.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "mimeType": { + "description": "The MIME type of this resource, if known.", + "type": "string" + }, + "uri": { + "description": "The URI of this resource.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "ResourceLink": { + "description": "A resource that the server is capable of reading, included in a prompt or tool call result.\n\nNote: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "description": { + "description": "A description of what this resource represents.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.", + "type": "string" + }, + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + }, + "mimeType": { + "description": "The MIME type of this resource, if known.", + "type": "string" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "size": { + "description": "The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.\n\nThis can be used by Hosts to display file sizes and estimate context window usage.", + "type": "integer" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + }, + "type": { + "const": "resource_link", + "type": "string" + }, + "uri": { + "description": "The URI of this resource.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "name", + "type", + "uri" + ], + "type": "object" + }, + "ResourceListChangedNotification": { + "description": "An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/resources/list_changed", + "type": "string" + }, + "params": { + "$ref": "#/$defs/NotificationParams" + } + }, + "required": [ + "jsonrpc", + "method" + ], + "type": "object" + }, + "ResourceRequestParams": { + "description": "Common parameters when working with resources.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "uri": { + "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "ResourceTemplate": { + "description": "A template description for resources available on the server.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "description": { + "description": "A description of what this template is for.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.", + "type": "string" + }, + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + }, + "mimeType": { + "description": "The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.", + "type": "string" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + }, + "uriTemplate": { + "description": "A URI template (according to RFC 6570) that can be used to construct resource URIs.", + "format": "uri-template", + "type": "string" + } + }, + "required": [ + "name", + "uriTemplate" + ], + "type": "object" + }, + "ResourceTemplateReference": { + "description": "A reference to a resource or resource template definition.", + "properties": { + "type": { + "const": "ref/resource", + "type": "string" + }, + "uri": { + "description": "The URI or URI template of the resource.", + "format": "uri-template", + "type": "string" + } + }, + "required": [ + "type", + "uri" + ], + "type": "object" + }, + "ResourceUpdatedNotification": { + "description": "A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/resources/updated", + "type": "string" + }, + "params": { + "$ref": "#/$defs/ResourceUpdatedNotificationParams" + } + }, + "required": [ + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "ResourceUpdatedNotificationParams": { + "description": "Parameters for a `notifications/resources/updated` notification.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "uri": { + "description": "The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "Result": { + "additionalProperties": {}, + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + } + }, + "type": "object" + }, + "Role": { + "description": "The sender or recipient of messages and data in a conversation.", + "enum": [ + "assistant", + "user" + ], + "type": "string" + }, + "Root": { + "description": "Represents a root directory or file that the server can operate on.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "name": { + "description": "An optional name for the root. This can be used to provide a human-readable\nidentifier for the root, which may be useful for display purposes or for\nreferencing the root in other parts of the application.", + "type": "string" + }, + "uri": { + "description": "The URI identifying the root. This *must* start with file:// for now.\nThis restriction may be relaxed in future versions of the protocol to allow\nother URI schemes.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "RootsListChangedNotification": { + "description": "A notification from the client to the server, informing it that the list of roots has changed.\nThis notification should be sent whenever the client adds, removes, or modifies any root.\nThe server should then request an updated list of roots using the ListRootsRequest.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/roots/list_changed", + "type": "string" + }, + "params": { + "$ref": "#/$defs/NotificationParams" + } + }, + "required": [ + "jsonrpc", + "method" + ], + "type": "object" + }, + "SamplingMessage": { + "description": "Describes a message issued to or received from an LLM API.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "content": { + "anyOf": [ + { + "$ref": "#/$defs/TextContent" + }, + { + "$ref": "#/$defs/ImageContent" + }, + { + "$ref": "#/$defs/AudioContent" + }, + { + "$ref": "#/$defs/ToolUseContent" + }, + { + "$ref": "#/$defs/ToolResultContent" + }, + { + "items": { + "$ref": "#/$defs/SamplingMessageContentBlock" + }, + "type": "array" + } + ] + }, + "role": { + "$ref": "#/$defs/Role" + } + }, + "required": [ + "content", + "role" + ], + "type": "object" + }, + "SamplingMessageContentBlock": { + "anyOf": [ + { + "$ref": "#/$defs/TextContent" + }, + { + "$ref": "#/$defs/ImageContent" + }, + { + "$ref": "#/$defs/AudioContent" + }, + { + "$ref": "#/$defs/ToolUseContent" + }, + { + "$ref": "#/$defs/ToolResultContent" + } + ] + }, + "ServerCapabilities": { + "description": "Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.", + "properties": { + "completions": { + "additionalProperties": true, + "description": "Present if the server supports argument autocompletion suggestions.", + "properties": {}, + "type": "object" + }, + "experimental": { + "additionalProperties": { + "additionalProperties": true, + "properties": {}, + "type": "object" + }, + "description": "Experimental, non-standard capabilities that the server supports.", + "type": "object" + }, + "logging": { + "additionalProperties": true, + "description": "Present if the server supports sending log messages to the client.", + "properties": {}, + "type": "object" + }, + "prompts": { + "description": "Present if the server offers any prompt templates.", + "properties": { + "listChanged": { + "description": "Whether this server supports notifications for changes to the prompt list.", + "type": "boolean" + } + }, + "type": "object" + }, + "resources": { + "description": "Present if the server offers any resources to read.", + "properties": { + "listChanged": { + "description": "Whether this server supports notifications for changes to the resource list.", + "type": "boolean" + }, + "subscribe": { + "description": "Whether this server supports subscribing to resource updates.", + "type": "boolean" + } + }, + "type": "object" + }, + "tasks": { + "description": "Present if the server supports task-augmented requests.", + "properties": { + "cancel": { + "additionalProperties": true, + "description": "Whether this server supports tasks/cancel.", + "properties": {}, + "type": "object" + }, + "list": { + "additionalProperties": true, + "description": "Whether this server supports tasks/list.", + "properties": {}, + "type": "object" + }, + "requests": { + "description": "Specifies which request types can be augmented with tasks.", + "properties": { + "tools": { + "description": "Task support for tool-related requests.", + "properties": { + "call": { + "additionalProperties": true, + "description": "Whether the server supports task-augmented tools/call requests.", + "properties": {}, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "tools": { + "description": "Present if the server offers any tools to call.", + "properties": { + "listChanged": { + "description": "Whether this server supports notifications for changes to the tool list.", + "type": "boolean" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "ServerNotification": { + "anyOf": [ + { + "$ref": "#/$defs/CancelledNotification" + }, + { + "$ref": "#/$defs/ProgressNotification" + }, + { + "$ref": "#/$defs/ResourceListChangedNotification" + }, + { + "$ref": "#/$defs/ResourceUpdatedNotification" + }, + { + "$ref": "#/$defs/PromptListChangedNotification" + }, + { + "$ref": "#/$defs/ToolListChangedNotification" + }, + { + "$ref": "#/$defs/TaskStatusNotification" + }, + { + "$ref": "#/$defs/LoggingMessageNotification" + }, + { + "$ref": "#/$defs/ElicitationCompleteNotification" + } + ] + }, + "ServerRequest": { + "anyOf": [ + { + "$ref": "#/$defs/PingRequest" + }, + { + "$ref": "#/$defs/GetTaskRequest" + }, + { + "$ref": "#/$defs/GetTaskPayloadRequest" + }, + { + "$ref": "#/$defs/CancelTaskRequest" + }, + { + "$ref": "#/$defs/ListTasksRequest" + }, + { + "$ref": "#/$defs/CreateMessageRequest" + }, + { + "$ref": "#/$defs/ListRootsRequest" + }, + { + "$ref": "#/$defs/ElicitRequest" + } + ] + }, + "ServerResult": { + "anyOf": [ + { + "$ref": "#/$defs/Result" + }, + { + "$ref": "#/$defs/InitializeResult" + }, + { + "$ref": "#/$defs/ListResourcesResult" + }, + { + "$ref": "#/$defs/ListResourceTemplatesResult" + }, + { + "$ref": "#/$defs/ReadResourceResult" + }, + { + "$ref": "#/$defs/ListPromptsResult" + }, + { + "$ref": "#/$defs/GetPromptResult" + }, + { + "$ref": "#/$defs/ListToolsResult" + }, + { + "$ref": "#/$defs/CallToolResult" + }, + { + "$ref": "#/$defs/GetTaskResult", + "description": "The response to a tasks/get request." + }, + { + "$ref": "#/$defs/GetTaskPayloadResult" + }, + { + "$ref": "#/$defs/CancelTaskResult", + "description": "The response to a tasks/cancel request." + }, + { + "$ref": "#/$defs/ListTasksResult" + }, + { + "$ref": "#/$defs/CompleteResult" + } + ] + }, + "SetLevelRequest": { + "description": "A request from the client to the server, to enable or adjust logging.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "logging/setLevel", + "type": "string" + }, + "params": { + "$ref": "#/$defs/SetLevelRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "SetLevelRequestParams": { + "description": "Parameters for a `logging/setLevel` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "level": { + "$ref": "#/$defs/LoggingLevel", + "description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message." + } + }, + "required": [ + "level" + ], + "type": "object" + }, + "SingleSelectEnumSchema": { + "anyOf": [ + { + "$ref": "#/$defs/UntitledSingleSelectEnumSchema" + }, + { + "$ref": "#/$defs/TitledSingleSelectEnumSchema" + } + ] + }, + "StringSchema": { + "properties": { + "default": { + "type": "string" + }, + "description": { + "type": "string" + }, + "format": { + "enum": [ + "date", + "date-time", + "email", + "uri" + ], + "type": "string" + }, + "maxLength": { + "type": "integer" + }, + "minLength": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "type": { + "const": "string", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "SubscribeRequest": { + "description": "Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "resources/subscribe", + "type": "string" + }, + "params": { + "$ref": "#/$defs/SubscribeRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "SubscribeRequestParams": { + "description": "Parameters for a `resources/subscribe` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "uri": { + "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "Task": { + "description": "Data associated with a task.", + "properties": { + "createdAt": { + "description": "ISO 8601 timestamp when the task was created.", + "type": "string" + }, + "lastUpdatedAt": { + "description": "ISO 8601 timestamp when the task was last updated.", + "type": "string" + }, + "pollInterval": { + "description": "Suggested polling interval in milliseconds.", + "type": "integer" + }, + "status": { + "$ref": "#/$defs/TaskStatus", + "description": "Current task state." + }, + "statusMessage": { + "description": "Optional human-readable message describing the current task state.\nThis can provide context for any status, including:\n- Reasons for \"cancelled\" status\n- Summaries for \"completed\" status\n- Diagnostic information for \"failed\" status (e.g., error details, what went wrong)", + "type": "string" + }, + "taskId": { + "description": "The task identifier.", + "type": "string" + }, + "ttl": { + "description": "Actual retention duration from creation in milliseconds, null for unlimited.", + "type": "integer" + } + }, + "required": [ + "createdAt", + "lastUpdatedAt", + "status", + "taskId", + "ttl" + ], + "type": "object" + }, + "TaskAugmentedRequestParams": { + "description": "Common params for any task-augmented request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "task": { + "$ref": "#/$defs/TaskMetadata", + "description": "If specified, the caller is requesting task-augmented execution for this request.\nThe request will return a CreateTaskResult immediately, and the actual result can be\nretrieved later via tasks/result.\n\nTask augmentation is subject to capability negotiation - receivers MUST declare support\nfor task augmentation of specific request types in their capabilities." + } + }, + "type": "object" + }, + "TaskMetadata": { + "description": "Metadata for augmenting a request with task execution.\nInclude this in the `task` field of the request parameters.", + "properties": { + "ttl": { + "description": "Requested duration in milliseconds to retain task from creation.", + "type": "integer" + } + }, + "type": "object" + }, + "TaskStatus": { + "description": "The status of a task.", + "enum": [ + "cancelled", + "completed", + "failed", + "input_required", + "working" + ], + "type": "string" + }, + "TaskStatusNotification": { + "description": "An optional notification from the receiver to the requestor, informing them that a task's status has changed. Receivers are not required to send these notifications.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/tasks/status", + "type": "string" + }, + "params": { + "$ref": "#/$defs/TaskStatusNotificationParams" + } + }, + "required": [ + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "TaskStatusNotificationParams": { + "allOf": [ + { + "$ref": "#/$defs/NotificationParams" + }, + { + "$ref": "#/$defs/Task" + } + ], + "description": "Parameters for a `notifications/tasks/status` notification." + }, + "TextContent": { + "description": "Text provided to or from an LLM.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/Annotations", + "description": "Optional annotations for the client." + }, + "text": { + "description": "The text content of the message.", + "type": "string" + }, + "type": { + "const": "text", + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "type": "object" + }, + "TextResourceContents": { + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "mimeType": { + "description": "The MIME type of this resource, if known.", + "type": "string" + }, + "text": { + "description": "The text of the item. This must only be set if the item can actually be represented as text (not binary data).", + "type": "string" + }, + "uri": { + "description": "The URI of this resource.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "text", + "uri" + ], + "type": "object" + }, + "TitledMultiSelectEnumSchema": { + "description": "Schema for multiple-selection enumeration with display titles for each option.", + "properties": { + "default": { + "description": "Optional default value.", + "items": { + "type": "string" + }, + "type": "array" + }, + "description": { + "description": "Optional description for the enum field.", + "type": "string" + }, + "items": { + "description": "Schema for array items with enum options and display labels.", + "properties": { + "anyOf": { + "description": "Array of enum options with values and display labels.", + "items": { + "properties": { + "const": { + "description": "The constant enum value.", + "type": "string" + }, + "title": { + "description": "Display title for this option.", + "type": "string" + } + }, + "required": [ + "const", + "title" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "anyOf" + ], + "type": "object" + }, + "maxItems": { + "description": "Maximum number of items to select.", + "type": "integer" + }, + "minItems": { + "description": "Minimum number of items to select.", + "type": "integer" + }, + "title": { + "description": "Optional title for the enum field.", + "type": "string" + }, + "type": { + "const": "array", + "type": "string" + } + }, + "required": [ + "items", + "type" + ], + "type": "object" + }, + "TitledSingleSelectEnumSchema": { + "description": "Schema for single-selection enumeration with display titles for each option.", + "properties": { + "default": { + "description": "Optional default value.", + "type": "string" + }, + "description": { + "description": "Optional description for the enum field.", + "type": "string" + }, + "oneOf": { + "description": "Array of enum options with values and display labels.", + "items": { + "properties": { + "const": { + "description": "The enum value.", + "type": "string" + }, + "title": { + "description": "Display label for this option.", + "type": "string" + } + }, + "required": [ + "const", + "title" + ], + "type": "object" + }, + "type": "array" + }, + "title": { + "description": "Optional title for the enum field.", + "type": "string" + }, + "type": { + "const": "string", + "type": "string" + } + }, + "required": [ + "oneOf", + "type" + ], + "type": "object" + }, + "Tool": { + "description": "Definition for a tool the client can call.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/ToolAnnotations", + "description": "Optional additional tool information.\n\nDisplay name precedence order is: title, annotations.title, then name." + }, + "description": { + "description": "A human-readable description of the tool.\n\nThis can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a \"hint\" to the model.", + "type": "string" + }, + "execution": { + "$ref": "#/$defs/ToolExecution", + "description": "Execution-related properties for this tool." + }, + "icons": { + "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", + "items": { + "$ref": "#/$defs/Icon" + }, + "type": "array" + }, + "inputSchema": { + "description": "A JSON Schema object defining the expected parameters for the tool.", + "properties": { + "$schema": { + "type": "string" + }, + "properties": { + "additionalProperties": { + "additionalProperties": true, + "properties": {}, + "type": "object" + }, + "type": "object" + }, + "required": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "const": "object", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "name": { + "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", + "type": "string" + }, + "outputSchema": { + "description": "An optional JSON Schema object defining the structure of the tool's output returned in\nthe structuredContent field of a CallToolResult.\n\nDefaults to JSON Schema 2020-12 when no explicit $schema is provided.\nCurrently restricted to type: \"object\" at the root level.", + "properties": { + "$schema": { + "type": "string" + }, + "properties": { + "additionalProperties": { + "additionalProperties": true, + "properties": {}, + "type": "object" + }, + "type": "object" + }, + "required": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "const": "object", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "title": { + "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for Tool,\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", + "type": "string" + } + }, + "required": [ + "inputSchema", + "name" + ], + "type": "object" + }, + "ToolAnnotations": { + "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**.\nThey are not guaranteed to provide a faithful description of\ntool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations\nreceived from untrusted servers.", + "properties": { + "destructiveHint": { + "description": "If true, the tool may perform destructive updates to its environment.\nIf false, the tool performs only additive updates.\n\n(This property is meaningful only when `readOnlyHint == false`)\n\nDefault: true", + "type": "boolean" + }, + "idempotentHint": { + "description": "If true, calling the tool repeatedly with the same arguments\nwill have no additional effect on its environment.\n\n(This property is meaningful only when `readOnlyHint == false`)\n\nDefault: false", + "type": "boolean" + }, + "openWorldHint": { + "description": "If true, this tool may interact with an \"open world\" of external\nentities. If false, the tool's domain of interaction is closed.\nFor example, the world of a web search tool is open, whereas that\nof a memory tool is not.\n\nDefault: true", + "type": "boolean" + }, + "readOnlyHint": { + "description": "If true, the tool does not modify its environment.\n\nDefault: false", + "type": "boolean" + }, + "title": { + "description": "A human-readable title for the tool.", + "type": "string" + } + }, + "type": "object" + }, + "ToolChoice": { + "description": "Controls tool selection behavior for sampling requests.", + "properties": { + "mode": { + "description": "Controls the tool use ability of the model:\n- \"auto\": Model decides whether to use tools (default)\n- \"required\": Model MUST use at least one tool before completing\n- \"none\": Model MUST NOT use any tools", + "enum": [ + "auto", + "none", + "required" + ], + "type": "string" + } + }, + "type": "object" + }, + "ToolExecution": { + "description": "Execution-related properties for a tool.", + "properties": { + "taskSupport": { + "description": "Indicates whether this tool supports task-augmented execution.\nThis allows clients to handle long-running operations through polling\nthe task system.\n\n- \"forbidden\": Tool does not support task-augmented execution (default when absent)\n- \"optional\": Tool may support task-augmented execution\n- \"required\": Tool requires task-augmented execution\n\nDefault: \"forbidden\"", + "enum": [ + "forbidden", + "optional", + "required" + ], + "type": "string" + } + }, + "type": "object" + }, + "ToolListChangedNotification": { + "description": "An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.", + "properties": { + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "notifications/tools/list_changed", + "type": "string" + }, + "params": { + "$ref": "#/$defs/NotificationParams" + } + }, + "required": [ + "jsonrpc", + "method" + ], + "type": "object" + }, + "ToolResultContent": { + "description": "The result of a tool use, provided by the user back to the assistant.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "Optional metadata about the tool result. Clients SHOULD preserve this field when\nincluding tool results in subsequent sampling requests to enable caching optimizations.\n\nSee [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "content": { + "description": "The unstructured result content of the tool use.\n\nThis has the same format as CallToolResult.content and can include text, images,\naudio, resource links, and embedded resources.", + "items": { + "$ref": "#/$defs/ContentBlock" + }, + "type": "array" + }, + "isError": { + "description": "Whether the tool use resulted in an error.\n\nIf true, the content typically describes the error that occurred.\nDefault: false", + "type": "boolean" + }, + "structuredContent": { + "additionalProperties": {}, + "description": "An optional structured result object.\n\nIf the tool defined an outputSchema, this SHOULD conform to that schema.", + "type": "object" + }, + "toolUseId": { + "description": "The ID of the tool use this result corresponds to.\n\nThis MUST match the ID from a previous ToolUseContent.", + "type": "string" + }, + "type": { + "const": "tool_result", + "type": "string" + } + }, + "required": [ + "content", + "toolUseId", + "type" + ], + "type": "object" + }, + "ToolUseContent": { + "description": "A request from the assistant to call a tool.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "Optional metadata about the tool use. Clients SHOULD preserve this field when\nincluding tool uses in subsequent sampling requests to enable caching optimizations.\n\nSee [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "type": "object" + }, + "id": { + "description": "A unique identifier for this tool use.\n\nThis ID is used to match tool results to their corresponding tool uses.", + "type": "string" + }, + "input": { + "additionalProperties": {}, + "description": "The arguments to pass to the tool, conforming to the tool's input schema.", + "type": "object" + }, + "name": { + "description": "The name of the tool to call.", + "type": "string" + }, + "type": { + "const": "tool_use", + "type": "string" + } + }, + "required": [ + "id", + "input", + "name", + "type" + ], + "type": "object" + }, + "URLElicitationRequiredError": { + "description": "An error response that indicates that the server requires the client to provide additional information via an elicitation request.", + "properties": { + "error": { + "allOf": [ + { + "$ref": "#/$defs/Error" + }, + { + "properties": { + "code": { + "const": -32042, + "type": "integer" + }, + "data": { + "additionalProperties": {}, + "properties": { + "elicitations": { + "items": { + "$ref": "#/$defs/ElicitRequestURLParams" + }, + "type": "array" + } + }, + "required": [ + "elicitations" + ], + "type": "object" + } + }, + "required": [ + "code", + "data" + ], + "type": "object" + } + ] + }, + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + } + }, + "required": [ + "error", + "jsonrpc" + ], + "type": "object" + }, + "UnsubscribeRequest": { + "description": "Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.", + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "jsonrpc": { + "const": "2.0", + "type": "string" + }, + "method": { + "const": "resources/unsubscribe", + "type": "string" + }, + "params": { + "$ref": "#/$defs/UnsubscribeRequestParams" + } + }, + "required": [ + "id", + "jsonrpc", + "method", + "params" + ], + "type": "object" + }, + "UnsubscribeRequestParams": { + "description": "Parameters for a `resources/unsubscribe` request.", + "properties": { + "_meta": { + "additionalProperties": {}, + "description": "See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.", + "properties": { + "progressToken": { + "$ref": "#/$defs/ProgressToken", + "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." + } + }, + "type": "object" + }, + "uri": { + "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "uri" + ], + "type": "object" + }, + "UntitledMultiSelectEnumSchema": { + "description": "Schema for multiple-selection enumeration without display titles for options.", + "properties": { + "default": { + "description": "Optional default value.", + "items": { + "type": "string" + }, + "type": "array" + }, + "description": { + "description": "Optional description for the enum field.", + "type": "string" + }, + "items": { + "description": "Schema for the array items.", + "properties": { + "enum": { + "description": "Array of enum values to choose from.", + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "const": "string", + "type": "string" + } + }, + "required": [ + "enum", + "type" + ], + "type": "object" + }, + "maxItems": { + "description": "Maximum number of items to select.", + "type": "integer" + }, + "minItems": { + "description": "Minimum number of items to select.", + "type": "integer" + }, + "title": { + "description": "Optional title for the enum field.", + "type": "string" + }, + "type": { + "const": "array", + "type": "string" + } + }, + "required": [ + "items", + "type" + ], + "type": "object" + }, + "UntitledSingleSelectEnumSchema": { + "description": "Schema for single-selection enumeration without display titles for options.", + "properties": { + "default": { + "description": "Optional default value.", + "type": "string" + }, + "description": { + "description": "Optional description for the enum field.", + "type": "string" + }, + "enum": { + "description": "Array of enum values to choose from.", + "items": { + "type": "string" + }, + "type": "array" + }, + "title": { + "description": "Optional title for the enum field.", + "type": "string" + }, + "type": { + "const": "string", + "type": "string" + } + }, + "required": [ + "enum", + "type" + ], + "type": "object" + } + } +} + diff --git a/codex-rs/mcp-types/src/lib.rs b/codex-rs/mcp-types/src/lib.rs index 7418bea854..2ba804d3f8 100644 --- a/codex-rs/mcp-types/src/lib.rs +++ b/codex-rs/mcp-types/src/lib.rs @@ -13,7 +13,7 @@ use std::convert::TryFrom; use schemars::JsonSchema; use ts_rs::TS; -pub const MCP_SCHEMA_VERSION: &str = "2025-06-18"; +pub const MCP_SCHEMA_VERSION: &str = "2025-11-25"; pub const JSONRPC_VERSION: &str = "2.0"; /// Paired request/response types for the Model Context Protocol (MCP). @@ -54,6 +54,9 @@ pub struct Annotations { /// Audio provided to or from an LLM. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct AudioContent { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, @@ -74,6 +77,9 @@ pub struct BaseMetadata { #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct BlobResourceContents { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub blob: String, #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -104,17 +110,27 @@ impl ModelContextProtocolRequest for CallToolRequest { type Result = CallToolResult; } +/// Parameters for a `tools/call` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CallToolRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub arguments: Option, pub name: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub task: Option, } /// The server's response to a tool call. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CallToolResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub content: Vec, #[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -136,6 +152,59 @@ impl From for serde_json::Value { } } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum CancelTaskRequest {} + +impl ModelContextProtocolRequest for CancelTaskRequest { + const METHOD: &'static str = "tasks/cancel"; + type Params = CancelTaskRequestParams; + type Result = CancelTaskResult; +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct CancelTaskRequestParams { + #[serde(rename = "taskId")] + pub task_id: String, +} + +/// The response to a tasks/cancel request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct CancelTaskResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + #[serde(rename = "createdAt")] + pub created_at: String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: String, + #[serde( + rename = "pollInterval", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub poll_interval: Option, + pub status: TaskStatus, + #[serde( + rename = "statusMessage", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub status_message: Option, + #[serde(rename = "taskId")] + pub task_id: String, + pub ttl: i64, +} + +impl From for serde_json::Value { + fn from(value: CancelTaskResult) -> Self { + // Leave this as it should never fail + #[expect(clippy::unwrap_used)] + serde_json::to_value(value).unwrap() + } +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub enum CancelledNotification {} @@ -144,13 +213,18 @@ impl ModelContextProtocolNotification for CancelledNotification { type Params = CancelledNotificationParams; } +/// Parameters for a `notifications/cancelled` notification. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CancelledNotificationParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub reason: Option, - #[serde(rename = "requestId")] - pub request_id: RequestId, + #[serde(rename = "requestId", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub request_id: Option, } /// Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities. @@ -158,7 +232,7 @@ pub struct CancelledNotificationParams { pub struct ClientCapabilities { #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub elicitation: Option, + pub elicitation: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub experimental: Option, @@ -167,7 +241,66 @@ pub struct ClientCapabilities { pub roots: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub sampling: Option, + pub sampling: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub tasks: Option, +} + +/// Present if the client supports task-augmented requests. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ClientCapabilitiesTasks { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub cancel: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub list: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub requests: Option, +} + +/// Specifies which request types can be augmented with tasks. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ClientCapabilitiesTasksRequests { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub elicitation: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub sampling: Option, +} + +/// Task support for sampling-related requests. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ClientCapabilitiesTasksRequestsSampling { + #[serde( + rename = "createMessage", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub create_message: Option, +} + +/// Task support for elicitation-related requests. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ClientCapabilitiesTasksRequestsElicitation { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub create: Option, +} + +/// Present if the client supports sampling from an LLM. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ClientCapabilitiesSampling { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub context: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub tools: Option, } /// Present if the client supports listing roots. @@ -182,12 +315,24 @@ pub struct ClientCapabilitiesRoots { pub list_changed: Option, } +/// Present if the client supports elicitation from the server. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ClientCapabilitiesElicitation { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub form: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub url: Option, +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] #[serde(untagged)] pub enum ClientNotification { CancelledNotification(CancelledNotification), InitializedNotification(InitializedNotification), ProgressNotification(ProgressNotification), + TaskStatusNotification(TaskStatusNotification), RootsListChangedNotification(RootsListChangedNotification), } @@ -218,6 +363,14 @@ pub enum ClientRequest { ListToolsRequest(::Params), #[serde(rename = "tools/call")] CallToolRequest(::Params), + #[serde(rename = "tasks/get")] + GetTaskRequest(::Params), + #[serde(rename = "tasks/result")] + GetTaskPayloadRequest(::Params), + #[serde(rename = "tasks/cancel")] + CancelTaskRequest(::Params), + #[serde(rename = "tasks/list")] + ListTasksRequest(::Params), #[serde(rename = "logging/setLevel")] SetLevelRequest(::Params), #[serde(rename = "completion/complete")] @@ -228,6 +381,10 @@ pub enum ClientRequest { #[serde(untagged)] pub enum ClientResult { Result(Result), + GetTaskResult(GetTaskResult), + GetTaskPayloadResult(GetTaskPayloadResult), + CancelTaskResult(CancelTaskResult), + ListTasksResult(ListTasksResult), CreateMessageResult(CreateMessageResult), ListRootsResult(ListRootsResult), ElicitResult(ElicitResult), @@ -242,8 +399,12 @@ impl ModelContextProtocolRequest for CompleteRequest { type Result = CompleteResult; } +/// Parameters for a `completion/complete` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CompleteRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub argument: CompleteRequestParamsArgument, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -276,6 +437,9 @@ pub enum CompleteRequestParamsRef { /// The server's response to a completion/complete request #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CompleteResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub completion: CompleteResultCompletion, } @@ -317,8 +481,12 @@ impl ModelContextProtocolRequest for CreateMessageRequest { type Result = CreateMessageResult; } +/// Parameters for a `sampling/createMessage` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CreateMessageRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde( rename = "includeContext", default, @@ -355,12 +523,30 @@ pub struct CreateMessageRequestParams { pub system_prompt: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] + pub task: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] pub temperature: Option, + #[serde( + rename = "toolChoice", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub tool_choice: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub tools: Option>, } -/// The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it. +/// The client's response to a sampling/createMessage request from the server. +/// The client should inform the user before returning the sampled message, to allow them +/// to inspect the response (human in the loop) and decide whether to allow the server to see it. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct CreateMessageResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub content: CreateMessageResultContent, pub model: String, pub role: Role, @@ -379,6 +565,9 @@ pub enum CreateMessageResultContent { TextContent(TextContent), ImageContent(ImageContent), AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), + Variant5(Vec), } impl From for serde_json::Value { @@ -389,6 +578,23 @@ impl From for serde_json::Value { } } +/// A response to a task-augmented request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct CreateTaskResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + pub task: Task, +} + +impl From for serde_json::Value { + fn from(value: CreateTaskResult) -> Self { + // Leave this as it should never fail + #[expect(clippy::unwrap_used)] + serde_json::to_value(value).unwrap() + } +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Cursor(String); @@ -401,17 +607,30 @@ impl ModelContextProtocolRequest for ElicitRequest { type Result = ElicitResult; } +/// The parameters for a request to elicit non-sensitive information from the user via a form in the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct ElicitRequestParams { +pub struct ElicitRequestFormParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub message: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub mode: Option, #[serde(rename = "requestedSchema")] - pub requested_schema: ElicitRequestParamsRequestedSchema, + pub requested_schema: ElicitRequestFormParamsRequestedSchema, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub task: Option, } /// A restricted subset of JSON Schema. /// Only top-level properties are allowed, without nesting. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct ElicitRequestParamsRequestedSchema { +pub struct ElicitRequestFormParamsRequestedSchema { + #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub schema: Option, pub properties: serde_json::Value, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -419,9 +638,36 @@ pub struct ElicitRequestParamsRequestedSchema { pub r#type: String, // &'static str = "object" } +/// The parameters for a request to elicit additional information from the user via the client. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +#[serde(untagged)] +pub enum ElicitRequestParams { + ElicitRequestURLParams(ElicitRequestURLParams), + ElicitRequestFormParams(ElicitRequestFormParams), +} + +/// The parameters for a request to elicit information from the user via a URL in the client. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ElicitRequestURLParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + #[serde(rename = "elicitationId")] + pub elicitation_id: String, + pub message: String, + pub mode: String, // &'static str = "url" + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub task: Option, + pub url: String, +} + /// The client's response to an elicitation request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ElicitResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub action: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -436,12 +682,29 @@ impl From for serde_json::Value { } } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum ElicitationCompleteNotification {} + +impl ModelContextProtocolNotification for ElicitationCompleteNotification { + const METHOD: &'static str = "notifications/elicitation/complete"; + type Params = ElicitationCompleteNotificationParams; +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ElicitationCompleteNotificationParams { + #[serde(rename = "elicitationId")] + pub elicitation_id: String, +} + /// The contents of a resource, embedded into a prompt or tool call result. /// /// It is up to the client how best to render embedded resources for the benefit /// of the LLM and/or the user. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct EmbeddedResource { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, @@ -459,18 +722,22 @@ pub enum EmbeddedResourceResource { pub type EmptyResult = Result; #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct EnumSchema { +#[serde(untagged)] +pub enum EnumSchema { + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), + LegacyTitledEnumSchema(LegacyTitledEnumSchema), +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct Error { + pub code: i64, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub description: Option, - pub r#enum: Vec, - #[serde(rename = "enumNames", default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub enum_names: Option>, - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub title: Option, - pub r#type: String, // &'static str = "string" + pub data: Option, + pub message: String, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] @@ -482,8 +749,12 @@ impl ModelContextProtocolRequest for GetPromptRequest { type Result = GetPromptResult; } +/// Parameters for a `prompts/get` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct GetPromptRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub arguments: Option, @@ -493,6 +764,9 @@ pub struct GetPromptRequestParams { /// The server's response to a prompts/get request from the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct GetPromptResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, @@ -507,9 +781,121 @@ impl From for serde_json::Value { } } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum GetTaskPayloadRequest {} + +impl ModelContextProtocolRequest for GetTaskPayloadRequest { + const METHOD: &'static str = "tasks/result"; + type Params = GetTaskPayloadRequestParams; + type Result = GetTaskPayloadResult; +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct GetTaskPayloadRequestParams { + #[serde(rename = "taskId")] + pub task_id: String, +} + +/// The response to a tasks/result request. +/// The structure matches the result type of the original request. +/// For example, a tools/call task would return the CallToolResult structure. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct GetTaskPayloadResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, +} + +impl From for serde_json::Value { + fn from(value: GetTaskPayloadResult) -> Self { + // Leave this as it should never fail + #[expect(clippy::unwrap_used)] + serde_json::to_value(value).unwrap() + } +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum GetTaskRequest {} + +impl ModelContextProtocolRequest for GetTaskRequest { + const METHOD: &'static str = "tasks/get"; + type Params = GetTaskRequestParams; + type Result = GetTaskResult; +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct GetTaskRequestParams { + #[serde(rename = "taskId")] + pub task_id: String, +} + +/// The response to a tasks/get request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct GetTaskResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + #[serde(rename = "createdAt")] + pub created_at: String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: String, + #[serde( + rename = "pollInterval", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub poll_interval: Option, + pub status: TaskStatus, + #[serde( + rename = "statusMessage", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub status_message: Option, + #[serde(rename = "taskId")] + pub task_id: String, + pub ttl: i64, +} + +impl From for serde_json::Value { + fn from(value: GetTaskResult) -> Self { + // Leave this as it should never fail + #[expect(clippy::unwrap_used)] + serde_json::to_value(value).unwrap() + } +} + +/// An optionally-sized icon that can be displayed in a user interface. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct Icon { + #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub mime_type: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub sizes: Option>, + pub src: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub theme: Option, +} + +/// Base interface to add `icons` property. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct Icons { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, +} + /// An image provided to or from an LLM. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ImageContent { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, @@ -519,14 +905,27 @@ pub struct ImageContent { pub r#type: String, // &'static str = "image" } -/// Describes the name and version of an MCP implementation, with an optional title for UI representation. +/// Describes the MCP implementation. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Implementation { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, pub name: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub title: Option, pub version: String, + #[serde( + rename = "websiteUrl", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub website_url: Option, // This is an extra field that the Codex MCP server sends as part of InitializeResult. #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -542,8 +941,12 @@ impl ModelContextProtocolRequest for InitializeRequest { type Result = InitializeResult; } +/// Parameters for an `initialize` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct InitializeRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub capabilities: ClientCapabilities, #[serde(rename = "clientInfo")] pub client_info: Implementation, @@ -554,6 +957,9 @@ pub struct InitializeRequestParams { /// After receiving an initialize request from the client, the server sends this response. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct InitializeResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub capabilities: ServerCapabilities, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -577,25 +983,18 @@ pub enum InitializedNotification {} impl ModelContextProtocolNotification for InitializedNotification { const METHOD: &'static str = "notifications/initialized"; - type Params = Option; + type Params = Option; } /// A response to a request that indicates an error occurred. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct JSONRPCError { - pub error: JSONRPCErrorError, - pub id: RequestId, - #[serde(rename = "jsonrpc", default = "default_jsonrpc")] - pub jsonrpc: String, -} - -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct JSONRPCErrorError { - pub code: i64, +pub struct JSONRPCErrorResponse { + pub error: Error, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub data: Option, - pub message: String, + pub id: Option, + #[serde(rename = "jsonrpc", default = "default_jsonrpc")] + pub jsonrpc: String, } /// Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent. @@ -604,8 +1003,8 @@ pub struct JSONRPCErrorError { pub enum JSONRPCMessage { Request(JSONRPCRequest), Notification(JSONRPCNotification), - Response(JSONRPCResponse), - Error(JSONRPCError), + ResultResponse(JSONRPCResultResponse), + ErrorResponse(JSONRPCErrorResponse), } /// A notification which does not expect a response. @@ -631,34 +1030,58 @@ pub struct JSONRPCRequest { pub params: Option, } +/// A response to a request, containing either the result or error. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +#[serde(untagged)] +pub enum JSONRPCResponse { + JSONRPCResultResponse(JSONRPCResultResponse), + JSONRPCErrorResponse(JSONRPCErrorResponse), +} + /// A successful (non-error) response to a request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct JSONRPCResponse { +pub struct JSONRPCResultResponse { pub id: RequestId, #[serde(rename = "jsonrpc", default = "default_jsonrpc")] pub jsonrpc: String, pub result: Result, } +/// Use TitledSingleSelectEnumSchema instead. +/// This interface will be removed in a future version. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct LegacyTitledEnumSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub description: Option, + pub r#enum: Vec, + #[serde(rename = "enumNames", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub enum_names: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub title: Option, + pub r#type: String, // &'static str = "string" +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub enum ListPromptsRequest {} impl ModelContextProtocolRequest for ListPromptsRequest { const METHOD: &'static str = "prompts/list"; - type Params = Option; + type Params = Option; type Result = ListPromptsResult; } -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct ListPromptsRequestParams { - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub cursor: Option, -} - /// The server's response to a prompts/list request from the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ListPromptsResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde( rename = "nextCursor", default, @@ -682,20 +1105,16 @@ pub enum ListResourceTemplatesRequest {} impl ModelContextProtocolRequest for ListResourceTemplatesRequest { const METHOD: &'static str = "resources/templates/list"; - type Params = Option; + type Params = Option; type Result = ListResourceTemplatesResult; } -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct ListResourceTemplatesRequestParams { - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub cursor: Option, -} - /// The server's response to a resources/templates/list request from the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ListResourceTemplatesResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde( rename = "nextCursor", default, @@ -720,20 +1139,16 @@ pub enum ListResourcesRequest {} impl ModelContextProtocolRequest for ListResourcesRequest { const METHOD: &'static str = "resources/list"; - type Params = Option; + type Params = Option; type Result = ListResourcesResult; } -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct ListResourcesRequestParams { - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub cursor: Option, -} - /// The server's response to a resources/list request from the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ListResourcesResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde( rename = "nextCursor", default, @@ -757,7 +1172,7 @@ pub enum ListRootsRequest {} impl ModelContextProtocolRequest for ListRootsRequest { const METHOD: &'static str = "roots/list"; - type Params = Option; + type Params = Option; type Result = ListRootsResult; } @@ -766,6 +1181,9 @@ impl ModelContextProtocolRequest for ListRootsRequest { /// or file that the server can operate on. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ListRootsResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub roots: Vec, } @@ -777,25 +1195,54 @@ impl From for serde_json::Value { } } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum ListTasksRequest {} + +impl ModelContextProtocolRequest for ListTasksRequest { + const METHOD: &'static str = "tasks/list"; + type Params = Option; + type Result = ListTasksResult; +} + +/// The response to a tasks/list request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ListTasksResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + #[serde( + rename = "nextCursor", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub next_cursor: Option, + pub tasks: Vec, +} + +impl From for serde_json::Value { + fn from(value: ListTasksResult) -> Self { + // Leave this as it should never fail + #[expect(clippy::unwrap_used)] + serde_json::to_value(value).unwrap() + } +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub enum ListToolsRequest {} impl ModelContextProtocolRequest for ListToolsRequest { const METHOD: &'static str = "tools/list"; - type Params = Option; + type Params = Option; type Result = ListToolsResult; } -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] -pub struct ListToolsRequestParams { - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub cursor: Option, -} - /// The server's response to a tools/list request from the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ListToolsResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde( rename = "nextCursor", default, @@ -846,8 +1293,12 @@ impl ModelContextProtocolNotification for LoggingMessageNotification { type Params = LoggingMessageNotificationParams; } +/// Parameters for a `notifications/message` notification. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct LoggingMessageNotificationParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub data: serde_json::Value, pub level: LoggingLevel, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -905,6 +1356,13 @@ pub struct ModelPreferences { pub speed_priority: Option, } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +#[serde(untagged)] +pub enum MultiSelectEnumSchema { + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Notification { pub method: String, @@ -913,8 +1371,18 @@ pub struct Notification { pub params: Option, } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct NotificationParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct NumberSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, @@ -932,14 +1400,21 @@ pub struct NumberSchema { #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct PaginatedRequest { + pub id: RequestId, + #[serde(rename = "jsonrpc", default = "default_jsonrpc")] + pub jsonrpc: String, pub method: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub params: Option, } +/// Common parameters for paginated requests. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct PaginatedRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub cursor: Option, @@ -947,6 +1422,9 @@ pub struct PaginatedRequestParams { #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct PaginatedResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde( rename = "nextCursor", default, @@ -969,7 +1447,7 @@ pub enum PingRequest {} impl ModelContextProtocolRequest for PingRequest { const METHOD: &'static str = "ping"; - type Params = Option; + type Params = Option; type Result = Result; } @@ -981,7 +1459,11 @@ pub enum PrimitiveSchemaDefinition { StringSchema(StringSchema), NumberSchema(NumberSchema), BooleanSchema(BooleanSchema), - EnumSchema(EnumSchema), + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), + LegacyTitledEnumSchema(LegacyTitledEnumSchema), } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] @@ -992,8 +1474,12 @@ impl ModelContextProtocolNotification for ProgressNotification { type Params = ProgressNotificationParams; } +/// Parameters for a `notifications/progress` notification. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ProgressNotificationParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub message: Option, @@ -1015,12 +1501,18 @@ pub enum ProgressToken { /// A prompt or prompt template that the server offers. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Prompt { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub arguments: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, pub name: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -1047,7 +1539,7 @@ pub enum PromptListChangedNotification {} impl ModelContextProtocolNotification for PromptListChangedNotification { const METHOD: &'static str = "notifications/prompts/list_changed"; - type Params = Option; + type Params = Option; } /// Describes a message returned as part of a prompt. @@ -1079,14 +1571,21 @@ impl ModelContextProtocolRequest for ReadResourceRequest { type Result = ReadResourceResult; } +/// Parameters for a `resources/read` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ReadResourceRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub uri: String, } /// The server's response to a resources/read request from the client. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ReadResourceResult { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub contents: Vec, } @@ -1105,6 +1604,14 @@ impl From for serde_json::Value { } } +/// Metadata for associating messages with a task. +/// Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct RelatedTaskMetadata { + #[serde(rename = "taskId")] + pub task_id: String, +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Request { pub method: String, @@ -1120,15 +1627,29 @@ pub enum RequestId { Integer(i64), } +/// Common params for any request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct RequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, +} + /// A known resource that the server is capable of reading. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Resource { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub mime_type: Option, @@ -1145,6 +1666,9 @@ pub struct Resource { /// The contents of a specific resource or sub-resource. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ResourceContents { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub mime_type: Option, @@ -1156,12 +1680,18 @@ pub struct ResourceContents { /// Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ResourceLink { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub mime_type: Option, @@ -1181,18 +1711,33 @@ pub enum ResourceListChangedNotification {} impl ModelContextProtocolNotification for ResourceListChangedNotification { const METHOD: &'static str = "notifications/resources/list_changed"; - type Params = Option; + type Params = Option; +} + +/// Common parameters when working with resources. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ResourceRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + pub uri: String, } /// A template description for resources available on the server. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ResourceTemplate { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub mime_type: Option, @@ -1219,8 +1764,12 @@ impl ModelContextProtocolNotification for ResourceUpdatedNotification { type Params = ResourceUpdatedNotificationParams; } +/// Parameters for a `notifications/resources/updated` notification. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ResourceUpdatedNotificationParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub uri: String, } @@ -1238,6 +1787,9 @@ pub enum Role { /// Represents a root directory or file that the server can operate on. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Root { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub name: Option, @@ -1249,12 +1801,15 @@ pub enum RootsListChangedNotification {} impl ModelContextProtocolNotification for RootsListChangedNotification { const METHOD: &'static str = "notifications/roots/list_changed"; - type Params = Option; + type Params = Option; } /// Describes a message issued to or received from an LLM API. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct SamplingMessage { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub content: SamplingMessageContent, pub role: Role, } @@ -1265,6 +1820,19 @@ pub enum SamplingMessageContent { TextContent(TextContent), ImageContent(ImageContent), AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), + Variant5(Vec), +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +#[serde(untagged)] +pub enum SamplingMessageContentBlock { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), } /// Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. @@ -1287,6 +1855,9 @@ pub struct ServerCapabilities { pub resources: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] + pub tasks: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] pub tools: Option, } @@ -1302,6 +1873,36 @@ pub struct ServerCapabilitiesTools { pub list_changed: Option, } +/// Present if the server supports task-augmented requests. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ServerCapabilitiesTasks { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub cancel: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub list: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub requests: Option, +} + +/// Specifies which request types can be augmented with tasks. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ServerCapabilitiesTasksRequests { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub tools: Option, +} + +/// Task support for tool-related requests. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ServerCapabilitiesTasksRequestsTools { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub call: Option, +} + /// Present if the server offers any resources to read. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ServerCapabilitiesResources { @@ -1352,16 +1953,26 @@ pub enum ServerNotification { ToolListChangedNotification( ::Params, ), + #[serde(rename = "notifications/tasks/status")] + TaskStatusNotification(::Params), #[serde(rename = "notifications/message")] LoggingMessageNotification( ::Params, ), + #[serde(rename = "notifications/elicitation/complete")] + ElicitationCompleteNotification( + ::Params, + ), } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] #[serde(untagged)] pub enum ServerRequest { PingRequest(PingRequest), + GetTaskRequest(GetTaskRequest), + GetTaskPayloadRequest(GetTaskPayloadRequest), + CancelTaskRequest(CancelTaskRequest), + ListTasksRequest(ListTasksRequest), CreateMessageRequest(CreateMessageRequest), ListRootsRequest(ListRootsRequest), ElicitRequest(ElicitRequest), @@ -1380,6 +1991,10 @@ pub enum ServerResult { GetPromptResult(GetPromptResult), ListToolsResult(ListToolsResult), CallToolResult(CallToolResult), + GetTaskResult(GetTaskResult), + GetTaskPayloadResult(GetTaskPayloadResult), + CancelTaskResult(CancelTaskResult), + ListTasksResult(ListTasksResult), CompleteResult(CompleteResult), } @@ -1392,13 +2007,27 @@ impl ModelContextProtocolRequest for SetLevelRequest { type Result = Result; } +/// Parameters for a `logging/setLevel` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct SetLevelRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub level: LoggingLevel, } +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +#[serde(untagged)] +pub enum SingleSelectEnumSchema { + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct StringSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, @@ -1426,14 +2055,121 @@ impl ModelContextProtocolRequest for SubscribeRequest { type Result = Result; } +/// Parameters for a `resources/subscribe` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct SubscribeRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub uri: String, } +/// Data associated with a task. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct Task { + #[serde(rename = "createdAt")] + pub created_at: String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: String, + #[serde( + rename = "pollInterval", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub poll_interval: Option, + pub status: TaskStatus, + #[serde( + rename = "statusMessage", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub status_message: Option, + #[serde(rename = "taskId")] + pub task_id: String, + pub ttl: i64, +} + +/// Common params for any task-augmented request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TaskAugmentedRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub task: Option, +} + +/// Metadata for augmenting a request with task execution. +/// Include this in the `task` field of the request parameters. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TaskMetadata { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub ttl: Option, +} + +/// The status of a task. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum TaskStatus { + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "completed")] + Completed, + #[serde(rename = "failed")] + Failed, + #[serde(rename = "input_required")] + Input_required, + #[serde(rename = "working")] + Working, +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub enum TaskStatusNotification {} + +impl ModelContextProtocolNotification for TaskStatusNotification { + const METHOD: &'static str = "notifications/tasks/status"; + type Params = TaskStatusNotificationParams; +} + +/// Parameters for a `notifications/tasks/status` notification. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TaskStatusNotificationParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + #[serde(rename = "createdAt")] + pub created_at: String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: String, + #[serde( + rename = "pollInterval", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub poll_interval: Option, + pub status: TaskStatus, + #[serde( + rename = "statusMessage", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub status_message: Option, + #[serde(rename = "taskId")] + pub task_id: String, + pub ttl: i64, +} + /// Text provided to or from an LLM. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct TextContent { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, @@ -1443,6 +2179,9 @@ pub struct TextContent { #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct TextResourceContents { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub mime_type: Option, @@ -1450,15 +2189,82 @@ pub struct TextResourceContents { pub uri: String, } +/// Schema for multiple-selection enumeration with display titles for each option. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TitledMultiSelectEnumSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub description: Option, + pub items: TitledMultiSelectEnumSchemaItems, + #[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub max_items: Option, + #[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub min_items: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub title: Option, + pub r#type: String, // &'static str = "array" +} + +/// Schema for array items with enum options and display labels. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TitledMultiSelectEnumSchemaItems { + #[serde(rename = "anyOf")] + pub any_of: Vec, +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TitledMultiSelectEnumSchemaItemsAnyOf { + pub r#const: String, + pub title: String, +} + +/// Schema for single-selection enumeration with display titles for each option. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TitledSingleSelectEnumSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub description: Option, + #[serde(rename = "oneOf")] + pub one_of: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub title: Option, + pub r#type: String, // &'static str = "string" +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct TitledSingleSelectEnumSchemaOneOf { + pub r#const: String, + pub title: String, +} + /// Definition for a tool the client can call. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct Tool { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub annotations: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub execution: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub icons: Option>, #[serde(rename = "inputSchema")] pub input_schema: ToolInputSchema, pub name: String, @@ -1480,8 +2286,14 @@ fn tool_output_schema_type_default_str() -> String { /// An optional JSON Schema object defining the structure of the tool's output returned in /// the structuredContent field of a CallToolResult. +/// +/// Defaults to JSON Schema 2020-12 when no explicit $schema is provided. +/// Currently restricted to type: "object" at the root level. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ToolOutputSchema { + #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub schema: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub properties: Option, @@ -1499,6 +2311,9 @@ fn tool_input_schema_type_default_str() -> String { /// A JSON Schema object defining the expected parameters for the tool. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct ToolInputSchema { + #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub schema: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub properties: Option, @@ -1552,12 +2367,77 @@ pub struct ToolAnnotations { pub title: Option, } +/// Controls tool selection behavior for sampling requests. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ToolChoice { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub mode: Option, +} + +/// Execution-related properties for a tool. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ToolExecution { + #[serde( + rename = "taskSupport", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub task_support: Option, +} + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub enum ToolListChangedNotification {} impl ModelContextProtocolNotification for ToolListChangedNotification { const METHOD: &'static str = "notifications/tools/list_changed"; - type Params = Option; + type Params = Option; +} + +/// The result of a tool use, provided by the user back to the assistant. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ToolResultContent { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + pub content: Vec, + #[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub is_error: Option, + #[serde( + rename = "structuredContent", + default, + skip_serializing_if = "Option::is_none" + )] + #[ts(optional)] + pub structured_content: Option, + #[serde(rename = "toolUseId")] + pub tool_use_id: String, + pub r#type: String, // &'static str = "tool_result" +} + +/// A request from the assistant to call a tool. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct ToolUseContent { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, + pub id: String, + pub input: serde_json::Value, + pub name: String, + pub r#type: String, // &'static str = "tool_use" +} + +/// An error response that indicates that the server requires the client to provide additional information via an elicitation request. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct URLElicitationRequiredError { + pub error: serde_json::Value, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub id: Option, + #[serde(rename = "jsonrpc", default = "default_jsonrpc")] + pub jsonrpc: String, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] @@ -1569,11 +2449,60 @@ impl ModelContextProtocolRequest for UnsubscribeRequest { type Result = Result; } +/// Parameters for a `resources/unsubscribe` request. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] pub struct UnsubscribeRequestParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub _meta: Option, pub uri: String, } +/// Schema for multiple-selection enumeration without display titles for options. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct UntitledMultiSelectEnumSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub description: Option, + pub items: UntitledMultiSelectEnumSchemaItems, + #[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub max_items: Option, + #[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub min_items: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub title: Option, + pub r#type: String, // &'static str = "array" +} + +/// Schema for the array items. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct UntitledMultiSelectEnumSchemaItems { + pub r#enum: Vec, + pub r#type: String, // &'static str = "string" +} + +/// Schema for single-selection enumeration without display titles for options. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)] +pub struct UntitledSingleSelectEnumSchema { + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub default: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub description: Option, + pub r#enum: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub title: Option, + pub r#type: String, // &'static str = "string" +} + impl TryFrom for ClientRequest { type Error = serde_json::Error; fn try_from(req: JSONRPCRequest) -> std::result::Result { @@ -1644,6 +2573,30 @@ impl TryFrom for ClientRequest { serde_json::from_value(params_json)?; Ok(ClientRequest::CallToolRequest(params)) } + "tasks/get" => { + let params_json = req.params.unwrap_or(serde_json::Value::Null); + let params: ::Params = + serde_json::from_value(params_json)?; + Ok(ClientRequest::GetTaskRequest(params)) + } + "tasks/result" => { + let params_json = req.params.unwrap_or(serde_json::Value::Null); + let params: ::Params = + serde_json::from_value(params_json)?; + Ok(ClientRequest::GetTaskPayloadRequest(params)) + } + "tasks/cancel" => { + let params_json = req.params.unwrap_or(serde_json::Value::Null); + let params: ::Params = + serde_json::from_value(params_json)?; + Ok(ClientRequest::CancelTaskRequest(params)) + } + "tasks/list" => { + let params_json = req.params.unwrap_or(serde_json::Value::Null); + let params: ::Params = + serde_json::from_value(params_json)?; + Ok(ClientRequest::ListTasksRequest(params)) + } "logging/setLevel" => { let params_json = req.params.unwrap_or(serde_json::Value::Null); let params: ::Params = @@ -1700,11 +2653,22 @@ impl TryFrom for ServerNotification { let params: ::Params = serde_json::from_value(params_json)?; Ok(ServerNotification::ToolListChangedNotification(params)) } + "notifications/tasks/status" => { + let params_json = n.params.unwrap_or(serde_json::Value::Null); + let params: ::Params = + serde_json::from_value(params_json)?; + Ok(ServerNotification::TaskStatusNotification(params)) + } "notifications/message" => { let params_json = n.params.unwrap_or(serde_json::Value::Null); let params: ::Params = serde_json::from_value(params_json)?; Ok(ServerNotification::LoggingMessageNotification(params)) } + "notifications/elicitation/complete" => { + let params_json = n.params.unwrap_or(serde_json::Value::Null); + let params: ::Params = serde_json::from_value(params_json)?; + Ok(ServerNotification::ElicitationCompleteNotification(params)) + } _ => Err(serde_json::Error::io(std::io::Error::new( std::io::ErrorKind::InvalidData, format!("Unknown method: {}", n.method), diff --git a/codex-rs/mcp-types/tests/suite/initialize.rs b/codex-rs/mcp-types/tests/suite/initialize.rs index 73ff120274..e4679c6404 100644 --- a/codex-rs/mcp-types/tests/suite/initialize.rs +++ b/codex-rs/mcp-types/tests/suite/initialize.rs @@ -52,16 +52,21 @@ fn deserialize_initialize_request() { assert_eq!( init_params, InitializeRequestParams { + _meta: None, capabilities: ClientCapabilities { experimental: None, roots: None, sampling: None, elicitation: None, + tasks: None, }, client_info: Implementation { + description: None, + icons: None, name: "acme-client".into(), title: Some("Acme".to_string()), version: "1.2.3".into(), + website_url: None, user_agent: None, }, protocol_version: "2025-06-18".into(), diff --git a/codex-rs/mcp-types/tests/suite/progress_notification.rs b/codex-rs/mcp-types/tests/suite/progress_notification.rs index 396efca2bd..faa4c462ae 100644 --- a/codex-rs/mcp-types/tests/suite/progress_notification.rs +++ b/codex-rs/mcp-types/tests/suite/progress_notification.rs @@ -33,6 +33,7 @@ fn deserialize_progress_notification() { }; let expected_params = ProgressNotificationParams { + _meta: None, message: Some("Half way there".into()), progress: 0.5, progress_token: ProgressToken::Integer(99), diff --git a/codex-rs/protocol/src/models.rs b/codex-rs/protocol/src/models.rs index 8e67fc40fc..b86ebb3c9c 100644 --- a/codex-rs/protocol/src/models.rs +++ b/codex-rs/protocol/src/models.rs @@ -805,6 +805,7 @@ impl From<&CallToolResult> for FunctionCallOutputPayload { content, structured_content, is_error, + .. } = call_tool_result; let is_success = is_error != &Some(true); @@ -1039,13 +1040,16 @@ mod tests { #[test] fn serializes_image_outputs_as_array() -> Result<()> { let call_tool_result = CallToolResult { + _meta: None, content: vec![ ContentBlock::TextContent(TextContent { + _meta: None, annotations: None, text: "caption".into(), r#type: "text".into(), }), ContentBlock::ImageContent(ImageContent { + _meta: None, annotations: None, data: "BASE64".into(), mime_type: "image/png".into(), diff --git a/codex-rs/rmcp-client/src/rmcp_client.rs b/codex-rs/rmcp-client/src/rmcp_client.rs index c1bf6d39d3..5633164721 100644 --- a/codex-rs/rmcp-client/src/rmcp_client.rs +++ b/codex-rs/rmcp-client/src/rmcp_client.rs @@ -14,12 +14,10 @@ use mcp_types::CallToolRequestParams; use mcp_types::CallToolResult; use mcp_types::InitializeRequestParams; use mcp_types::InitializeResult; -use mcp_types::ListResourceTemplatesRequestParams; use mcp_types::ListResourceTemplatesResult; -use mcp_types::ListResourcesRequestParams; use mcp_types::ListResourcesResult; -use mcp_types::ListToolsRequestParams; use mcp_types::ListToolsResult; +use mcp_types::PaginatedRequestParams; use mcp_types::ReadResourceRequestParams; use mcp_types::ReadResourceResult; use mcp_types::RequestId; @@ -296,11 +294,12 @@ impl RmcpClient { pub async fn list_tools( &self, - params: Option, + params: Option, timeout: Option, ) -> Result { let result = self.list_tools_with_connector_ids(params, timeout).await?; Ok(ListToolsResult { + _meta: None, next_cursor: result.next_cursor, tools: result.tools.into_iter().map(|tool| tool.tool).collect(), }) @@ -308,7 +307,7 @@ impl RmcpClient { pub async fn list_tools_with_connector_ids( &self, - params: Option, + params: Option, timeout: Option, ) -> Result { self.refresh_oauth_if_needed().await; @@ -352,7 +351,7 @@ impl RmcpClient { pub async fn list_resources( &self, - params: Option, + params: Option, timeout: Option, ) -> Result { self.refresh_oauth_if_needed().await; @@ -370,7 +369,7 @@ impl RmcpClient { pub async fn list_resource_templates( &self, - params: Option, + params: Option, timeout: Option, ) -> Result { self.refresh_oauth_if_needed().await; @@ -409,7 +408,12 @@ impl RmcpClient { ) -> Result { self.refresh_oauth_if_needed().await; let service = self.service().await?; - let params = CallToolRequestParams { arguments, name }; + let params = CallToolRequestParams { + _meta: None, + arguments, + name, + task: None, + }; let rmcp_params: CallToolRequestParam = convert_to_rmcp(params)?; let fut = service.call_tool(rmcp_params); let rmcp_result = run_with_timeout(fut, timeout, "tools/call").await?; diff --git a/codex-rs/rmcp-client/tests/resources.rs b/codex-rs/rmcp-client/tests/resources.rs index 3d627ebbf4..37ec97d748 100644 --- a/codex-rs/rmcp-client/tests/resources.rs +++ b/codex-rs/rmcp-client/tests/resources.rs @@ -8,6 +8,7 @@ use codex_rmcp_client::RmcpClient; use codex_utils_cargo_bin::CargoBinError; use futures::FutureExt as _; use mcp_types::ClientCapabilities; +use mcp_types::ClientCapabilitiesElicitation; use mcp_types::Implementation; use mcp_types::InitializeRequestParams; use mcp_types::ListResourceTemplatesResult; @@ -26,16 +27,24 @@ fn stdio_server_bin() -> Result { fn init_params() -> InitializeRequestParams { InitializeRequestParams { + _meta: None, capabilities: ClientCapabilities { + elicitation: Some(ClientCapabilitiesElicitation { + form: None, + url: None, + }), experimental: None, roots: None, sampling: None, - elicitation: Some(json!({})), + tasks: None, }, client_info: Implementation { + description: None, + icons: None, name: "codex-test".into(), version: "0.0.0-test".into(), title: Some("Codex rmcp resource test".into()), + website_url: None, user_agent: None, }, protocol_version: mcp_types::MCP_SCHEMA_VERSION.to_string(), @@ -80,8 +89,10 @@ async fn rmcp_client_can_list_and_read_resources() -> anyhow::Result<()> { assert_eq!( memo, &Resource { + _meta: None, annotations: None, description: Some("A sample MCP resource exposed for integration tests.".to_string()), + icons: None, mime_type: Some("text/plain".to_string()), name: "example-note".to_string(), size: None, @@ -95,12 +106,15 @@ async fn rmcp_client_can_list_and_read_resources() -> anyhow::Result<()> { assert_eq!( templates, ListResourceTemplatesResult { + _meta: None, next_cursor: None, resource_templates: vec![ResourceTemplate { + _meta: None, annotations: None, description: Some( "Template for memo://codex/{slug} resources used in tests.".to_string() ), + icons: None, mime_type: Some("text/plain".to_string()), name: "codex-memo".to_string(), title: Some("Codex Memo".to_string()), @@ -112,6 +126,7 @@ async fn rmcp_client_can_list_and_read_resources() -> anyhow::Result<()> { let read = client .read_resource( ReadResourceRequestParams { + _meta: None, uri: RESOURCE_URI.to_string(), }, Some(Duration::from_secs(5)), @@ -125,6 +140,7 @@ async fn rmcp_client_can_list_and_read_resources() -> anyhow::Result<()> { assert_eq!( text, &TextResourceContents { + _meta: None, text: "This is a sample MCP resource served by the rmcp test server.".to_string(), uri: RESOURCE_URI.to_string(), mime_type: Some("text/plain".to_string()),