From 976af7be66dad17a5fd6037d0395b08fd60cd41b Mon Sep 17 00:00:00 2001 From: Ali Hashemi Date: Mon, 1 Dec 2025 18:29:51 -0400 Subject: [PATCH 1/5] feat: add schema for mcp protocol version 2025-11-25 --- Cargo.toml | 12 +- README.md | 19 +- examples/mcp_client_handle_message.rs | 48 +- examples/mcp_server_handle_message.rs | 58 +- scripts/run_clippy.sh | 2 +- scripts/run_test.sh | 2 +- src/generated_schema.rs | 17 +- src/generated_schema/2024_11_05/mcp_schema.rs | 437 +- .../2024_11_05/schema_utils.rs | 6 +- src/generated_schema/2025_03_26/mcp_schema.rs | 530 +- .../2025_03_26/schema_utils.rs | 6 +- src/generated_schema/2025_06_18/mcp_schema.rs | 817 +- .../2025_06_18/schema_utils.rs | 6 +- src/generated_schema/2025_11_25/mcp_schema.rs | 11209 ++++++++++++++++ .../2025_11_25/schema_utils.rs | 5231 ++++++++ src/generated_schema/2025_11_25/validators.rs | 368 + src/generated_schema/draft/mcp_schema.rs | 6923 +++++++--- src/generated_schema/draft/schema_utils.rs | 885 +- src/generated_schema/draft/validators.rs | 166 +- src/generated_schema/protocol_version.rs | 4 + tests/2024_11_05_exclusive.rs | 91 - .../{ => before_2025_11_25}/miscellaneous.rs | 9 +- tests/before_2025_11_25/mod.rs | 9 + .../serde_smoke_test.rs | 30 +- .../test_2024_11_05_exclusive.rs | 85 + tests/before_2025_11_25/test_deserialize.rs | 342 + tests/before_2025_11_25/test_serialize.rs | 899 ++ tests/common/common.rs | 25 +- tests/main.rs | 5 + tests/test_deserialize.rs | 336 - tests/test_serialize.rs | 904 -- tests/v2025_11_25/mod.rs | 5 + tests/v2025_11_25/schema_2025_11_25.rs | 222 + tests/v2025_11_25/test_schema_utils.rs | 270 + 34 files changed, 26123 insertions(+), 3855 deletions(-) create mode 100644 src/generated_schema/2025_11_25/mcp_schema.rs create mode 100644 src/generated_schema/2025_11_25/schema_utils.rs create mode 100644 src/generated_schema/2025_11_25/validators.rs delete mode 100644 tests/2024_11_05_exclusive.rs rename tests/{ => before_2025_11_25}/miscellaneous.rs (89%) create mode 100644 tests/before_2025_11_25/mod.rs rename tests/{ => before_2025_11_25}/serde_smoke_test.rs (95%) create mode 100644 tests/before_2025_11_25/test_2024_11_05_exclusive.rs create mode 100644 tests/before_2025_11_25/test_deserialize.rs create mode 100644 tests/before_2025_11_25/test_serialize.rs create mode 100644 tests/main.rs delete mode 100644 tests/test_deserialize.rs delete mode 100644 tests/test_serialize.rs create mode 100644 tests/v2025_11_25/mod.rs create mode 100644 tests/v2025_11_25/schema_2025_11_25.rs create mode 100644 tests/v2025_11_25/test_schema_utils.rs diff --git a/Cargo.toml b/Cargo.toml index b5bbf50..8821f44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,11 +24,11 @@ json5 = { version = "0.4" } [package.metadata.docs.rs] -features = ["2025_06_18", "schema_utils"] +features = ["2025_11_25", "schema_utils"] rustdoc-args = ["--generate-link-to-definition"] [package.metadata.playground] -features = ["2025_06_18", "schema_utils"] +features = ["2025_11_25", "schema_utils"] ### FEATURES ################################################################# @@ -36,12 +36,14 @@ features = ["2025_06_18", "schema_utils"] [features] # default features -default = ["2025_06_18", "schema_utils"] # Default features +default = ["2025_11_25", "schema_utils"] # Default features # activates the latest MCP schema version, this will be updated once a new version of schema is published -latest = ["2025_06_18"] +latest = ["2025_11_25"] +# enabled mcp schema version 2025_11_25 +2025_11_25 = ["latest"] # enabled mcp schema version 2025_06_18 -2025_06_18 = ["latest"] +2025_06_18 = [] # enabled mcp schema version 2025_03_26 2025_03_26 = [] # enabled mcp schema version 2024_11_05 diff --git a/README.md b/README.md index b4f247f..f182196 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,13 @@ [build status ](https://github.com/rust-mcp-stack/rust-mcp-schema/actions/workflows/ci.yml) -A type-safe Rust implementation of the official Model Context Protocol (MCP) schema, supporting all official released versions including `2025_06_18`, `2025_03_26`, `2024_11_05` and `draft` version for early adoption. +A type-safe Rust implementation of the official Model Context Protocol (MCP) schema, supporting all official MCP Protocol versions: + +- `2025_11_25` +- `2025_06_18` +- `2025_03_26` +- `2024_11_05` +- `draft` The MCP schemas in this repository are [automatically generated](#how-are-schemas-generated) from the official Model Context Protocol, ensuring they are always up-to-date and aligned with the latest official specifications. @@ -46,7 +52,7 @@ Focus on your app's logic while [rust-mcp-sdk](https://crates.io/crates/rust-mcp - 🧩 Type-safe implementation of the MCP protocol specification. - 💎 Auto-generated schemas are always synchronized with the official schema specifications. -- 📜 Includes all official released versions : `2025_06_18`, `2025_03_26`, `2024_11_05` and `draft` version for early adoption. +- 📜 Includes all official released versions : `2025_11_25`, `2025_06_18`, `2025_03_26`, `2024_11_05` and `draft` version for early adoption. - 🛠 Complimentary schema utility module (schema_utils) to boost productivity and ensure development integrity. ## How can this crate be used? @@ -70,6 +76,7 @@ For more information on the MCP architecture, refer to the [official documentati This repository provides all official released versions the schema , including draft version, enabling you to prepare and adapt your applications ahead of upcoming official schema releases. +- [2025_11_25](src/generated_schema/2025_11_25) - [2025_06_18](src/generated_schema/2025_06_18) - [2025_03_26](src/generated_schema/2025_03_26) - [2024_11_05](src/generated_schema/2024_11_05) @@ -83,19 +90,19 @@ Each schema version has a corresponding Cargo feature that can be enabled in you Multiple schema versions may be enabled concurrently if needed. Non-default versions are available under explicitly named modules, for example: -- rust_mcp_schema::mcp_2024_11_05 +- rust_mcp_schema::mcp_2025_06_18 - rust_mcp_schema::mcp_draft" -Example: enable `2024_11_05` version of the schema: +Example: enable `2025_06_18` version of the schema: ```toml # Cargo.toml -rust-mcp-schema = { version: 0.7.5 , default-features = false, features=["2024_11_05"] } +rust-mcp-schema = { version: 0.7.5 , default-features = false, features=["2025_06_18"] } ``` -Example: enable `draft`` version of the schema (2024_11_05) : +Example: enable `draft`` version of the schema : ```toml #Cargo.toml diff --git a/examples/mcp_client_handle_message.rs b/examples/mcp_client_handle_message.rs index d072191..e3fc590 100644 --- a/examples/mcp_client_handle_message.rs +++ b/examples/mcp_client_handle_message.rs @@ -4,6 +4,12 @@ mod schema { pub use rust_mcp_schema::*; } +#[cfg(feature = "2025_06_18")] +mod schema { + pub use rust_mcp_schema::mcp_2025_06_18::schema_utils::*; + pub use rust_mcp_schema::mcp_2025_06_18::*; +} + #[cfg(feature = "2024_11_05")] mod schema { pub use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; @@ -77,10 +83,26 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> { ServerRequest::ListRootsRequest(list_roots_request) => { dbg!(list_roots_request); } - #[cfg(any(feature = "2025_06_18", feature = "draft"))] + #[cfg(any(feature = "2025_06_18", feature = "2025_11_25", feature = "draft"))] ServerRequest::ElicitRequest(elicit_request) => { dbg!(elicit_request); } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerRequest::GetTaskRequest(get_task_request) => { + dbg!(get_task_request); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerRequest::GetTaskPayloadRequest(get_task_payload_request) => { + dbg!(get_task_payload_request); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerRequest::CancelTaskRequest(cancel_task_request) => { + dbg!(cancel_task_request); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerRequest::ListTasksRequest(list_tasks_request) => { + dbg!(list_tasks_request); + } } } // Check if it's a CustomRequest; the value can be deserialized into your own custom types. @@ -115,6 +137,14 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> { ServerNotification::LoggingMessageNotification(logging_message_notification) => { dbg!(logging_message_notification); } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerNotification::TaskStatusNotification(task_status_notification) => { + dbg!(task_status_notification); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerNotification::ElicitationCompleteNotification(elicitation_complete_notification) => { + dbg!(elicitation_complete_notification); + } } } // Check if it's a CustomNotification; the value can be deserialized into your custom types. @@ -156,6 +186,22 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> { ServerResult::CompleteResult(complete_result) => { dbg!(complete_result); } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerResult::GetTaskResult(get_task_result) => { + dbg!(get_task_result); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerResult::GetTaskPayloadResult(get_task_payload_result) => { + dbg!(get_task_payload_result); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerResult::CancelTaskResult(cancel_task_result) => { + dbg!(cancel_task_result); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ServerResult::ListTasksResult(list_tasks_result) => { + dbg!(list_tasks_result); + } }, // Check if it's a CustomResult; the value can be deserialized into your custom types. ResultFromServer::CustomResult(value) => { diff --git a/examples/mcp_server_handle_message.rs b/examples/mcp_server_handle_message.rs index 391ef5d..6b3e430 100644 --- a/examples/mcp_server_handle_message.rs +++ b/examples/mcp_server_handle_message.rs @@ -4,6 +4,12 @@ mod schema { pub use rust_mcp_schema::*; } +#[cfg(feature = "2025_06_18")] +mod schema { + pub use rust_mcp_schema::mcp_2025_06_18::schema_utils::*; + pub use rust_mcp_schema::mcp_2025_06_18::*; +} + #[cfg(feature = "2024_11_05")] mod schema { pub use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; @@ -68,53 +74,58 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> { ClientRequest::InitializeRequest(initialize_request) => { dbg!(initialize_request); } - ClientRequest::PingRequest(ping_request) => { dbg!(ping_request); } ClientRequest::ListResourcesRequest(list_resources_request) => { dbg!(list_resources_request); } - ClientRequest::ListResourceTemplatesRequest(list_resource_templates_request) => { dbg!(list_resource_templates_request); } - ClientRequest::ReadResourceRequest(read_resource_request) => { dbg!(read_resource_request); } - ClientRequest::SubscribeRequest(subscribe_request) => { dbg!(subscribe_request); } - ClientRequest::UnsubscribeRequest(unsubscribe_request) => { dbg!(unsubscribe_request); } - ClientRequest::ListPromptsRequest(list_prompts_request) => { dbg!(list_prompts_request); } - ClientRequest::GetPromptRequest(get_prompt_request) => { dbg!(get_prompt_request); } - ClientRequest::ListToolsRequest(list_tools_request) => { dbg!(list_tools_request); } - ClientRequest::CallToolRequest(call_tool_request) => { dbg!(call_tool_request); } - ClientRequest::SetLevelRequest(set_level_request) => { dbg!(set_level_request); } - ClientRequest::CompleteRequest(complete_request) => { dbg!(complete_request); } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientRequest::GetTaskRequest(get_task_request) => { + dbg!(get_task_request); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientRequest::GetTaskPayloadRequest(get_task_payload_request) => { + dbg!(get_task_payload_request); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientRequest::CancelTaskRequest(cancel_task_request) => { + dbg!(cancel_task_request); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientRequest::ListTasksRequest(list_tasks_request) => { + dbg!(list_tasks_request); + } }, // Check if it's a CustomRequest; the value can be deserialized into your own custom types. @@ -132,18 +143,19 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> { ClientNotification::CancelledNotification(cancelled_notification) => { dbg!(cancelled_notification); } - ClientNotification::InitializedNotification(initialized_notification) => { dbg!(initialized_notification); } - ClientNotification::ProgressNotification(progress_notification) => { dbg!(progress_notification); } - ClientNotification::RootsListChangedNotification(progress_notification) => { dbg!(progress_notification); } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientNotification::TaskStatusNotification(task_status_notification) => { + dbg!(task_status_notification); + } } } @@ -166,10 +178,26 @@ fn handle_message(message_payload: &str) -> std::result::Result<(), AppError> { ClientResult::ListRootsResult(list_roots_result) => { dbg!(list_roots_result); } - #[cfg(any(feature = "2025_06_18", feature = "draft"))] + #[cfg(any(feature = "2025_06_18", feature = "2025_11_25", feature = "draft"))] ClientResult::ElicitResult(elicit_result) => { dbg!(elicit_result); } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientResult::GetTaskResult(get_task_result) => { + dbg!(get_task_result); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientResult::GetTaskPayloadResult(get_task_payload_result) => { + dbg!(get_task_payload_result); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientResult::CancelTaskResult(cancel_task_result) => { + dbg!(cancel_task_result); + } + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + ClientResult::ListTasksResult(list_tasks_result) => { + dbg!(list_tasks_result); + } }, // Check if it's a CustomResult; the value can be deserialized into your custom types. diff --git a/scripts/run_clippy.sh b/scripts/run_clippy.sh index 5ec2aee..c0759b3 100755 --- a/scripts/run_clippy.sh +++ b/scripts/run_clippy.sh @@ -4,7 +4,7 @@ COMMON_FEATURES=("schema_utils") # schema versions features (passed to clippy one at a time) -SCHEMA_VERSION_FEATURES=("2025_06_18", "2025_03_26", "2024_11_05", "draft") +SCHEMA_VERSION_FEATURES=("2025_11_25", "2025_06_18", "2025_03_26", "2024_11_05", "draft") # space-separated string COMMON_FEATURES_STR="${COMMON_FEATURES[*]}" diff --git a/scripts/run_test.sh b/scripts/run_test.sh index 764b552..43a5900 100755 --- a/scripts/run_test.sh +++ b/scripts/run_test.sh @@ -4,7 +4,7 @@ COMMON_FEATURES=("schema_utils") # schema versions features (tested one at a time) -SCHEMA_VERSION_FEATURES=("2025_06_18", "2025_03_26", "2024_11_05") #// TODO: add the "draft" tests back +SCHEMA_VERSION_FEATURES=("2025_11_25", "2025_06_18", "2025_03_26", "2024_11_05") #// TODO: add the "draft" tests back # space-separated string COMMON_FEATURES_STR="${COMMON_FEATURES[*]}" diff --git a/src/generated_schema.rs b/src/generated_schema.rs index be88bf1..57a4f51 100644 --- a/src/generated_schema.rs +++ b/src/generated_schema.rs @@ -31,9 +31,9 @@ macro_rules! define_schema_version { }; } -/// Latest MCP Protocol 2025_06_18 -#[cfg(feature = "2025_06_18")] -pub use mcp_2025_06_18::*; +/// Latest MCP Protocol 2025_11_25 +#[cfg(feature = "2025_11_25")] +pub use mcp_2025_11_25::*; #[cfg(feature = "2025_06_18")] define_schema_version!( @@ -68,6 +68,17 @@ define_schema_version!( __int_utils_2024_11_05 ); +#[cfg(feature = "2025_11_25")] +define_schema_version!( + "2025_11_25", + mcp_2025_11_25, + "generated_schema/2025_11_25/mcp_schema.rs", + "generated_schema/2025_11_25/schema_utils.rs", + "generated_schema/2025_11_25/validators.rs", + __int_2025_11_25, + __int_utils_2025_11_25 +); + #[cfg(feature = "draft")] define_schema_version!( "draft", diff --git a/src/generated_schema/2024_11_05/mcp_schema.rs b/src/generated_schema/2024_11_05/mcp_schema.rs index aeffa9f..bd98a8e 100644 --- a/src/generated_schema/2024_11_05/mcp_schema.rs +++ b/src/generated_schema/2024_11_05/mcp_schema.rs @@ -1,12 +1,15 @@ +/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) +/// Licensed under the MIT License. See LICENSE in the project root. +/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- -/// This file is auto-generated by mcp-schema-gen v0.4.4. +/// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: /// It is not recommended to modify this file directly. You are free to /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : 71204c22f8e062795dca00a87d31070033572ba2 -/// Generated at : 2025-10-03 15:17:01 +/// Hash : UNKNOWN +/// Generated at : 2025-12-01 14:17:31 /// ---------------------------------------------------------------------------- /// use super::validators as validate; @@ -186,6 +189,11 @@ impl CallToolRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/call" + pub fn method_value() -> ::std::string::String { + "tools/call".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/call".to_string() } @@ -375,6 +383,11 @@ impl CancelledNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/cancelled" + pub fn method_value() -> ::std::string::String { + "notifications/cancelled".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/cancelled".to_string() } @@ -456,34 +469,11 @@ pub struct ClientCapabilities { ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, >, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub roots: ::std::option::Option, + pub roots: ::std::option::Option, ///Present if the client supports sampling from an LLM. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub sampling: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///Present if the client supports listing roots. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "Present if the client supports listing roots.", -/// "type": "object", -/// "properties": { -/// "listChanged": { -/// "description": "Whether the client supports notifications for changes to the roots list.", -/// "type": "boolean" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ClientCapabilitiesRoots { - ///Whether the client supports notifications for changes to the roots list. - #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] - pub list_changed: ::std::option::Option, -} ///ClientNotification /// ///
JSON schema @@ -709,6 +699,29 @@ impl ::std::convert::From for ClientResult { Self::Result(value) } } +///Present if the client supports listing roots. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports listing roots.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether the client supports notifications for changes to the roots list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientRoots { + ///Whether the client supports notifications for changes to the roots list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} ///A request from the client to the server, to ask for completion options. /// ///
JSON schema @@ -783,10 +796,47 @@ impl CompleteRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "completion/complete" + pub fn method_value() -> ::std::string::String { + "completion/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "completion/complete".to_string() } } +///The argument's information +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The argument's information", +/// "type": "object", +/// "required": [ +/// "name", +/// "value" +/// ], +/// "properties": { +/// "name": { +/// "description": "The name of the argument", +/// "type": "string" +/// }, +/// "value": { +/// "description": "The value of the argument to use for completion matching.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequestArgument { + ///The name of the argument + pub name: ::std::string::String, + ///The value of the argument to use for completion matching. + pub value: ::std::string::String, +} ///CompleteRequestParams /// ///
JSON schema @@ -833,43 +883,11 @@ impl CompleteRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CompleteRequestParams { - pub argument: CompleteRequestParamsArgument, + pub argument: CompleteRequestArgument, #[serde(rename = "ref")] - pub ref_: CompleteRequestParamsRef, -} -///The argument's information -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "The argument's information", -/// "type": "object", -/// "required": [ -/// "name", -/// "value" -/// ], -/// "properties": { -/// "name": { -/// "description": "The name of the argument", -/// "type": "string" -/// }, -/// "value": { -/// "description": "The value of the argument to use for completion matching.", -/// "type": "string" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct CompleteRequestParamsArgument { - ///The name of the argument - pub name: ::std::string::String, - ///The value of the argument to use for completion matching. - pub value: ::std::string::String, + pub ref_: CompleteRequestRef, } -///CompleteRequestParamsRef +///CompleteRequestRef /// ///
JSON schema /// @@ -888,16 +906,16 @@ pub struct CompleteRequestParamsArgument { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] #[serde(untagged)] -pub enum CompleteRequestParamsRef { +pub enum CompleteRequestRef { PromptReference(PromptReference), ResourceReference(ResourceReference), } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: PromptReference) -> Self { Self::PromptReference(value) } } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: ResourceReference) -> Self { Self::ResourceReference(value) } @@ -1081,6 +1099,11 @@ impl CreateMessageRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "sampling/createMessage" + pub fn method_value() -> ::std::string::String { + "sampling/createMessage".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "sampling/createMessage".to_string() } @@ -1146,7 +1169,7 @@ impl CreateMessageRequest { pub struct CreateMessageRequestParams { ///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. #[serde(rename = "includeContext", default, skip_serializing_if = "::std::option::Option::is_none")] - pub include_context: ::std::option::Option, + pub include_context: ::std::option::Option, ///The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested. #[serde(rename = "maxTokens")] pub max_tokens: i64, @@ -1169,40 +1192,6 @@ pub struct CreateMessageRequestParams { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub temperature: ::std::option::Option, } -///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", -/// "type": "string", -/// "enum": [ -/// "allServers", -/// "none", -/// "thisServer" -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub enum CreateMessageRequestParamsIncludeContext { - #[serde(rename = "allServers")] - AllServers, - #[serde(rename = "none")] - None, - #[serde(rename = "thisServer")] - ThisServer, -} -impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match *self { - Self::AllServers => write!(f, "allServers"), - Self::None => write!(f, "none"), - Self::ThisServer => write!(f, "thisServer"), - } - } -} ///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. /// ///
JSON schema @@ -1377,6 +1366,11 @@ impl EmbeddedResource { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "resource" + pub fn type_value() -> ::std::string::String { + "resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "resource".to_string() } @@ -1517,6 +1511,11 @@ impl GetPromptRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/get" + pub fn method_value() -> ::std::string::String { + "prompts/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/get".to_string() } @@ -1673,6 +1672,11 @@ impl ImageContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "image" + pub fn type_value() -> ::std::string::String { + "image".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "image".to_string() } @@ -1739,6 +1743,40 @@ pub struct Implementation { pub name: ::std::string::String, pub version: ::std::string::String, } +///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", +/// "type": "string", +/// "enum": [ +/// "allServers", +/// "none", +/// "thisServer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum IncludeContext { + #[serde(rename = "allServers")] + AllServers, + #[serde(rename = "none")] + None, + #[serde(rename = "thisServer")] + ThisServer, +} +impl ::std::fmt::Display for IncludeContext { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::AllServers => write!(f, "allServers"), + Self::None => write!(f, "none"), + Self::ThisServer => write!(f, "thisServer"), + } + } +} ///This request is sent from the client to the server when it first connects, asking it to begin initialization. /// ///
JSON schema @@ -1796,6 +1834,11 @@ impl InitializeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "initialize" + pub fn method_value() -> ::std::string::String { + "initialize".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "initialize".to_string() } @@ -1937,6 +1980,11 @@ impl InitializedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/initialized" + pub fn method_value() -> ::std::string::String { + "notifications/initialized".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/initialized".to_string() } @@ -2372,6 +2420,11 @@ impl ListPromptsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/list" + pub fn method_value() -> ::std::string::String { + "prompts/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/list".to_string() } @@ -2487,6 +2540,11 @@ impl ListResourceTemplatesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/templates/list" + pub fn method_value() -> ::std::string::String { + "resources/templates/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/templates/list".to_string() } @@ -2603,6 +2661,11 @@ impl ListResourcesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/list" + pub fn method_value() -> ::std::string::String { + "resources/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/list".to_string() } @@ -2729,6 +2792,11 @@ impl ListRootsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "roots/list" + pub fn method_value() -> ::std::string::String { + "roots/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "roots/list".to_string() } @@ -2866,6 +2934,11 @@ impl ListToolsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/list" + pub fn method_value() -> ::std::string::String { + "tools/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/list".to_string() } @@ -3048,6 +3121,11 @@ impl LoggingMessageNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/message" + pub fn method_value() -> ::std::string::String { + "notifications/message".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/message".to_string() } @@ -3386,6 +3464,11 @@ impl PingRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "ping" + pub fn method_value() -> ::std::string::String { + "ping".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "ping".to_string() } @@ -3499,6 +3582,11 @@ impl ProgressNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/progress" + pub fn method_value() -> ::std::string::String { + "notifications/progress".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/progress".to_string() } @@ -3694,6 +3782,11 @@ impl PromptListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/prompts/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/prompts/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/prompts/list_changed".to_string() } @@ -3848,10 +3941,48 @@ impl PromptReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/prompt" + pub fn type_value() -> ::std::string::String { + "ref/prompt".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/prompt".to_string() } } +///ReadResourceContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/definitions/TextResourceContents" +/// }, +/// { +/// "$ref": "#/definitions/BlobResourceContents" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ReadResourceContent { + TextResourceContents(TextResourceContents), + BlobResourceContents(BlobResourceContents), +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: TextResourceContents) -> Self { + Self::TextResourceContents(value) + } +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: BlobResourceContents) -> Self { + Self::BlobResourceContents(value) + } +} ///Sent from the client to the server, to read a specific resource URI. /// ///
JSON schema @@ -3902,6 +4033,11 @@ impl ReadResourceRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/read" + pub fn method_value() -> ::std::string::String { + "resources/read".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/read".to_string() } @@ -3967,44 +4103,11 @@ pub struct ReadResourceRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ReadResourceResult { - pub contents: ::std::vec::Vec, + pub contents: ::std::vec::Vec, ///This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///ReadResourceResultContentsItem -/// -///
JSON schema -/// -/// ```json -///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextResourceContents" -/// }, -/// { -/// "$ref": "#/definitions/BlobResourceContents" -/// } -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ReadResourceResultContentsItem { - TextResourceContents(TextResourceContents), - BlobResourceContents(BlobResourceContents), -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: TextResourceContents) -> Self { - Self::TextResourceContents(value) - } -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: BlobResourceContents) -> Self { - Self::BlobResourceContents(value) - } -} ///Request /// ///
JSON schema @@ -4312,6 +4415,11 @@ impl ResourceListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/resources/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/list_changed".to_string() } @@ -4385,6 +4493,11 @@ impl ResourceReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/resource" + pub fn type_value() -> ::std::string::String { + "ref/resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/resource".to_string() } @@ -4543,6 +4656,11 @@ impl ResourceUpdatedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/updated" + pub fn method_value() -> ::std::string::String { + "notifications/resources/updated".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/updated".to_string() } @@ -4715,6 +4833,11 @@ impl RootsListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/roots/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/roots/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/roots/list_changed".to_string() } @@ -5279,6 +5402,11 @@ impl SetLevelRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "logging/setLevel" + pub fn method_value() -> ::std::string::String { + "logging/setLevel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "logging/setLevel".to_string() } @@ -5357,6 +5485,11 @@ impl SubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/subscribe" + pub fn method_value() -> ::std::string::String { + "resources/subscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/subscribe".to_string() } @@ -5449,6 +5582,11 @@ impl TextContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "text" + pub fn type_value() -> ::std::string::String { + "text".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "text".to_string() } @@ -5650,6 +5788,11 @@ impl ToolInputSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "object".to_string() } @@ -5702,6 +5845,11 @@ impl ToolListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/tools/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/tools/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/tools/list_changed".to_string() } @@ -5782,6 +5930,11 @@ impl UnsubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/unsubscribe" + pub fn method_value() -> ::std::string::String { + "resources/unsubscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/unsubscribe".to_string() } @@ -6049,5 +6202,17 @@ impl ServerNotification { } } } -#[deprecated(since = "0.3.0", note = "Use `RpcError` instead.")] -pub type JsonrpcErrorError = RpcError; +/// Deprecating the old auto-generated verbose names. +/// These were renamed to clearer, shorter names in v0.8.0. +/// The old names are deprecated but kept for backward-compatibility for a smooth migration period. +/// +#[deprecated(since = "0.8.0", note = "Use `ClientRoots` instead.")] +pub type ClientCapabilitiesRoots = ClientRoots; +#[deprecated(since = "0.8.0", note = "Use `IncludeContext` instead.")] +pub type CreateMessageRequestParamsIncludeContext = IncludeContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestRef` instead.")] +pub type CompleteRequestParamsRef = CompleteRequestRef; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestArgument` instead.")] +pub type CompleteRequestParamsArgument = CompleteRequestArgument; +#[deprecated(since = "0.8.0", note = "Use `ReadResourceContent` instead.")] +pub type ReadResourceResultContentsItem = ReadResourceContent; diff --git a/src/generated_schema/2024_11_05/schema_utils.rs b/src/generated_schema/2024_11_05/schema_utils.rs index 66fa72a..bf53f9a 100644 --- a/src/generated_schema/2024_11_05/schema_utils.rs +++ b/src/generated_schema/2024_11_05/schema_utils.rs @@ -1492,7 +1492,7 @@ impl CallToolError { /// # Examples /// /// ``` - /// let err = CallToolError::from_message("Something went wrong"); + /// let err = rust_mcp_schema::schema_utils::CallToolError::from_message("Something went wrong"); /// println!("{:?}", err); /// ``` /// @@ -2608,7 +2608,7 @@ impl SdkError { self } } -/// Enum representing standard JSON-RPC error codes. +/// Enum representing standard and mcp specific JSON-RPC error codes. #[allow(non_camel_case_types)] pub enum RpcErrorCodes { PARSE_ERROR = -32700isize, @@ -2780,7 +2780,7 @@ impl FromStr for RpcError { .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) } } -/// Constructs a new JsonrpcError using the provided arguments. +///Constructs a new `JsonrpcError` using the provided arguments. impl JsonrpcError { pub fn create( id: RequestId, diff --git a/src/generated_schema/2025_03_26/mcp_schema.rs b/src/generated_schema/2025_03_26/mcp_schema.rs index 6387502..928575e 100644 --- a/src/generated_schema/2025_03_26/mcp_schema.rs +++ b/src/generated_schema/2025_03_26/mcp_schema.rs @@ -1,12 +1,15 @@ +/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) +/// Licensed under the MIT License. See LICENSE in the project root. +/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- -/// This file is auto-generated by mcp-schema-gen v0.4.4. +/// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: /// It is not recommended to modify this file directly. You are free to /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : 71204c22f8e062795dca00a87d31070033572ba2 -/// Generated at : 2025-10-03 15:17:03 +/// Hash : UNKNOWN +/// Generated at : 2025-12-01 14:17:33 /// ---------------------------------------------------------------------------- /// use super::validators as validate; @@ -123,6 +126,11 @@ impl AudioContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "audio" + pub fn type_value() -> ::std::string::String { + "audio".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "audio".to_string() } @@ -219,6 +227,11 @@ impl CallToolRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/call" + pub fn method_value() -> ::std::string::String { + "tools/call".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/call".to_string() } @@ -420,6 +433,11 @@ impl CancelledNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/cancelled" + pub fn method_value() -> ::std::string::String { + "notifications/cancelled".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/cancelled".to_string() } @@ -501,34 +519,11 @@ pub struct ClientCapabilities { ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, >, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub roots: ::std::option::Option, + pub roots: ::std::option::Option, ///Present if the client supports sampling from an LLM. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub sampling: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///Present if the client supports listing roots. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "Present if the client supports listing roots.", -/// "type": "object", -/// "properties": { -/// "listChanged": { -/// "description": "Whether the client supports notifications for changes to the roots list.", -/// "type": "boolean" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ClientCapabilitiesRoots { - ///Whether the client supports notifications for changes to the roots list. - #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] - pub list_changed: ::std::option::Option, -} ///ClientNotification /// ///
JSON schema @@ -754,6 +749,29 @@ impl ::std::convert::From for ClientResult { Self::Result(value) } } +///Present if the client supports listing roots. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports listing roots.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether the client supports notifications for changes to the roots list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientRoots { + ///Whether the client supports notifications for changes to the roots list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} ///A request from the client to the server, to ask for completion options. /// ///
JSON schema @@ -828,10 +846,47 @@ impl CompleteRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "completion/complete" + pub fn method_value() -> ::std::string::String { + "completion/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "completion/complete".to_string() } } +///The argument's information +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The argument's information", +/// "type": "object", +/// "required": [ +/// "name", +/// "value" +/// ], +/// "properties": { +/// "name": { +/// "description": "The name of the argument", +/// "type": "string" +/// }, +/// "value": { +/// "description": "The value of the argument to use for completion matching.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequestArgument { + ///The name of the argument + pub name: ::std::string::String, + ///The value of the argument to use for completion matching. + pub value: ::std::string::String, +} ///CompleteRequestParams /// ///
JSON schema @@ -878,43 +933,11 @@ impl CompleteRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CompleteRequestParams { - pub argument: CompleteRequestParamsArgument, + pub argument: CompleteRequestArgument, #[serde(rename = "ref")] - pub ref_: CompleteRequestParamsRef, -} -///The argument's information -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "The argument's information", -/// "type": "object", -/// "required": [ -/// "name", -/// "value" -/// ], -/// "properties": { -/// "name": { -/// "description": "The name of the argument", -/// "type": "string" -/// }, -/// "value": { -/// "description": "The value of the argument to use for completion matching.", -/// "type": "string" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct CompleteRequestParamsArgument { - ///The name of the argument - pub name: ::std::string::String, - ///The value of the argument to use for completion matching. - pub value: ::std::string::String, + pub ref_: CompleteRequestRef, } -///CompleteRequestParamsRef +///CompleteRequestRef /// ///
JSON schema /// @@ -933,16 +956,16 @@ pub struct CompleteRequestParamsArgument { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] #[serde(untagged)] -pub enum CompleteRequestParamsRef { +pub enum CompleteRequestRef { PromptReference(PromptReference), ResourceReference(ResourceReference), } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: PromptReference) -> Self { Self::PromptReference(value) } } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: ResourceReference) -> Self { Self::ResourceReference(value) } @@ -1039,6 +1062,48 @@ pub struct CompleteResultCompletion { ///An array of completion values. Must not exceed 100 items. pub values: ::std::vec::Vec<::std::string::String>, } +///CreateMessageContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/definitions/TextContent" +/// }, +/// { +/// "$ref": "#/definitions/ImageContent" +/// }, +/// { +/// "$ref": "#/definitions/AudioContent" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum CreateMessageContent { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} ///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. /// ///
JSON schema @@ -1126,6 +1191,11 @@ impl CreateMessageRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "sampling/createMessage" + pub fn method_value() -> ::std::string::String { + "sampling/createMessage".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "sampling/createMessage".to_string() } @@ -1191,7 +1261,7 @@ impl CreateMessageRequest { pub struct CreateMessageRequestParams { ///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. #[serde(rename = "includeContext", default, skip_serializing_if = "::std::option::Option::is_none")] - pub include_context: ::std::option::Option, + pub include_context: ::std::option::Option, ///The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested. #[serde(rename = "maxTokens")] pub max_tokens: i64, @@ -1214,40 +1284,6 @@ pub struct CreateMessageRequestParams { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub temperature: ::std::option::Option, } -///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", -/// "type": "string", -/// "enum": [ -/// "allServers", -/// "none", -/// "thisServer" -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub enum CreateMessageRequestParamsIncludeContext { - #[serde(rename = "allServers")] - AllServers, - #[serde(rename = "none")] - None, - #[serde(rename = "thisServer")] - ThisServer, -} -impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match *self { - Self::AllServers => write!(f, "allServers"), - Self::None => write!(f, "none"), - Self::ThisServer => write!(f, "thisServer"), - } - } -} ///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. /// ///
JSON schema @@ -1297,7 +1333,7 @@ impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CreateMessageResult { - pub content: CreateMessageResultContent, + pub content: CreateMessageContent, ///This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, @@ -1308,48 +1344,6 @@ pub struct CreateMessageResult { #[serde(rename = "stopReason", default, skip_serializing_if = "::std::option::Option::is_none")] pub stop_reason: ::std::option::Option<::std::string::String>, } -///CreateMessageResultContent -/// -///
JSON schema -/// -/// ```json -///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextContent" -/// }, -/// { -/// "$ref": "#/definitions/ImageContent" -/// }, -/// { -/// "$ref": "#/definitions/AudioContent" -/// } -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum CreateMessageResultContent { - TextContent(TextContent), - ImageContent(ImageContent), - AudioContent(AudioContent), -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: TextContent) -> Self { - Self::TextContent(value) - } -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: ImageContent) -> Self { - Self::ImageContent(value) - } -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: AudioContent) -> Self { - Self::AudioContent(value) - } -} ///An opaque token used to represent a cursor for pagination. /// ///
JSON schema @@ -1421,6 +1415,11 @@ impl EmbeddedResource { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "resource" + pub fn type_value() -> ::std::string::String { + "resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "resource".to_string() } @@ -1527,6 +1526,11 @@ impl GetPromptRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/get" + pub fn method_value() -> ::std::string::String { + "prompts/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/get".to_string() } @@ -1670,6 +1674,11 @@ impl ImageContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "image" + pub fn type_value() -> ::std::string::String { + "image".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "image".to_string() } @@ -1702,6 +1711,40 @@ pub struct Implementation { pub name: ::std::string::String, pub version: ::std::string::String, } +///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", +/// "type": "string", +/// "enum": [ +/// "allServers", +/// "none", +/// "thisServer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum IncludeContext { + #[serde(rename = "allServers")] + AllServers, + #[serde(rename = "none")] + None, + #[serde(rename = "thisServer")] + ThisServer, +} +impl ::std::fmt::Display for IncludeContext { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::AllServers => write!(f, "allServers"), + Self::None => write!(f, "none"), + Self::ThisServer => write!(f, "thisServer"), + } + } +} ///This request is sent from the client to the server when it first connects, asking it to begin initialization. /// ///
JSON schema @@ -1759,6 +1802,11 @@ impl InitializeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "initialize" + pub fn method_value() -> ::std::string::String { + "initialize".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "initialize".to_string() } @@ -1900,6 +1948,11 @@ impl InitializedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/initialized" + pub fn method_value() -> ::std::string::String { + "notifications/initialized".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/initialized".to_string() } @@ -2468,6 +2521,11 @@ impl ListPromptsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/list" + pub fn method_value() -> ::std::string::String { + "prompts/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/list".to_string() } @@ -2583,6 +2641,11 @@ impl ListResourceTemplatesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/templates/list" + pub fn method_value() -> ::std::string::String { + "resources/templates/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/templates/list".to_string() } @@ -2699,6 +2762,11 @@ impl ListResourcesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/list" + pub fn method_value() -> ::std::string::String { + "resources/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/list".to_string() } @@ -2825,6 +2893,11 @@ impl ListRootsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "roots/list" + pub fn method_value() -> ::std::string::String { + "roots/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "roots/list".to_string() } @@ -2962,6 +3035,11 @@ impl ListToolsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/list" + pub fn method_value() -> ::std::string::String { + "tools/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/list".to_string() } @@ -3144,6 +3222,11 @@ impl LoggingMessageNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/message" + pub fn method_value() -> ::std::string::String { + "notifications/message".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/message".to_string() } @@ -3482,6 +3565,11 @@ impl PingRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "ping" + pub fn method_value() -> ::std::string::String { + "ping".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "ping".to_string() } @@ -3599,6 +3687,11 @@ impl ProgressNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/progress" + pub fn method_value() -> ::std::string::String { + "notifications/progress".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/progress".to_string() } @@ -3801,6 +3894,11 @@ impl PromptListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/prompts/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/prompts/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/prompts/list_changed".to_string() } @@ -3967,10 +4065,48 @@ impl PromptReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/prompt" + pub fn type_value() -> ::std::string::String { + "ref/prompt".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/prompt".to_string() } } +///ReadResourceContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/definitions/TextResourceContents" +/// }, +/// { +/// "$ref": "#/definitions/BlobResourceContents" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ReadResourceContent { + TextResourceContents(TextResourceContents), + BlobResourceContents(BlobResourceContents), +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: TextResourceContents) -> Self { + Self::TextResourceContents(value) + } +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: BlobResourceContents) -> Self { + Self::BlobResourceContents(value) + } +} ///Sent from the client to the server, to read a specific resource URI. /// ///
JSON schema @@ -4021,6 +4157,11 @@ impl ReadResourceRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/read" + pub fn method_value() -> ::std::string::String { + "resources/read".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/read".to_string() } @@ -4086,44 +4227,11 @@ pub struct ReadResourceRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ReadResourceResult { - pub contents: ::std::vec::Vec, + pub contents: ::std::vec::Vec, ///This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///ReadResourceResultContentsItem -/// -///
JSON schema -/// -/// ```json -///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextResourceContents" -/// }, -/// { -/// "$ref": "#/definitions/BlobResourceContents" -/// } -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ReadResourceResultContentsItem { - TextResourceContents(TextResourceContents), - BlobResourceContents(BlobResourceContents), -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: TextResourceContents) -> Self { - Self::TextResourceContents(value) - } -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: BlobResourceContents) -> Self { - Self::BlobResourceContents(value) - } -} ///Request /// ///
JSON schema @@ -4384,6 +4492,11 @@ impl ResourceListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/resources/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/list_changed".to_string() } @@ -4457,6 +4570,11 @@ impl ResourceReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/resource" + pub fn type_value() -> ::std::string::String { + "ref/resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/resource".to_string() } @@ -4568,6 +4686,11 @@ impl ResourceUpdatedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/updated" + pub fn method_value() -> ::std::string::String { + "notifications/resources/updated".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/updated".to_string() } @@ -4740,6 +4863,11 @@ impl RootsListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/roots/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/roots/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/roots/list_changed".to_string() } @@ -5324,6 +5452,11 @@ impl SetLevelRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "logging/setLevel" + pub fn method_value() -> ::std::string::String { + "logging/setLevel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "logging/setLevel".to_string() } @@ -5402,6 +5535,11 @@ impl SubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/subscribe" + pub fn method_value() -> ::std::string::String { + "resources/subscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/subscribe".to_string() } @@ -5481,6 +5619,11 @@ impl TextContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "text" + pub fn type_value() -> ::std::string::String { + "text".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "text".to_string() } @@ -5723,6 +5866,11 @@ impl ToolInputSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "object".to_string() } @@ -5775,6 +5923,11 @@ impl ToolListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/tools/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/tools/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/tools/list_changed".to_string() } @@ -5855,6 +6008,11 @@ impl UnsubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/unsubscribe" + pub fn method_value() -> ::std::string::String { + "resources/unsubscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/unsubscribe".to_string() } @@ -6122,5 +6280,19 @@ impl ServerNotification { } } } -#[deprecated(since = "0.3.0", note = "Use `RpcError` instead.")] -pub type JsonrpcErrorError = RpcError; +/// Deprecating the old auto-generated verbose names. +/// These were renamed to clearer, shorter names in v0.8.0. +/// The old names are deprecated but kept for backward-compatibility for a smooth migration period. +/// +#[deprecated(since = "0.8.0", note = "Use `ClientRoots` instead.")] +pub type ClientCapabilitiesRoots = ClientRoots; +#[deprecated(since = "0.8.0", note = "Use `IncludeContext` instead.")] +pub type CreateMessageRequestParamsIncludeContext = IncludeContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestRef` instead.")] +pub type CompleteRequestParamsRef = CompleteRequestRef; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestArgument` instead.")] +pub type CompleteRequestParamsArgument = CompleteRequestArgument; +#[deprecated(since = "0.8.0", note = "Use `CreateMessageContent` instead.")] +pub type CreateMessageResultContent = CreateMessageContent; +#[deprecated(since = "0.8.0", note = "Use `ReadResourceContent` instead.")] +pub type ReadResourceResultContentsItem = ReadResourceContent; diff --git a/src/generated_schema/2025_03_26/schema_utils.rs b/src/generated_schema/2025_03_26/schema_utils.rs index be14dcd..284db1d 100644 --- a/src/generated_schema/2025_03_26/schema_utils.rs +++ b/src/generated_schema/2025_03_26/schema_utils.rs @@ -1492,7 +1492,7 @@ impl CallToolError { /// # Examples /// /// ``` - /// let err = CallToolError::from_message("Something went wrong"); + /// let err = rust_mcp_schema::schema_utils::CallToolError::from_message("Something went wrong"); /// println!("{:?}", err); /// ``` /// @@ -2608,7 +2608,7 @@ impl SdkError { self } } -/// Enum representing standard JSON-RPC error codes. +/// Enum representing standard and mcp specific JSON-RPC error codes. #[allow(non_camel_case_types)] pub enum RpcErrorCodes { PARSE_ERROR = -32700isize, @@ -2780,7 +2780,7 @@ impl FromStr for RpcError { .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) } } -/// Constructs a new JsonrpcError using the provided arguments. +///Constructs a new `JsonrpcError` using the provided arguments. impl JsonrpcError { pub fn create( id: RequestId, diff --git a/src/generated_schema/2025_06_18/mcp_schema.rs b/src/generated_schema/2025_06_18/mcp_schema.rs index 8154108..9f6c596 100644 --- a/src/generated_schema/2025_06_18/mcp_schema.rs +++ b/src/generated_schema/2025_06_18/mcp_schema.rs @@ -1,12 +1,15 @@ +/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) +/// Licensed under the MIT License. See LICENSE in the project root. +/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- -/// This file is auto-generated by mcp-schema-gen v0.4.4. +/// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: /// It is not recommended to modify this file directly. You are free to /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : 71204c22f8e062795dca00a87d31070033572ba2 -/// Generated at : 2025-10-03 15:17:04 +/// Hash : UNKNOWN +/// Generated at : 2025-12-01 14:17:33 /// ---------------------------------------------------------------------------- /// use super::validators as validate; @@ -84,7 +87,7 @@ pub struct Annotations { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -116,7 +119,7 @@ pub struct AudioContent { pub annotations: ::std::option::Option, ///The base64-encoded audio data. pub data: ::std::string::String, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of the audio. Different providers may support different audio types. @@ -143,6 +146,11 @@ impl AudioContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "audio" + pub fn type_value() -> ::std::string::String { + "audio".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "audio".to_string() } @@ -196,7 +204,7 @@ pub struct BaseMetadata { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -222,7 +230,7 @@ pub struct BaseMetadata { pub struct BlobResourceContents { ///A base64-encoded string representing the binary data of the item. pub blob: ::std::string::String, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -286,6 +294,11 @@ impl BooleanSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "boolean" + pub fn type_value() -> ::std::string::String { + "boolean".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "boolean".to_string() } @@ -342,6 +355,11 @@ impl CallToolRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/call" + pub fn method_value() -> ::std::string::String { + "tools/call".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/call".to_string() } @@ -387,7 +405,7 @@ pub struct CallToolRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -426,7 +444,7 @@ pub struct CallToolResult { should be reported as an MCP error response.*/ #[serde(rename = "isError", default, skip_serializing_if = "::std::option::Option::is_none")] pub is_error: ::std::option::Option, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///An optional JSON object that represents the structured result of the tool call. @@ -493,6 +511,11 @@ impl CancelledNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/cancelled" + pub fn method_value() -> ::std::string::String { + "notifications/cancelled".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/cancelled".to_string() } @@ -582,34 +605,11 @@ pub struct ClientCapabilities { ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, >, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub roots: ::std::option::Option, + pub roots: ::std::option::Option, ///Present if the client supports sampling from an LLM. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub sampling: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///Present if the client supports listing roots. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "Present if the client supports listing roots.", -/// "type": "object", -/// "properties": { -/// "listChanged": { -/// "description": "Whether the client supports notifications for changes to the roots list.", -/// "type": "boolean" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ClientCapabilitiesRoots { - ///Whether the client supports notifications for changes to the roots list. - #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] - pub list_changed: ::std::option::Option, -} ///ClientNotification /// ///
JSON schema @@ -844,6 +844,29 @@ impl ::std::convert::From for ClientResult { Self::Result(value) } } +///Present if the client supports listing roots. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports listing roots.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether the client supports notifications for changes to the roots list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientRoots { + ///Whether the client supports notifications for changes to the roots list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} ///A request from the client to the server, to ask for completion options. /// ///
JSON schema @@ -931,10 +954,73 @@ impl CompleteRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "completion/complete" + pub fn method_value() -> ::std::string::String { + "completion/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "completion/complete".to_string() } } +///The argument's information +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The argument's information", +/// "type": "object", +/// "required": [ +/// "name", +/// "value" +/// ], +/// "properties": { +/// "name": { +/// "description": "The name of the argument", +/// "type": "string" +/// }, +/// "value": { +/// "description": "The value of the argument to use for completion matching.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequestArgument { + ///The name of the argument + pub name: ::std::string::String, + ///The value of the argument to use for completion matching. + pub value: ::std::string::String, +} +///Additional, optional context for completions +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Additional, optional context for completions", +/// "type": "object", +/// "properties": { +/// "arguments": { +/// "description": "Previously-resolved variables in a URI template or prompt.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "string" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CompleteRequestContext { + ///Previously-resolved variables in a URI template or prompt. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub arguments: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>, +} ///CompleteRequestParams /// ///
JSON schema @@ -994,71 +1080,13 @@ impl CompleteRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CompleteRequestParams { - pub argument: CompleteRequestParamsArgument, + pub argument: CompleteRequestArgument, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub context: ::std::option::Option, + pub context: ::std::option::Option, #[serde(rename = "ref")] - pub ref_: CompleteRequestParamsRef, -} -///The argument's information -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "The argument's information", -/// "type": "object", -/// "required": [ -/// "name", -/// "value" -/// ], -/// "properties": { -/// "name": { -/// "description": "The name of the argument", -/// "type": "string" -/// }, -/// "value": { -/// "description": "The value of the argument to use for completion matching.", -/// "type": "string" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct CompleteRequestParamsArgument { - ///The name of the argument - pub name: ::std::string::String, - ///The value of the argument to use for completion matching. - pub value: ::std::string::String, + pub ref_: CompleteRequestRef, } -///Additional, optional context for completions -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "Additional, optional context for completions", -/// "type": "object", -/// "properties": { -/// "arguments": { -/// "description": "Previously-resolved variables in a URI template or prompt.", -/// "type": "object", -/// "additionalProperties": { -/// "type": "string" -/// } -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct CompleteRequestParamsContext { - ///Previously-resolved variables in a URI template or prompt. - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub arguments: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>, -} -///CompleteRequestParamsRef +///CompleteRequestRef /// ///
JSON schema /// @@ -1077,16 +1105,16 @@ pub struct CompleteRequestParamsContext { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] #[serde(untagged)] -pub enum CompleteRequestParamsRef { +pub enum CompleteRequestRef { PromptReference(PromptReference), ResourceTemplateReference(ResourceTemplateReference), } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: PromptReference) -> Self { Self::PromptReference(value) } } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: ResourceTemplateReference) -> Self { Self::ResourceTemplateReference(value) } @@ -1104,7 +1132,7 @@ impl ::std::convert::From for CompleteRequestParamsRe /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -1138,7 +1166,7 @@ impl ::std::convert::From for CompleteRequestParamsRe #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CompleteResult { pub completion: CompleteResultCompletion, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } @@ -1243,6 +1271,48 @@ impl ::std::convert::From for ContentBlock { Self::EmbeddedResource(value) } } +///CreateMessageContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/definitions/TextContent" +/// }, +/// { +/// "$ref": "#/definitions/ImageContent" +/// }, +/// { +/// "$ref": "#/definitions/AudioContent" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum CreateMessageContent { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} ///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. /// ///
JSON schema @@ -1330,6 +1400,11 @@ impl CreateMessageRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "sampling/createMessage" + pub fn method_value() -> ::std::string::String { + "sampling/createMessage".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "sampling/createMessage".to_string() } @@ -1395,7 +1470,7 @@ impl CreateMessageRequest { pub struct CreateMessageRequestParams { ///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. #[serde(rename = "includeContext", default, skip_serializing_if = "::std::option::Option::is_none")] - pub include_context: ::std::option::Option, + pub include_context: ::std::option::Option, /**The requested maximum number of tokens to sample (to prevent runaway completions). The client MAY choose to sample fewer tokens than the requested maximum.*/ #[serde(rename = "maxTokens")] @@ -1419,40 +1494,6 @@ pub struct CreateMessageRequestParams { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub temperature: ::std::option::Option, } -///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", -/// "type": "string", -/// "enum": [ -/// "allServers", -/// "none", -/// "thisServer" -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub enum CreateMessageRequestParamsIncludeContext { - #[serde(rename = "allServers")] - AllServers, - #[serde(rename = "none")] - None, - #[serde(rename = "thisServer")] - ThisServer, -} -impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match *self { - Self::AllServers => write!(f, "allServers"), - Self::None => write!(f, "none"), - Self::ThisServer => write!(f, "thisServer"), - } - } -} ///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. /// ///
JSON schema @@ -1468,7 +1509,7 @@ impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -1502,8 +1543,8 @@ impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CreateMessageResult { - pub content: CreateMessageResultContent, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + pub content: CreateMessageContent, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The name of the model that generated the message. @@ -1513,48 +1554,6 @@ pub struct CreateMessageResult { #[serde(rename = "stopReason", default, skip_serializing_if = "::std::option::Option::is_none")] pub stop_reason: ::std::option::Option<::std::string::String>, } -///CreateMessageResultContent -/// -///
JSON schema -/// -/// ```json -///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextContent" -/// }, -/// { -/// "$ref": "#/definitions/ImageContent" -/// }, -/// { -/// "$ref": "#/definitions/AudioContent" -/// } -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum CreateMessageResultContent { - TextContent(TextContent), - ImageContent(ImageContent), - AudioContent(AudioContent), -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: TextContent) -> Self { - Self::TextContent(value) - } -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: ImageContent) -> Self { - Self::ImageContent(value) - } -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: AudioContent) -> Self { - Self::AudioContent(value) - } -} ///An opaque token used to represent a cursor for pagination. /// ///
JSON schema @@ -1645,6 +1644,11 @@ impl ElicitRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "elicitation/create" + pub fn method_value() -> ::std::string::String { + "elicitation/create".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "elicitation/create".to_string() } @@ -1758,6 +1762,11 @@ impl ElicitRequestedSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "object".to_string() } @@ -1775,7 +1784,7 @@ impl ElicitRequestedSchema { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -1813,8 +1822,8 @@ pub struct ElicitResult { /**The submitted form data, only present when action is "accept". Contains values matching the requested schema.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub content: ::std::option::Option<::std::collections::HashMap<::std::string::String, ElicitResultContentValue>>, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + pub content: ::std::option::Option<::std::collections::HashMap<::std::string::String, ElicitResultContent>>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } @@ -1855,7 +1864,7 @@ impl ::std::fmt::Display for ElicitResultAction { } } } -///ElicitResultContentValue +///ElicitResultContent /// ///
JSON schema /// @@ -1871,17 +1880,17 @@ impl ::std::fmt::Display for ElicitResultAction { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] #[serde(untagged)] -pub enum ElicitResultContentValue { +pub enum ElicitResultContent { Boolean(bool), String(::std::string::String), Integer(i64), } -impl ::std::convert::From for ElicitResultContentValue { +impl ::std::convert::From for ElicitResultContent { fn from(value: bool) -> Self { Self::Boolean(value) } } -impl ::std::convert::From for ElicitResultContentValue { +impl ::std::convert::From for ElicitResultContent { fn from(value: i64) -> Self { Self::Integer(value) } @@ -1902,7 +1911,7 @@ of the LLM and/or the user.*/ /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -1933,7 +1942,7 @@ pub struct EmbeddedResource { ///Optional annotations for the client. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub annotations: ::std::option::Option, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, pub resource: EmbeddedResourceResource, @@ -1956,6 +1965,11 @@ impl EmbeddedResource { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "resource" + pub fn type_value() -> ::std::string::String { + "resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "resource".to_string() } @@ -2075,6 +2089,11 @@ impl EnumSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "string".to_string() } @@ -2135,6 +2154,11 @@ impl GetPromptRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/get" + pub fn method_value() -> ::std::string::String { + "prompts/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/get".to_string() } @@ -2186,7 +2210,7 @@ pub struct GetPromptRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -2210,7 +2234,7 @@ pub struct GetPromptResult { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, pub messages: ::std::vec::Vec, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } @@ -2229,7 +2253,7 @@ pub struct GetPromptResult { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -2261,7 +2285,7 @@ pub struct ImageContent { pub annotations: ::std::option::Option, ///The base64-encoded image data. pub data: ::std::string::String, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of the image. Different providers may support different image types. @@ -2288,6 +2312,11 @@ impl ImageContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "image" + pub fn type_value() -> ::std::string::String { + "image".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "image".to_string() } @@ -2333,6 +2362,40 @@ pub struct Implementation { pub title: ::std::option::Option<::std::string::String>, pub version: ::std::string::String, } +///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", +/// "type": "string", +/// "enum": [ +/// "allServers", +/// "none", +/// "thisServer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum IncludeContext { + #[serde(rename = "allServers")] + AllServers, + #[serde(rename = "none")] + None, + #[serde(rename = "thisServer")] + ThisServer, +} +impl ::std::fmt::Display for IncludeContext { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::AllServers => write!(f, "allServers"), + Self::None => write!(f, "none"), + Self::ThisServer => write!(f, "thisServer"), + } + } +} ///This request is sent from the client to the server when it first connects, asking it to begin initialization. /// ///
JSON schema @@ -2390,6 +2453,11 @@ impl InitializeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "initialize" + pub fn method_value() -> ::std::string::String { + "initialize".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "initialize".to_string() } @@ -2445,7 +2513,7 @@ pub struct InitializeRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -2474,7 +2542,7 @@ pub struct InitializeResult { This 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.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub instructions: ::std::option::Option<::std::string::String>, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///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. @@ -2503,7 +2571,7 @@ pub struct InitializeResult { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -2531,6 +2599,11 @@ impl InitializedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/initialized" + pub fn method_value() -> ::std::string::String { + "notifications/initialized".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/initialized".to_string() } @@ -2544,7 +2617,7 @@ impl InitializedNotification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -2555,7 +2628,7 @@ impl InitializedNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct InitializedNotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -2701,7 +2774,7 @@ impl ::std::convert::From for JsonrpcMessage { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -2741,7 +2814,7 @@ impl JsonrpcNotification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -2752,7 +2825,7 @@ impl JsonrpcNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct JsonrpcNotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -2786,7 +2859,7 @@ pub struct JsonrpcNotificationParams { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -2834,7 +2907,7 @@ impl JsonrpcRequest { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -2856,13 +2929,13 @@ pub struct JsonrpcRequestParams { #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -2975,6 +3048,11 @@ impl ListPromptsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/list" + pub fn method_value() -> ::std::string::String { + "prompts/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/list".to_string() } @@ -3015,7 +3093,7 @@ pub struct ListPromptsRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3035,7 +3113,7 @@ pub struct ListPromptsRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListPromptsResult { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3090,6 +3168,11 @@ impl ListResourceTemplatesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/templates/list" + pub fn method_value() -> ::std::string::String { + "resources/templates/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/templates/list".to_string() } @@ -3130,7 +3213,7 @@ pub struct ListResourceTemplatesRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3150,7 +3233,7 @@ pub struct ListResourceTemplatesRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListResourceTemplatesResult { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3206,6 +3289,11 @@ impl ListResourcesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/list" + pub fn method_value() -> ::std::string::String { + "resources/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/list".to_string() } @@ -3246,7 +3334,7 @@ pub struct ListResourcesRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3266,7 +3354,7 @@ pub struct ListResourcesRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListResourcesResult { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3300,7 +3388,7 @@ structure or access specific locations that the client has permission to read fr /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -3334,6 +3422,11 @@ impl ListRootsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "roots/list" + pub fn method_value() -> ::std::string::String { + "roots/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "roots/list".to_string() } @@ -3347,7 +3440,7 @@ impl ListRootsRequest { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -3369,13 +3462,13 @@ pub struct ListRootsRequestParams { #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -3410,7 +3503,7 @@ or file that the server can operate on.*/ /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3426,7 +3519,7 @@ or file that the server can operate on.*/ ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListRootsResult { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, pub roots: ::std::vec::Vec, @@ -3477,6 +3570,11 @@ impl ListToolsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/list" + pub fn method_value() -> ::std::string::String { + "tools/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/list".to_string() } @@ -3517,7 +3615,7 @@ pub struct ListToolsRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3537,7 +3635,7 @@ pub struct ListToolsRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListToolsResult { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3659,6 +3757,11 @@ impl LoggingMessageNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/message" + pub fn method_value() -> ::std::string::String { + "notifications/message".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/message".to_string() } @@ -3815,7 +3918,7 @@ pub struct ModelPreferences { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -3841,7 +3944,7 @@ pub struct Notification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -3852,7 +3955,7 @@ pub struct Notification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct NotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -3999,7 +4102,7 @@ pub struct PaginatedRequestParams { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4013,7 +4116,7 @@ pub struct PaginatedRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct PaginatedResult { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -4041,7 +4144,7 @@ pub struct PaginatedResult { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -4075,6 +4178,11 @@ impl PingRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "ping" + pub fn method_value() -> ::std::string::String { + "ping".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "ping".to_string() } @@ -4088,7 +4196,7 @@ impl PingRequest { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -4110,13 +4218,13 @@ pub struct PingRequestParams { #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -4251,6 +4359,11 @@ impl ProgressNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/progress" + pub fn method_value() -> ::std::string::String { + "notifications/progress".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/progress".to_string() } @@ -4337,7 +4450,7 @@ impl ::std::convert::From for ProgressToken { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4372,7 +4485,7 @@ pub struct Prompt { ///An optional description of what this prompt provides #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). @@ -4455,7 +4568,7 @@ pub struct PromptArgument { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -4483,6 +4596,11 @@ impl PromptListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/prompts/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/prompts/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/prompts/list_changed".to_string() } @@ -4496,7 +4614,7 @@ impl PromptListChangedNotification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -4507,7 +4625,7 @@ impl PromptListChangedNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct PromptListChangedNotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -4597,10 +4715,48 @@ impl PromptReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/prompt" + pub fn type_value() -> ::std::string::String { + "ref/prompt".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/prompt".to_string() } } +///ReadResourceContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/definitions/TextResourceContents" +/// }, +/// { +/// "$ref": "#/definitions/BlobResourceContents" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ReadResourceContent { + TextResourceContents(TextResourceContents), + BlobResourceContents(BlobResourceContents), +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: TextResourceContents) -> Self { + Self::TextResourceContents(value) + } +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: BlobResourceContents) -> Self { + Self::BlobResourceContents(value) + } +} ///Sent from the client to the server, to read a specific resource URI. /// ///
JSON schema @@ -4651,6 +4807,11 @@ impl ReadResourceRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/read" + pub fn method_value() -> ::std::string::String { + "resources/read".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/read".to_string() } @@ -4693,7 +4854,7 @@ pub struct ReadResourceRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4716,44 +4877,11 @@ pub struct ReadResourceRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ReadResourceResult { - pub contents: ::std::vec::Vec, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + pub contents: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///ReadResourceResultContentsItem -/// -///
JSON schema -/// -/// ```json -///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextResourceContents" -/// }, -/// { -/// "$ref": "#/definitions/BlobResourceContents" -/// } -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ReadResourceResultContentsItem { - TextResourceContents(TextResourceContents), - BlobResourceContents(BlobResourceContents), -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: TextResourceContents) -> Self { - Self::TextResourceContents(value) - } -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: BlobResourceContents) -> Self { - Self::BlobResourceContents(value) - } -} ///Request /// ///
JSON schema @@ -4772,7 +4900,7 @@ impl ::std::convert::From for ReadResourceResultContentsIt /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -4829,7 +4957,7 @@ impl ::std::convert::From for RequestId { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -4851,13 +4979,13 @@ pub struct RequestParams { #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "progressToken": { @@ -4891,7 +5019,7 @@ pub struct RequestParamsMeta { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4937,7 +5065,7 @@ pub struct Resource { This 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.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -4972,7 +5100,7 @@ pub struct Resource { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4991,7 +5119,7 @@ pub struct Resource { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ResourceContents { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -5016,7 +5144,7 @@ Note: resource links returned by tools are not guaranteed to appear in the resul /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -5066,7 +5194,7 @@ pub struct ResourceLink { This 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.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -5117,6 +5245,11 @@ impl ResourceLink { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "resource_link" + pub fn type_value() -> ::std::string::String { + "resource_link".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "resource_link".to_string() } @@ -5141,7 +5274,7 @@ impl ResourceLink { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -5169,6 +5302,11 @@ impl ResourceListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/resources/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/list_changed".to_string() } @@ -5182,7 +5320,7 @@ impl ResourceListChangedNotification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -5193,7 +5331,7 @@ impl ResourceListChangedNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct ResourceListChangedNotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -5213,7 +5351,7 @@ pub struct ResourceListChangedNotificationParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -5255,7 +5393,7 @@ pub struct ResourceTemplate { This 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.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///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. @@ -5317,6 +5455,11 @@ impl ResourceTemplateReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/resource" + pub fn type_value() -> ::std::string::String { + "ref/resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/resource".to_string() } @@ -5371,6 +5514,11 @@ impl ResourceUpdatedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/updated" + pub fn method_value() -> ::std::string::String { + "notifications/resources/updated".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/updated".to_string() } @@ -5409,7 +5557,7 @@ pub struct ResourceUpdatedNotificationParams { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -5420,7 +5568,7 @@ pub struct ResourceUpdatedNotificationParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct Result { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -5469,7 +5617,7 @@ impl ::std::fmt::Display for Role { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -5488,7 +5636,7 @@ impl ::std::fmt::Display for Role { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct Root { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An optional name for the root. This can be used to provide a human-readable @@ -5523,7 +5671,7 @@ The server should then request an updated list of roots using the ListRootsReque /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -5551,6 +5699,11 @@ impl RootsListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/roots/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/roots/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/roots/list_changed".to_string() } @@ -5564,7 +5717,7 @@ impl RootsListChangedNotification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -5575,7 +5728,7 @@ impl RootsListChangedNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct RootsListChangedNotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -6144,6 +6297,11 @@ impl SetLevelRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "logging/setLevel" + pub fn method_value() -> ::std::string::String { + "logging/setLevel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "logging/setLevel".to_string() } @@ -6247,6 +6405,11 @@ impl StringSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "string".to_string() } @@ -6338,6 +6501,11 @@ impl SubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/subscribe" + pub fn method_value() -> ::std::string::String { + "resources/subscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/subscribe".to_string() } @@ -6381,7 +6549,7 @@ pub struct SubscribeRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -6406,7 +6574,7 @@ pub struct TextContent { ///Optional annotations for the client. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub annotations: ::std::option::Option, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The text content of the message. @@ -6430,6 +6598,11 @@ impl TextContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "text" + pub fn type_value() -> ::std::string::String { + "text".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "text".to_string() } @@ -6447,7 +6620,7 @@ impl TextContent { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -6470,7 +6643,7 @@ impl TextContent { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct TextResourceContents { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -6495,7 +6668,7 @@ pub struct TextResourceContents { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -6583,7 +6756,7 @@ pub struct Tool { pub description: ::std::option::Option<::std::string::String>, #[serde(rename = "inputSchema")] pub input_schema: ToolInputSchema, - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). @@ -6728,6 +6901,11 @@ impl ToolInputSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "object".to_string() } @@ -6752,7 +6930,7 @@ impl ToolInputSchema { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -6780,6 +6958,11 @@ impl ToolListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/tools/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/tools/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/tools/list_changed".to_string() } @@ -6793,7 +6976,7 @@ impl ToolListChangedNotification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -6804,7 +6987,7 @@ impl ToolListChangedNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct ToolListChangedNotificationParams { - ///See [General fields: _meta](/specification/2025-06-18/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -6874,6 +7057,11 @@ impl ToolOutputSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "object".to_string() } @@ -6928,6 +7116,11 @@ impl UnsubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/unsubscribe" + pub fn method_value() -> ::std::string::String { + "resources/unsubscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/unsubscribe".to_string() } @@ -7200,7 +7393,25 @@ impl ServerNotification { } } } -#[deprecated(since = "0.3.0", note = "Use `RpcError` instead.")] -pub type JsonrpcErrorError = RpcError; -#[deprecated(since = "0.7.0", note = "Use `ElicitRequestedSchema` instead.")] +/// Deprecating the old auto-generated verbose names. +/// These were renamed to clearer, shorter names in v0.8.0. +/// The old names are deprecated but kept for backward-compatibility for a smooth migration period. +/// +#[deprecated(since = "0.8.0", note = "Use `ClientRoots` instead.")] +pub type ClientCapabilitiesRoots = ClientRoots; +#[deprecated(since = "0.8.0", note = "Use `IncludeContext` instead.")] +pub type CreateMessageRequestParamsIncludeContext = IncludeContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestRef` instead.")] +pub type CompleteRequestParamsRef = CompleteRequestRef; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestContext` instead.")] +pub type CompleteRequestParamsContext = CompleteRequestContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestArgument` instead.")] +pub type CompleteRequestParamsArgument = CompleteRequestArgument; +#[deprecated(since = "0.8.0", note = "Use `ElicitRequestedSchema` instead.")] pub type ElicitRequestParamsRequestedSchema = ElicitRequestedSchema; +#[deprecated(since = "0.8.0", note = "Use `CreateMessageContent` instead.")] +pub type CreateMessageResultContent = CreateMessageContent; +#[deprecated(since = "0.8.0", note = "Use `ElicitResultContent` instead.")] +pub type ElicitResultContentValue = ElicitResultContent; +#[deprecated(since = "0.8.0", note = "Use `ReadResourceContent` instead.")] +pub type ReadResourceResultContentsItem = ReadResourceContent; diff --git a/src/generated_schema/2025_06_18/schema_utils.rs b/src/generated_schema/2025_06_18/schema_utils.rs index 14f3094..daebcab 100644 --- a/src/generated_schema/2025_06_18/schema_utils.rs +++ b/src/generated_schema/2025_06_18/schema_utils.rs @@ -1,4 +1,4 @@ -use crate::generated_schema::*; +use crate::generated_schema::mcp_2025_06_18::*; use serde::ser::SerializeStruct; use serde_json::{json, Value}; use std::hash::{Hash, Hasher}; @@ -2740,7 +2740,7 @@ impl SdkError { self } } -/// Enum representing standard JSON-RPC error codes. +/// Enum representing standard and mcp specific JSON-RPC error codes. #[allow(non_camel_case_types)] pub enum RpcErrorCodes { PARSE_ERROR = -32700isize, @@ -2912,7 +2912,7 @@ impl FromStr for RpcError { .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) } } -/// Constructs a new JsonrpcError using the provided arguments. +///Constructs a new `JsonrpcError` using the provided arguments. impl JsonrpcError { pub fn create( id: RequestId, diff --git a/src/generated_schema/2025_11_25/mcp_schema.rs b/src/generated_schema/2025_11_25/mcp_schema.rs new file mode 100644 index 0000000..bceccd1 --- /dev/null +++ b/src/generated_schema/2025_11_25/mcp_schema.rs @@ -0,0 +1,11209 @@ +/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) +/// Licensed under the MIT License. See LICENSE in the project root. +/// Include this notice in copies or substantial portions of the Software. +/// ---------------------------------------------------------------------------- +/// This file is auto-generated by mcp-schema-gen v0.5.0. +/// WARNING: +/// It is not recommended to modify this file directly. You are free to +/// modify or extend the implementations as needed, but please do so at your own risk. +/// +/// Generated from : +/// Hash : UNKNOWN +/// Generated at : 2025-12-01 14:17:34 +/// ---------------------------------------------------------------------------- +/// +use super::validators as validate; +/// MCP Protocol Version +pub const LATEST_PROTOCOL_VERSION: &str = "2025-11-25"; +/// JSON-RPC Version +pub const JSONRPC_VERSION: &str = "2.0"; +/// Parse error. Invalid JSON was received. An error occurred while parsing the JSON text. +pub const PARSE_ERROR: i64 = -32700i64; +/// Invalid Request. The JSON sent is not a valid Request object. +pub const INVALID_REQUEST: i64 = -32600i64; +/// Method not found. The method does not exist / is not available. +pub const METHOD_NOT_FOUND: i64 = -32601i64; +/// Invalid param. Invalid method parameter(s). +pub const INVALID_PARAMS: i64 = -32602i64; +/// Internal error. Internal JSON-RPC error. +pub const INTERNAL_ERROR: i64 = -32603i64; +/// The server cannot proceed without additional client input. +pub const URL_ELICITATION_REQUIRED: i64 = -32042i64; +///Optional annotations for the client. The client can use annotations to inform how objects are used or displayed +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", +/// "type": "object", +/// "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\"]).", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Role" +/// } +/// }, +/// "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.", +/// "type": "number", +/// "maximum": 1.0, +/// "minimum": 0.0 +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct Annotations { + /**Describes who the intended audience of this object or data is. + It can include multiple entries to indicate content useful for multiple audiences (e.g., ["user", "assistant"]).*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub audience: ::std::vec::Vec, + /**The moment the resource was last modified, as an ISO 8601 formatted string. + Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z"). + Examples: last activity timestamp in an open file, timestamp when the resource + was attached, etc.*/ + #[serde(rename = "lastModified", default, skip_serializing_if = "::std::option::Option::is_none")] + pub last_modified: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub priority: ::std::option::Option, +} +///Audio provided to or from an LLM. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Audio provided to or from an LLM.", +/// "type": "object", +/// "required": [ +/// "data", +/// "mimeType", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "data": { +/// "description": "The base64-encoded audio data.", +/// "type": "string", +/// "format": "byte" +/// }, +/// "mimeType": { +/// "description": "The MIME type of the audio. Different providers may support different audio types.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "audio" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct AudioContent { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + ///The base64-encoded audio data. + pub data: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of the audio. Different providers may support different audio types. + #[serde(rename = "mimeType")] + pub mime_type: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::audio_content_type_")] + type_: ::std::string::String, +} +impl AudioContent { + pub fn new( + data: ::std::string::String, + mime_type: ::std::string::String, + annotations: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + annotations, + data, + meta, + mime_type, + type_: "audio".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "audio" + pub fn type_value() -> ::std::string::String { + "audio".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "audio".to_string() + } +} +///Base interface for metadata with name (identifier) and title (display name) properties. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Base interface for metadata with name (identifier) and title (display name) properties.", +/// "type": "object", +/// "required": [ +/// "name" +/// ], +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct BaseMetadata { + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, +} +///BlobResourceContents +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "blob", +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "blob": { +/// "description": "A base64-encoded string representing the binary data of the item.", +/// "type": "string", +/// "format": "byte" +/// }, +/// "mimeType": { +/// "description": "The MIME type of this resource, if known.", +/// "type": "string" +/// }, +/// "uri": { +/// "description": "The URI of this resource.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct BlobResourceContents { + ///A base64-encoded string representing the binary data of the item. + pub blob: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of this resource, if known. + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + ///The URI of this resource. + pub uri: ::std::string::String, +} +///BooleanSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "type": "boolean" +/// }, +/// "description": { +/// "type": "string" +/// }, +/// "title": { +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct BooleanSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::boolean_schema_type_")] + type_: ::std::string::String, +} +impl BooleanSchema { + pub fn new( + default: ::std::option::Option, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + title, + type_: "boolean".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "boolean" + pub fn type_value() -> ::std::string::String { + "boolean".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "boolean".to_string() + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CallToolMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Used by the client to invoke a tool provided by the server. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Used by the client to invoke a tool provided by the server.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tools/call" +/// }, +/// "params": { +/// "$ref": "#/$defs/CallToolRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CallToolRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::call_tool_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::call_tool_request_method")] + method: ::std::string::String, + pub params: CallToolRequestParams, +} +impl CallToolRequest { + pub fn new(id: RequestId, params: CallToolRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tools/call".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tools/call" + pub fn method_value() -> ::std::string::String { + "tools/call".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tools/call".to_string() + } +} +///Parameters for a tools/call request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a tools/call request.", +/// "type": "object", +/// "required": [ +/// "name" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "arguments": { +/// "description": "Arguments to use for the tool call.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "name": { +/// "description": "The name of the tool.", +/// "type": "string" +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CallToolRequestParams { + ///Arguments to use for the tool call. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub arguments: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The name of the tool. + pub name: ::std::string::String, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, +} +///The server's response to a tool call. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a tool call.", +/// "type": "object", +/// "required": [ +/// "content" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "content": { +/// "description": "A list of content objects that represent the unstructured result of the tool call.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ContentBlock" +/// } +/// }, +/// "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": { +/// "description": "An optional JSON object that represents the structured result of the tool call.", +/// "type": "object", +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CallToolResult { + ///A list of content objects that represent the unstructured result of the tool call. + pub content: ::std::vec::Vec, + /**Whether the tool call ended in an error. + If not set, this is assumed to be false (the call was successful). + Any errors that originate from the tool SHOULD be reported inside the result + object, with isError set to true, _not_ as an MCP protocol-level error + response. Otherwise, the LLM would not be able to see that an error occurred + and self-correct. + However, any errors in _finding_ the tool, an error indicating that the + server does not support tool calls, or any other exceptional conditions, + should be reported as an MCP error response.*/ + #[serde(rename = "isError", default, skip_serializing_if = "::std::option::Option::is_none")] + pub is_error: ::std::option::Option, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///An optional JSON object that represents the structured result of the tool call. + #[serde( + rename = "structuredContent", + default, + skip_serializing_if = "::std::option::Option::is_none" + )] + pub structured_content: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///CancelTaskParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to cancel.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelTaskParams { + ///The task identifier to cancel. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///A request to cancel a task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to cancel a task.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tasks/cancel" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to cancel.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelTaskRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::cancel_task_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::cancel_task_request_method")] + method: ::std::string::String, + pub params: CancelTaskParams, +} +impl CancelTaskRequest { + pub fn new(id: RequestId, params: CancelTaskParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/cancel".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/cancel" + pub fn method_value() -> ::std::string::String { + "tasks/cancel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/cancel".to_string() + } +} +///The response to a tasks/cancel request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The response to a tasks/cancel request.", +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "$ref": "#/$defs/Task" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelTaskResult { + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + pub ttl: i64, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**This notification can be sent by either side to indicate that it is cancelling a previously-issued request. +The 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. +This notification indicates that the result will be unused, so any associated processing SHOULD cease. +A client MUST NOT attempt to cancel its initialize request. +For task cancellation, use the tasks/cancel request instead of this notification.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/cancelled" +/// }, +/// "params": { +/// "$ref": "#/$defs/CancelledNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelledNotification { + #[serde(deserialize_with = "validate::cancelled_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::cancelled_notification_method")] + method: ::std::string::String, + pub params: CancelledNotificationParams, +} +impl CancelledNotification { + pub fn new(params: CancelledNotificationParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/cancelled".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/cancelled" + pub fn method_value() -> ::std::string::String { + "notifications/cancelled".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/cancelled".to_string() + } +} +///Parameters for a notifications/cancelled notification. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a notifications/cancelled notification.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "reason": { +/// "description": "An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.", +/// "type": "string" +/// }, +/// "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).", +/// "$ref": "#/$defs/RequestId" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CancelledNotificationParams { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub reason: ::std::option::Option<::std::string::String>, + /**The ID of the request to cancel. + This MUST correspond to the ID of a request previously issued in the same direction. + This MUST be provided for cancelling non-task requests. + This MUST NOT be used for cancelling tasks (use the tasks/cancel request instead).*/ + #[serde(rename = "requestId", default, skip_serializing_if = "::std::option::Option::is_none")] + pub request_id: ::std::option::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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "properties": { +/// "elicitation": { +/// "description": "Present if the client supports elicitation from the server.", +/// "type": "object", +/// "properties": { +/// "form": { +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "url": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "experimental": { +/// "description": "Experimental, non-standard capabilities that the client supports.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "roots": { +/// "description": "Present if the client supports listing roots.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether the client supports notifications for changes to the roots list.", +/// "type": "boolean" +/// } +/// } +/// }, +/// "sampling": { +/// "description": "Present if the client supports sampling from an LLM.", +/// "type": "object", +/// "properties": { +/// "context": { +/// "description": "Whether the client supports context inclusion via includeContext parameter.\nIf not declared, servers SHOULD only use includeContext: \"none\" (or omit it).", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "tools": { +/// "description": "Whether the client supports tool use via tools and toolChoice parameters.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "tasks": { +/// "description": "Present if the client supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this client supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this client supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "elicitation": { +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "sampling": { +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientCapabilities { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub elicitation: ::std::option::Option, + ///Experimental, non-standard capabilities that the client supports. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub experimental: ::std::option::Option< + ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, + >, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub roots: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sampling: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tasks: ::std::option::Option, +} +///Present if the client supports elicitation from the server. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports elicitation from the server.", +/// "type": "object", +/// "properties": { +/// "form": { +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "url": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientElicitation { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub form: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///ClientNotification +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/CancelledNotification" +/// }, +/// { +/// "$ref": "#/$defs/InitializedNotification" +/// }, +/// { +/// "$ref": "#/$defs/ProgressNotification" +/// }, +/// { +/// "$ref": "#/$defs/TaskStatusNotification" +/// }, +/// { +/// "$ref": "#/$defs/RootsListChangedNotification" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ClientNotification { + CancelledNotification(CancelledNotification), + InitializedNotification(InitializedNotification), + ProgressNotification(ProgressNotification), + TaskStatusNotification(TaskStatusNotification), + RootsListChangedNotification(RootsListChangedNotification), +} +impl ::std::convert::From for ClientNotification { + fn from(value: CancelledNotification) -> Self { + Self::CancelledNotification(value) + } +} +impl ::std::convert::From for ClientNotification { + fn from(value: InitializedNotification) -> Self { + Self::InitializedNotification(value) + } +} +impl ::std::convert::From for ClientNotification { + fn from(value: ProgressNotification) -> Self { + Self::ProgressNotification(value) + } +} +impl ::std::convert::From for ClientNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::TaskStatusNotification(value) + } +} +impl ::std::convert::From for ClientNotification { + fn from(value: RootsListChangedNotification) -> Self { + Self::RootsListChangedNotification(value) + } +} +///ClientRequest +/// +///
JSON schema +/// +/// ```json +///{ +/// "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" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ClientRequest { + InitializeRequest(InitializeRequest), + PingRequest(PingRequest), + ListResourcesRequest(ListResourcesRequest), + ListResourceTemplatesRequest(ListResourceTemplatesRequest), + ReadResourceRequest(ReadResourceRequest), + SubscribeRequest(SubscribeRequest), + UnsubscribeRequest(UnsubscribeRequest), + ListPromptsRequest(ListPromptsRequest), + GetPromptRequest(GetPromptRequest), + ListToolsRequest(ListToolsRequest), + CallToolRequest(CallToolRequest), + GetTaskRequest(GetTaskRequest), + GetTaskPayloadRequest(GetTaskPayloadRequest), + CancelTaskRequest(CancelTaskRequest), + ListTasksRequest(ListTasksRequest), + SetLevelRequest(SetLevelRequest), + CompleteRequest(CompleteRequest), +} +impl ::std::convert::From for ClientRequest { + fn from(value: InitializeRequest) -> Self { + Self::InitializeRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: PingRequest) -> Self { + Self::PingRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ListResourcesRequest) -> Self { + Self::ListResourcesRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ListResourceTemplatesRequest) -> Self { + Self::ListResourceTemplatesRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ReadResourceRequest) -> Self { + Self::ReadResourceRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: SubscribeRequest) -> Self { + Self::SubscribeRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: UnsubscribeRequest) -> Self { + Self::UnsubscribeRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ListPromptsRequest) -> Self { + Self::ListPromptsRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: GetPromptRequest) -> Self { + Self::GetPromptRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ListToolsRequest) -> Self { + Self::ListToolsRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: CallToolRequest) -> Self { + Self::CallToolRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: GetTaskRequest) -> Self { + Self::GetTaskRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::GetTaskPayloadRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: CancelTaskRequest) -> Self { + Self::CancelTaskRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ListTasksRequest) -> Self { + Self::ListTasksRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: SetLevelRequest) -> Self { + Self::SetLevelRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: CompleteRequest) -> Self { + Self::CompleteRequest(value) + } +} +///ClientResult +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "description": "The response to a tasks/get request.", +/// "$ref": "#/$defs/GetTaskResult" +/// }, +/// { +/// "$ref": "#/$defs/GetTaskPayloadResult" +/// }, +/// { +/// "description": "The response to a tasks/cancel request.", +/// "$ref": "#/$defs/CancelTaskResult" +/// }, +/// { +/// "$ref": "#/$defs/ListTasksResult" +/// }, +/// { +/// "$ref": "#/$defs/CreateMessageResult" +/// }, +/// { +/// "$ref": "#/$defs/ListRootsResult" +/// }, +/// { +/// "$ref": "#/$defs/ElicitResult" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ClientResult { + GetTaskResult(GetTaskResult), + GetTaskPayloadResult(GetTaskPayloadResult), + CancelTaskResult(CancelTaskResult), + ListTasksResult(ListTasksResult), + CreateMessageResult(CreateMessageResult), + ListRootsResult(ListRootsResult), + ElicitResult(ElicitResult), + Result(Result), +} +impl ::std::convert::From for ClientResult { + fn from(value: GetTaskResult) -> Self { + Self::GetTaskResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: GetTaskPayloadResult) -> Self { + Self::GetTaskPayloadResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: CancelTaskResult) -> Self { + Self::CancelTaskResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: ListTasksResult) -> Self { + Self::ListTasksResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: CreateMessageResult) -> Self { + Self::CreateMessageResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: ListRootsResult) -> Self { + Self::ListRootsResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: ElicitResult) -> Self { + Self::ElicitResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: Result) -> Self { + Self::Result(value) + } +} +///Present if the client supports listing roots. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports listing roots.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether the client supports notifications for changes to the roots list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientRoots { + ///Whether the client supports notifications for changes to the roots list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} +///Present if the client supports sampling from an LLM. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports sampling from an LLM.", +/// "type": "object", +/// "properties": { +/// "context": { +/// "description": "Whether the client supports context inclusion via includeContext parameter.\nIf not declared, servers SHOULD only use includeContext: \"none\" (or omit it).", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "tools": { +/// "description": "Whether the client supports tool use via tools and toolChoice parameters.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientSampling { + /**Whether the client supports context inclusion via includeContext parameter. + If not declared, servers SHOULD only use includeContext: "none" (or omit it).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub context: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Whether the client supports tool use via tools and toolChoice parameters. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tools: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Task support for elicitation-related requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTaskElicitation { + ///Whether the client supports task-augmented elicitation/create requests. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub create: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Specifies which request types can be augmented with tasks. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "elicitation": { +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "sampling": { +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTaskRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub elicitation: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sampling: ::std::option::Option, +} +///Task support for sampling-related requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTaskSampling { + ///Whether the client supports task-augmented sampling/createMessage requests. + #[serde(rename = "createMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub create_message: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Present if the client supports task-augmented requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this client supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this client supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "elicitation": { +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "sampling": { +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTasks { + ///Whether this client supports tasks/cancel. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cancel: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Whether this client supports tasks/list. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub list: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub requests: ::std::option::Option, +} +///A request from the client to the server, to ask for completion options. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request from the client to the server, to ask for completion options.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "completion/complete" +/// }, +/// "params": { +/// "$ref": "#/$defs/CompleteRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::complete_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::complete_request_method")] + method: ::std::string::String, + pub params: CompleteRequestParams, +} +impl CompleteRequest { + pub fn new(id: RequestId, params: CompleteRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "completion/complete".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "completion/complete" + pub fn method_value() -> ::std::string::String { + "completion/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "completion/complete".to_string() + } +} +///The argument's information +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The argument's information", +/// "type": "object", +/// "required": [ +/// "name", +/// "value" +/// ], +/// "properties": { +/// "name": { +/// "description": "The name of the argument", +/// "type": "string" +/// }, +/// "value": { +/// "description": "The value of the argument to use for completion matching.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequestArgument { + ///The name of the argument + pub name: ::std::string::String, + ///The value of the argument to use for completion matching. + pub value: ::std::string::String, +} +///Additional, optional context for completions +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Additional, optional context for completions", +/// "type": "object", +/// "properties": { +/// "arguments": { +/// "description": "Previously-resolved variables in a URI template or prompt.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "string" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CompleteRequestContext { + ///Previously-resolved variables in a URI template or prompt. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub arguments: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CompleteRequestMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Parameters for a completion/complete request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a completion/complete request.", +/// "type": "object", +/// "required": [ +/// "argument", +/// "ref" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "argument": { +/// "description": "The argument's information", +/// "type": "object", +/// "required": [ +/// "name", +/// "value" +/// ], +/// "properties": { +/// "name": { +/// "description": "The name of the argument", +/// "type": "string" +/// }, +/// "value": { +/// "description": "The value of the argument to use for completion matching.", +/// "type": "string" +/// } +/// } +/// }, +/// "context": { +/// "description": "Additional, optional context for completions", +/// "type": "object", +/// "properties": { +/// "arguments": { +/// "description": "Previously-resolved variables in a URI template or prompt.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "string" +/// } +/// } +/// } +/// }, +/// "ref": { +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/PromptReference" +/// }, +/// { +/// "$ref": "#/$defs/ResourceTemplateReference" +/// } +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequestParams { + pub argument: CompleteRequestArgument, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub context: ::std::option::Option, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + #[serde(rename = "ref")] + pub ref_: CompleteRequestRef, +} +///CompleteRequestRef +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/PromptReference" +/// }, +/// { +/// "$ref": "#/$defs/ResourceTemplateReference" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum CompleteRequestRef { + PromptReference(PromptReference), + ResourceTemplateReference(ResourceTemplateReference), +} +impl ::std::convert::From for CompleteRequestRef { + fn from(value: PromptReference) -> Self { + Self::PromptReference(value) + } +} +impl ::std::convert::From for CompleteRequestRef { + fn from(value: ResourceTemplateReference) -> Self { + Self::ResourceTemplateReference(value) + } +} +///The server's response to a completion/complete request +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a completion/complete request", +/// "type": "object", +/// "required": [ +/// "completion" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "completion": { +/// "type": "object", +/// "required": [ +/// "values" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteResult { + pub completion: CompleteResultCompletion, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///CompleteResultCompletion +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "values" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteResultCompletion { + ///Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown. + #[serde(rename = "hasMore", default, skip_serializing_if = "::std::option::Option::is_none")] + pub has_more: ::std::option::Option, + ///The total number of completion options available. This can exceed the number of values actually sent in the response. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub total: ::std::option::Option, + ///An array of completion values. Must not exceed 100 items. + pub values: ::std::vec::Vec<::std::string::String>, +} +///ContentBlock +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ResourceLink" +/// }, +/// { +/// "$ref": "#/$defs/EmbeddedResource" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ContentBlock { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ResourceLink(ResourceLink), + EmbeddedResource(EmbeddedResource), +} +impl ::std::convert::From for ContentBlock { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for ContentBlock { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for ContentBlock { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} +impl ::std::convert::From for ContentBlock { + fn from(value: ResourceLink) -> Self { + Self::ResourceLink(value) + } +} +impl ::std::convert::From for ContentBlock { + fn from(value: EmbeddedResource) -> Self { + Self::EmbeddedResource(value) + } +} +///CreateMessageContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// }, +/// { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum CreateMessageContent { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), + SamplingMessageContentBlock(::std::vec::Vec), +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ToolUseContent) -> Self { + Self::ToolUseContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ToolResultContent) -> Self { + Self::ToolResultContent(value) + } +} +impl ::std::convert::From<::std::vec::Vec> for CreateMessageContent { + fn from(value: ::std::vec::Vec) -> Self { + Self::SamplingMessageContentBlock(value) + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "sampling/createMessage" +/// }, +/// "params": { +/// "$ref": "#/$defs/CreateMessageRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CreateMessageRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::create_message_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::create_message_request_method")] + method: ::std::string::String, + pub params: CreateMessageRequestParams, +} +impl CreateMessageRequest { + pub fn new(id: RequestId, params: CreateMessageRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "sampling/createMessage".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "sampling/createMessage" + pub fn method_value() -> ::std::string::String { + "sampling/createMessage".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "sampling/createMessage".to_string() + } +} +///Parameters for a sampling/createMessage request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a sampling/createMessage request.", +/// "type": "object", +/// "required": [ +/// "maxTokens", +/// "messages" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "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.", +/// "type": "string", +/// "enum": [ +/// "allServers", +/// "none", +/// "thisServer" +/// ] +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessage" +/// } +/// }, +/// "metadata": { +/// "description": "Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "modelPreferences": { +/// "description": "The server's preferences for which model to select. The client MAY ignore these preferences.", +/// "$ref": "#/$defs/ModelPreferences" +/// }, +/// "stopSequences": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "systemPrompt": { +/// "description": "An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.", +/// "type": "string" +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// }, +/// "temperature": { +/// "type": "number" +/// }, +/// "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\" }.", +/// "$ref": "#/$defs/ToolChoice" +/// }, +/// "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.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Tool" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CreateMessageRequestParams { + /**A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. + The client MAY ignore this request. + Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client + declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.*/ + #[serde(rename = "includeContext", default, skip_serializing_if = "::std::option::Option::is_none")] + pub include_context: ::std::option::Option, + /**The requested maximum number of tokens to sample (to prevent runaway completions). + The client MAY choose to sample fewer tokens than the requested maximum.*/ + #[serde(rename = "maxTokens")] + pub max_tokens: i64, + pub messages: ::std::vec::Vec, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub metadata: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The server's preferences for which model to select. The client MAY ignore these preferences. + #[serde( + rename = "modelPreferences", + default, + skip_serializing_if = "::std::option::Option::is_none" + )] + pub model_preferences: ::std::option::Option, + #[serde(rename = "stopSequences", default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub stop_sequences: ::std::vec::Vec<::std::string::String>, + ///An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. + #[serde(rename = "systemPrompt", default, skip_serializing_if = "::std::option::Option::is_none")] + pub system_prompt: ::std::option::Option<::std::string::String>, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub temperature: ::std::option::Option, + /**Controls how the model uses tools. + The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. + Default is { mode: "auto" }.*/ + #[serde(rename = "toolChoice", default, skip_serializing_if = "::std::option::Option::is_none")] + pub tool_choice: ::std::option::Option, + /**Tools that the model may use during generation. + The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub tools: ::std::vec::Vec, +} +/**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.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "content", +/// "model", +/// "role" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "content": { +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// }, +/// { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } +/// } +/// ] +/// }, +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CreateMessageResult { + pub content: CreateMessageContent, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The name of the model that generated the message. + pub model: ::std::string::String, + pub role: Role, + /**The reason why sampling stopped, if known. + Standard values: + - "endTurn": Natural end of the assistant's turn + - "stopSequence": A stop sequence was encountered + - "maxTokens": Maximum token limit was reached + - "toolUse": The model wants to use one or more tools + This field is an open string to allow for provider-specific stop reasons.*/ + #[serde(rename = "stopReason", default, skip_serializing_if = "::std::option::Option::is_none")] + pub stop_reason: ::std::option::Option<::std::string::String>, +} +///A response to a task-augmented request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A response to a task-augmented request.", +/// "type": "object", +/// "required": [ +/// "task" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "task": { +/// "$ref": "#/$defs/Task" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CreateTaskResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub task: Task, +} +///An opaque token used to represent a cursor for pagination. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An opaque token used to represent a cursor for pagination.", +/// "type": "string" +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[serde(transparent)] +pub struct Cursor(pub ::std::string::String); +///ElicitCompleteParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "elicitationId" +/// ], +/// "properties": { +/// "elicitationId": { +/// "description": "The ID of the elicitation that completed.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitCompleteParams { + ///The ID of the elicitation that completed. + #[serde(rename = "elicitationId")] + pub elicitation_id: ::std::string::String, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ElicitFormMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**A restricted subset of JSON Schema. +Only top-level properties are allowed, without nesting.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", +/// "type": "object", +/// "required": [ +/// "properties", +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "$ref": "#/$defs/PrimitiveSchemaDefinition" +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitFormSchema { + pub properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub required: ::std::vec::Vec<::std::string::String>, + #[serde(rename = "$schema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub schema: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::elicit_form_schema_type_")] + type_: ::std::string::String, +} +impl ElicitFormSchema { + pub fn new( + properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>, + required: ::std::vec::Vec<::std::string::String>, + schema: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + properties, + required, + schema, + type_: "object".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "object".to_string() + } +} +///A request from the server to elicit additional information from the user via the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request from the server to elicit additional information from the user via the client.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "elicitation/create" +/// }, +/// "params": { +/// "$ref": "#/$defs/ElicitRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::elicit_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::elicit_request_method")] + method: ::std::string::String, + pub params: ElicitRequestParams, +} +impl ElicitRequest { + pub fn new(id: RequestId, params: ElicitRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "elicitation/create".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "elicitation/create" + pub fn method_value() -> ::std::string::String { + "elicitation/create".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "elicitation/create".to_string() + } +} +///The parameters for a request to elicit non-sensitive information from the user via a form in the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The parameters for a request to elicit non-sensitive information from the user via a form in the client.", +/// "type": "object", +/// "required": [ +/// "message", +/// "requestedSchema" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "message": { +/// "description": "The message to present to the user describing what information is being requested.", +/// "type": "string" +/// }, +/// "mode": { +/// "description": "The elicitation mode.", +/// "type": "string", +/// "const": "form" +/// }, +/// "requestedSchema": { +/// "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", +/// "type": "object", +/// "required": [ +/// "properties", +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "$ref": "#/$defs/PrimitiveSchemaDefinition" +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitRequestFormParams { + ///The message to present to the user describing what information is being requested. + pub message: ::std::string::String, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The elicitation mode. + #[serde( + default, + skip_serializing_if = "::std::option::Option::is_none", + deserialize_with = "validate::elicit_request_form_params_mode" + )] + mode: ::std::option::Option<::std::string::String>, + #[serde(rename = "requestedSchema")] + pub requested_schema: ElicitFormSchema, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, +} +impl ElicitRequestFormParams { + pub fn new( + message: ::std::string::String, + requested_schema: ElicitFormSchema, + meta: ::std::option::Option, + task: ::std::option::Option, + ) -> Self { + Self { + message, + meta, + mode: Some("form".to_string()), + requested_schema, + task, + } + } + pub fn mode(&self) -> &::std::option::Option<::std::string::String> { + &self.mode + } + /// returns "form" + pub fn mode_value() -> ::std::string::String { + "form".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `mode_value()` instead.")] + pub fn mode_name() -> ::std::string::String { + "form".to_string() + } +} +///The parameters for a request to elicit additional information from the user via the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The parameters for a request to elicit additional information from the user via the client.", +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// }, +/// { +/// "$ref": "#/$defs/ElicitRequestFormParams" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ElicitRequestParams { + UrlParams(ElicitRequestUrlParams), + FormParams(ElicitRequestFormParams), +} +impl ::std::convert::From for ElicitRequestParams { + fn from(value: ElicitRequestUrlParams) -> Self { + Self::UrlParams(value) + } +} +impl ::std::convert::From for ElicitRequestParams { + fn from(value: ElicitRequestFormParams) -> Self { + Self::FormParams(value) + } +} +///The parameters for a request to elicit information from the user via a URL in the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The parameters for a request to elicit information from the user via a URL in the client.", +/// "type": "object", +/// "required": [ +/// "elicitationId", +/// "message", +/// "mode", +/// "url" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "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": { +/// "description": "The elicitation mode.", +/// "type": "string", +/// "const": "url" +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// }, +/// "url": { +/// "description": "The URL that the user should navigate to.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitRequestUrlParams { + /**The ID of the elicitation, which must be unique within the context of the server. + The client MUST treat this ID as an opaque value.*/ + #[serde(rename = "elicitationId")] + pub elicitation_id: ::std::string::String, + ///The message to present to the user explaining why the interaction is needed. + pub message: ::std::string::String, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The elicitation mode. + #[serde(deserialize_with = "validate::elicit_request_url_params_mode")] + mode: ::std::string::String, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, + ///The URL that the user should navigate to. + pub url: ::std::string::String, +} +impl ElicitRequestUrlParams { + pub fn new( + elicitation_id: ::std::string::String, + message: ::std::string::String, + url: ::std::string::String, + meta: ::std::option::Option, + task: ::std::option::Option, + ) -> Self { + Self { + elicitation_id, + message, + meta, + mode: "url".to_string(), + task, + url, + } + } + pub fn mode(&self) -> &::std::string::String { + &self.mode + } + /// returns "url" + pub fn mode_value() -> ::std::string::String { + "url".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `mode_value()` instead.")] + pub fn mode_name() -> ::std::string::String { + "url".to_string() + } +} +///The client's response to an elicitation request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The client's response to an elicitation request.", +/// "type": "object", +/// "required": [ +/// "action" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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", +/// "type": "string", +/// "enum": [ +/// "accept", +/// "cancel", +/// "decline" +/// ] +/// }, +/// "content": { +/// "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", +/// "additionalProperties": { +/// "anyOf": [ +/// { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// { +/// "type": [ +/// "string", +/// "integer", +/// "boolean" +/// ] +/// } +/// ] +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitResult { + /**The user action in response to the elicitation. + - "accept": User submitted the form/confirmed the action + - "decline": User explicitly decline the action + - "cancel": User dismissed without making an explicit choice*/ + pub action: ElicitResultAction, + /**The submitted form data, only present when action is "accept" and mode was "form". + Contains values matching the requested schema. + Omitted for out-of-band mode responses.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub content: ::std::option::Option<::std::collections::HashMap<::std::string::String, ElicitResultContent>>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**The user action in response to the elicitation. +- "accept": User submitted the form/confirmed the action +- "decline": User explicitly decline the action +- "cancel": User dismissed without making an explicit choice*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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", +/// "type": "string", +/// "enum": [ +/// "accept", +/// "cancel", +/// "decline" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum ElicitResultAction { + #[serde(rename = "accept")] + Accept, + #[serde(rename = "cancel")] + Cancel, + #[serde(rename = "decline")] + Decline, +} +impl ::std::fmt::Display for ElicitResultAction { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Accept => write!(f, "accept"), + Self::Cancel => write!(f, "cancel"), + Self::Decline => write!(f, "decline"), + } + } +} +///ElicitResultContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// { +/// "type": [ +/// "string", +/// "integer", +/// "boolean" +/// ] +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ElicitResultContent { + StringArray(::std::vec::Vec<::std::string::String>), + Primitive(ElicitResultContentPrimitive), +} +impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for ElicitResultContent { + fn from(value: ::std::vec::Vec<::std::string::String>) -> Self { + Self::StringArray(value) + } +} +impl ::std::convert::From for ElicitResultContent { + fn from(value: ElicitResultContentPrimitive) -> Self { + Self::Primitive(value) + } +} +///ElicitResultContentPrimitive +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": [ +/// "string", +/// "integer", +/// "boolean" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ElicitResultContentPrimitive { + Boolean(bool), + String(::std::string::String), + Integer(i64), +} +impl ::std::convert::From for ElicitResultContentPrimitive { + fn from(value: bool) -> Self { + Self::Boolean(value) + } +} +impl ::std::convert::From for ElicitResultContentPrimitive { + fn from(value: i64) -> Self { + Self::Integer(value) + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ElicitUrlMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/elicitation/complete" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "elicitationId" +/// ], +/// "properties": { +/// "elicitationId": { +/// "description": "The ID of the elicitation that completed.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitationCompleteNotification { + #[serde(deserialize_with = "validate::elicitation_complete_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::elicitation_complete_notification_method")] + method: ::std::string::String, + pub params: ElicitCompleteParams, +} +impl ElicitationCompleteNotification { + pub fn new(params: ElicitCompleteParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/elicitation/complete".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/elicitation/complete" + pub fn method_value() -> ::std::string::String { + "notifications/elicitation/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/elicitation/complete".to_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.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "resource", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "resource": { +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextResourceContents" +/// }, +/// { +/// "$ref": "#/$defs/BlobResourceContents" +/// } +/// ] +/// }, +/// "type": { +/// "type": "string", +/// "const": "resource" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct EmbeddedResource { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub resource: EmbeddedResourceResource, + #[serde(rename = "type", deserialize_with = "validate::embedded_resource_type_")] + type_: ::std::string::String, +} +impl EmbeddedResource { + pub fn new( + resource: EmbeddedResourceResource, + annotations: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + annotations, + meta, + resource, + type_: "resource".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "resource" + pub fn type_value() -> ::std::string::String { + "resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "resource".to_string() + } +} +///EmbeddedResourceResource +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextResourceContents" +/// }, +/// { +/// "$ref": "#/$defs/BlobResourceContents" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum EmbeddedResourceResource { + TextResourceContents(TextResourceContents), + BlobResourceContents(BlobResourceContents), +} +impl ::std::convert::From for EmbeddedResourceResource { + fn from(value: TextResourceContents) -> Self { + Self::TextResourceContents(value) + } +} +impl ::std::convert::From for EmbeddedResourceResource { + fn from(value: BlobResourceContents) -> Self { + Self::BlobResourceContents(value) + } +} +///EmptyResult +/// +///
JSON schema +/// +/// ```json +///{ +/// "$ref": "#/$defs/Result" +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(transparent)] +pub struct EmptyResult(pub Result); +///EnumSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/UntitledSingleSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/TitledSingleSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/UntitledMultiSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/TitledMultiSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/LegacyTitledEnumSchema" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum EnumSchema { + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), + LegacyTitledEnumSchema(LegacyTitledEnumSchema), +} +impl ::std::convert::From for EnumSchema { + fn from(value: UntitledSingleSelectEnumSchema) -> Self { + Self::UntitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for EnumSchema { + fn from(value: TitledSingleSelectEnumSchema) -> Self { + Self::TitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for EnumSchema { + fn from(value: UntitledMultiSelectEnumSchema) -> Self { + Self::UntitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for EnumSchema { + fn from(value: TitledMultiSelectEnumSchema) -> Self { + Self::TitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for EnumSchema { + fn from(value: LegacyTitledEnumSchema) -> Self { + Self::LegacyTitledEnumSchema(value) + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct GetPromptMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Used by the client to get a prompt provided by the server. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Used by the client to get a prompt provided by the server.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "prompts/get" +/// }, +/// "params": { +/// "$ref": "#/$defs/GetPromptRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetPromptRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::get_prompt_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::get_prompt_request_method")] + method: ::std::string::String, + pub params: GetPromptRequestParams, +} +impl GetPromptRequest { + pub fn new(id: RequestId, params: GetPromptRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "prompts/get".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "prompts/get" + pub fn method_value() -> ::std::string::String { + "prompts/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "prompts/get".to_string() + } +} +///Parameters for a prompts/get request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a prompts/get request.", +/// "type": "object", +/// "required": [ +/// "name" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "arguments": { +/// "description": "Arguments to use for templating the prompt.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "string" +/// } +/// }, +/// "name": { +/// "description": "The name of the prompt or prompt template.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetPromptRequestParams { + ///Arguments to use for templating the prompt. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub arguments: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The name of the prompt or prompt template. + pub name: ::std::string::String, +} +///The server's response to a prompts/get request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a prompts/get request from the client.", +/// "type": "object", +/// "required": [ +/// "messages" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "description": { +/// "description": "An optional description for the prompt.", +/// "type": "string" +/// }, +/// "messages": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/PromptMessage" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetPromptResult { + ///An optional description for the prompt. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub messages: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///GetTaskParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to query.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskParams { + ///The task identifier to query. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///GetTaskPayloadParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to retrieve results for.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskPayloadParams { + ///The task identifier to retrieve results for. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///A request to retrieve the result of a completed task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to retrieve the result of a completed task.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tasks/result" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to retrieve results for.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskPayloadRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::get_task_payload_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::get_task_payload_request_method")] + method: ::std::string::String, + pub params: GetTaskPayloadParams, +} +impl GetTaskPayloadRequest { + pub fn new(id: RequestId, params: GetTaskPayloadParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/result".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/result" + pub fn method_value() -> ::std::string::String { + "tasks/result".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/result".to_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.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct GetTaskPayloadResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///A request to retrieve the state of a task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to retrieve the state of a task.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tasks/get" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to query.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::get_task_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::get_task_request_method")] + method: ::std::string::String, + pub params: GetTaskParams, +} +impl GetTaskRequest { + pub fn new(id: RequestId, params: GetTaskParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/get".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/get" + pub fn method_value() -> ::std::string::String { + "tasks/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/get".to_string() + } +} +///The response to a tasks/get request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The response to a tasks/get request.", +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "$ref": "#/$defs/Task" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskResult { + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + pub ttl: i64, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///An optionally-sized icon that can be displayed in a user interface. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An optionally-sized icon that can be displayed in a user interface.", +/// "type": "object", +/// "required": [ +/// "src" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "src": { +/// "description": "A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a\ndata: 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.", +/// "type": "string", +/// "format": "uri" +/// }, +/// "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.", +/// "type": "string", +/// "enum": [ +/// "dark", +/// "light" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Icon { + /**Optional MIME type override if the source MIME type is missing or generic. + For example: "image/png", "image/jpeg", or "image/svg+xml".*/ + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + /**Optional array of strings that specify sizes at which the icon can be used. + Each string should be in WxH format (e.g., "48x48", "96x96") or "any" for scalable formats like SVG. + If not provided, the client should assume that the icon can be used at any size.*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub sizes: ::std::vec::Vec<::std::string::String>, + /**A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a + data: URI with Base64-encoded image data. + Consumers SHOULD takes steps to ensure URLs serving icons are from the + same domain as the client/server or a trusted domain. + Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain + executable JavaScript.*/ + pub src: ::std::string::String, + /**Optional specifier for the theme this icon is designed for. light indicates + the icon is designed to be used with a light background, and dark indicates + the icon is designed to be used with a dark background. + If not provided, the client should assume the icon can be used with any theme.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub theme: ::std::option::Option, +} +/**Optional specifier for the theme this icon is designed for. light indicates +the icon is designed to be used with a light background, and dark indicates +the icon is designed to be used with a dark background. +If not provided, the client should assume the icon can be used with any theme.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "string", +/// "enum": [ +/// "dark", +/// "light" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum IconTheme { + #[serde(rename = "dark")] + Dark, + #[serde(rename = "light")] + Light, +} +impl ::std::fmt::Display for IconTheme { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Dark => write!(f, "dark"), + Self::Light => write!(f, "light"), + } + } +} +///Base interface to add icons property. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Base interface to add icons property.", +/// "type": "object", +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct Icons { + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, +} +///An image provided to or from an LLM. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An image provided to or from an LLM.", +/// "type": "object", +/// "required": [ +/// "data", +/// "mimeType", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "data": { +/// "description": "The base64-encoded image data.", +/// "type": "string", +/// "format": "byte" +/// }, +/// "mimeType": { +/// "description": "The MIME type of the image. Different providers may support different image types.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "image" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ImageContent { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + ///The base64-encoded image data. + pub data: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of the image. Different providers may support different image types. + #[serde(rename = "mimeType")] + pub mime_type: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::image_content_type_")] + type_: ::std::string::String, +} +impl ImageContent { + pub fn new( + data: ::std::string::String, + mime_type: ::std::string::String, + annotations: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + annotations, + data, + meta, + mime_type, + type_: "image".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "image" + pub fn type_value() -> ::std::string::String { + "image".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "image".to_string() + } +} +///Describes the MCP implementation. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Describes the MCP implementation.", +/// "type": "object", +/// "required": [ +/// "name", +/// "version" +/// ], +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "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.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Implementation { + /**An optional human-readable description of what this implementation does. + This can be used by clients or servers to provide context about their purpose + and capabilities. For example, a server might describe the types of resources + or tools it provides, while a client might describe its intended use case.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + pub version: ::std::string::String, + ///An optional URL of the website for this implementation. + #[serde(rename = "websiteUrl", default, skip_serializing_if = "::std::option::Option::is_none")] + pub website_url: ::std::option::Option<::std::string::String>, +} +/**A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. +The client MAY ignore this request. +Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client +declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "string", +/// "enum": [ +/// "allServers", +/// "none", +/// "thisServer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum IncludeContext { + #[serde(rename = "allServers")] + AllServers, + #[serde(rename = "none")] + None, + #[serde(rename = "thisServer")] + ThisServer, +} +impl ::std::fmt::Display for IncludeContext { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::AllServers => write!(f, "allServers"), + Self::None => write!(f, "none"), + Self::ThisServer => write!(f, "thisServer"), + } + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct InitializeMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///This request is sent from the client to the server when it first connects, asking it to begin initialization. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "This request is sent from the client to the server when it first connects, asking it to begin initialization.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "initialize" +/// }, +/// "params": { +/// "$ref": "#/$defs/InitializeRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct InitializeRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::initialize_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::initialize_request_method")] + method: ::std::string::String, + pub params: InitializeRequestParams, +} +impl InitializeRequest { + pub fn new(id: RequestId, params: InitializeRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "initialize".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "initialize" + pub fn method_value() -> ::std::string::String { + "initialize".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "initialize".to_string() + } +} +///Parameters for an initialize request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for an initialize request.", +/// "type": "object", +/// "required": [ +/// "capabilities", +/// "clientInfo", +/// "protocolVersion" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct InitializeRequestParams { + pub capabilities: ClientCapabilities, + #[serde(rename = "clientInfo")] + pub client_info: Implementation, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. + #[serde(rename = "protocolVersion")] + pub protocol_version: ::std::string::String, +} +///After receiving an initialize request from the client, the server sends this response. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "After receiving an initialize request from the client, the server sends this response.", +/// "type": "object", +/// "required": [ +/// "capabilities", +/// "protocolVersion", +/// "serverInfo" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct InitializeResult { + pub capabilities: ServerCapabilities, + /**Instructions describing how to use the server and its features. + This 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.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub instructions: ::std::option::Option<::std::string::String>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///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. + #[serde(rename = "protocolVersion")] + pub protocol_version: ::std::string::String, + #[serde(rename = "serverInfo")] + pub server_info: Implementation, +} +///This notification is sent from the client to the server after initialization has finished. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "This notification is sent from the client to the server after initialization has finished.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/initialized" +/// }, +/// "params": { +/// "$ref": "#/$defs/NotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct InitializedNotification { + #[serde(deserialize_with = "validate::initialized_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::initialized_notification_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl InitializedNotification { + pub fn new(params: ::std::option::Option) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/initialized".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/initialized" + pub fn method_value() -> ::std::string::String { + "notifications/initialized".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/initialized".to_string() + } +} +///A response to a request that indicates an error occurred. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A response to a request that indicates an error occurred.", +/// "type": "object", +/// "required": [ +/// "error", +/// "jsonrpc" +/// ], +/// "properties": { +/// "error": { +/// "$ref": "#/$defs/Error" +/// }, +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct JsonrpcErrorResponse { + pub error: RpcError, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub id: ::std::option::Option, + #[serde(deserialize_with = "validate::jsonrpc_error_response_jsonrpc")] + jsonrpc: ::std::string::String, +} +impl JsonrpcErrorResponse { + pub fn new(error: RpcError, id: ::std::option::Option) -> Self { + Self { + error, + id, + jsonrpc: JSONRPC_VERSION.to_string(), + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} +///Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.", +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/JSONRPCRequest" +/// }, +/// { +/// "$ref": "#/$defs/JSONRPCNotification" +/// }, +/// { +/// "$ref": "#/$defs/JSONRPCResultResponse" +/// }, +/// { +/// "$ref": "#/$defs/JSONRPCErrorResponse" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum JsonrpcMessage { + Request(JsonrpcRequest), + Notification(JsonrpcNotification), + ResultResponse(JsonrpcResultResponse), + ErrorResponse(JsonrpcErrorResponse), +} +impl ::std::convert::From for JsonrpcMessage { + fn from(value: JsonrpcRequest) -> Self { + Self::Request(value) + } +} +impl ::std::convert::From for JsonrpcMessage { + fn from(value: JsonrpcNotification) -> Self { + Self::Notification(value) + } +} +impl ::std::convert::From for JsonrpcMessage { + fn from(value: JsonrpcResultResponse) -> Self { + Self::ResultResponse(value) + } +} +impl ::std::convert::From for JsonrpcMessage { + fn from(value: JsonrpcErrorResponse) -> Self { + Self::ErrorResponse(value) + } +} +///A notification which does not expect a response. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A notification which does not expect a response.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string" +/// }, +/// "params": { +/// "type": "object", +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct JsonrpcNotification { + #[serde(deserialize_with = "validate::jsonrpc_notification_jsonrpc")] + jsonrpc: ::std::string::String, + pub method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +impl JsonrpcNotification { + pub fn new( + method: ::std::string::String, + params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method, + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} +///A request that expects a response. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request that expects a response.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string" +/// }, +/// "params": { +/// "type": "object", +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct JsonrpcRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::jsonrpc_request_jsonrpc")] + jsonrpc: ::std::string::String, + pub method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +impl JsonrpcRequest { + pub fn new( + id: RequestId, + method: ::std::string::String, + params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method, + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} +///A response to a request, containing either the result or error. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A response to a request, containing either the result or error.", +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/JSONRPCResultResponse" +/// }, +/// { +/// "$ref": "#/$defs/JSONRPCErrorResponse" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum JsonrpcResponse { + ResultResponse(JsonrpcResultResponse), + ErrorResponse(JsonrpcErrorResponse), +} +impl ::std::convert::From for JsonrpcResponse { + fn from(value: JsonrpcResultResponse) -> Self { + Self::ResultResponse(value) + } +} +impl ::std::convert::From for JsonrpcResponse { + fn from(value: JsonrpcErrorResponse) -> Self { + Self::ErrorResponse(value) + } +} +///A successful (non-error) response to a request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A successful (non-error) response to a request.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "result" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "result": { +/// "$ref": "#/$defs/Result" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct JsonrpcResultResponse { + pub id: RequestId, + #[serde(deserialize_with = "validate::jsonrpc_result_response_jsonrpc")] + jsonrpc: ::std::string::String, + pub result: Result, +} +impl JsonrpcResultResponse { + pub fn new(id: RequestId, result: Result) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + result, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} +/**Use TitledSingleSelectEnumSchema instead. +This interface will be removed in a future version.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Use TitledSingleSelectEnumSchema instead.\nThis interface will be removed in a future version.", +/// "type": "object", +/// "required": [ +/// "enum", +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "type": "string" +/// }, +/// "description": { +/// "type": "string" +/// }, +/// "enum": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "enumNames": { +/// "description": "(Legacy) Display names for enum values.\nNon-standard according to JSON schema 2020-12.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "title": { +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct LegacyTitledEnumSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(rename = "enum")] + pub enum_: ::std::vec::Vec<::std::string::String>, + /**(Legacy) Display names for enum values. + Non-standard according to JSON schema 2020-12.*/ + #[serde(rename = "enumNames", default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub enum_names: ::std::vec::Vec<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::legacy_titled_enum_schema_type_")] + type_: ::std::string::String, +} +impl LegacyTitledEnumSchema { + pub fn new( + enum_: ::std::vec::Vec<::std::string::String>, + enum_names: ::std::vec::Vec<::std::string::String>, + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + enum_, + enum_names, + title, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///Sent from the client to request a list of prompts and prompt templates the server has. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request a list of prompts and prompt templates the server has.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "prompts/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListPromptsRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_prompts_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_prompts_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListPromptsRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "prompts/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "prompts/list" + pub fn method_value() -> ::std::string::String { + "prompts/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "prompts/list".to_string() + } +} +///The server's response to a prompts/list request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a prompts/list request from the client.", +/// "type": "object", +/// "required": [ +/// "prompts" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Prompt" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListPromptsResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, + pub prompts: ::std::vec::Vec, +} +///Sent from the client to request a list of resource templates the server has. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request a list of resource templates the server has.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "resources/templates/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListResourceTemplatesRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_resource_templates_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_resource_templates_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListResourceTemplatesRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "resources/templates/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "resources/templates/list" + pub fn method_value() -> ::std::string::String { + "resources/templates/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "resources/templates/list".to_string() + } +} +///The server's response to a resources/templates/list request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a resources/templates/list request from the client.", +/// "type": "object", +/// "required": [ +/// "resourceTemplates" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ResourceTemplate" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListResourceTemplatesResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, + #[serde(rename = "resourceTemplates")] + pub resource_templates: ::std::vec::Vec, +} +///Sent from the client to request a list of resources the server has. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request a list of resources the server has.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "resources/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListResourcesRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_resources_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_resources_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListResourcesRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "resources/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "resources/list" + pub fn method_value() -> ::std::string::String { + "resources/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "resources/list".to_string() + } +} +///The server's response to a resources/list request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a resources/list request from the client.", +/// "type": "object", +/// "required": [ +/// "resources" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Resource" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListResourcesResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, + pub resources: ::std::vec::Vec, +} +/**Sent from the server to request a list of root URIs from the client. Roots allow +servers to ask for specific directories or files to operate on. A common example +for roots is providing a set of repositories or directories a server should operate +on. +This request is typically used when the server needs to understand the file system +structure or access specific locations that the client has permission to read from.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "roots/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/RequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListRootsRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_roots_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_roots_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListRootsRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "roots/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "roots/list" + pub fn method_value() -> ::std::string::String { + "roots/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "roots/list".to_string() + } +} +/**The client's response to a roots/list request from the server. +This result contains an array of Root objects, each representing a root directory +or file that the server can operate on.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "roots" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "roots": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Root" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListRootsResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub roots: ::std::vec::Vec, +} +///A request to retrieve a list of tasks. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to retrieve a list of tasks.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tasks/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListTasksRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_tasks_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_tasks_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListTasksRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/list" + pub fn method_value() -> ::std::string::String { + "tasks/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/list".to_string() + } +} +///The response to a tasks/list request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The response to a tasks/list request.", +/// "type": "object", +/// "required": [ +/// "tasks" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Task" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListTasksResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, + pub tasks: ::std::vec::Vec, +} +///Sent from the client to request a list of tools the server has. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request a list of tools the server has.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tools/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListToolsRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_tools_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_tools_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListToolsRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tools/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tools/list" + pub fn method_value() -> ::std::string::String { + "tools/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tools/list".to_string() + } +} +///The server's response to a tools/list request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a tools/list request from the client.", +/// "type": "object", +/// "required": [ +/// "tools" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Tool" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListToolsResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, + pub tools: ::std::vec::Vec, +} +/**The severity of a log message. +These map to syslog message severities, as specified in RFC-5424: +*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The severity of a log message.\n\nThese map to syslog message severities, as specified in RFC-5424:\n", +/// "type": "string", +/// "enum": [ +/// "alert", +/// "critical", +/// "debug", +/// "emergency", +/// "error", +/// "info", +/// "notice", +/// "warning" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum LoggingLevel { + #[serde(rename = "alert")] + Alert, + #[serde(rename = "critical")] + Critical, + #[serde(rename = "debug")] + Debug, + #[serde(rename = "emergency")] + Emergency, + #[serde(rename = "error")] + Error, + #[serde(rename = "info")] + Info, + #[serde(rename = "notice")] + Notice, + #[serde(rename = "warning")] + Warning, +} +impl ::std::fmt::Display for LoggingLevel { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Alert => write!(f, "alert"), + Self::Critical => write!(f, "critical"), + Self::Debug => write!(f, "debug"), + Self::Emergency => write!(f, "emergency"), + Self::Error => write!(f, "error"), + Self::Info => write!(f, "info"), + Self::Notice => write!(f, "notice"), + Self::Warning => write!(f, "warning"), + } + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/message" +/// }, +/// "params": { +/// "$ref": "#/$defs/LoggingMessageNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct LoggingMessageNotification { + #[serde(deserialize_with = "validate::logging_message_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::logging_message_notification_method")] + method: ::std::string::String, + pub params: LoggingMessageNotificationParams, +} +impl LoggingMessageNotification { + pub fn new(params: LoggingMessageNotificationParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/message".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/message" + pub fn method_value() -> ::std::string::String { + "notifications/message".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/message".to_string() + } +} +///Parameters for a notifications/message notification. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a notifications/message notification.", +/// "type": "object", +/// "required": [ +/// "data", +/// "level" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "data": { +/// "description": "The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here." +/// }, +/// "level": { +/// "description": "The severity of this log message.", +/// "$ref": "#/$defs/LoggingLevel" +/// }, +/// "logger": { +/// "description": "An optional name of the logger issuing this message.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct LoggingMessageNotificationParams { + ///The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here. + pub data: ::serde_json::Value, + ///The severity of this log message. + pub level: LoggingLevel, + ///An optional name of the logger issuing this message. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub logger: ::std::option::Option<::std::string::String>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct MessageMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**Hints to use for model selection. +Keys not declared here are currently left unspecified by the spec and are up +to the client to interpret.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ModelHint { + /**A hint for a model name. + The client SHOULD treat this as a substring of a model name; for example: + - claude-3-5-sonnet should match claude-3-5-sonnet-20241022 + - sonnet should match claude-3-5-sonnet-20241022, claude-3-sonnet-20240229, etc. + - claude should match any Claude model + The 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: + - gemini-1.5-flash could match claude-3-haiku-20240307*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option<::std::string::String>, +} +/**The server's preferences for model selection, requested of the client during sampling. +Because LLMs can vary along multiple dimensions, choosing the "best" model is +rarely straightforward. Different models excel in different areas—some are +faster but less capable, others are more capable but more expensive, and so +on. This interface allows servers to express their priorities across multiple +dimensions to help clients make an appropriate selection for their use case. +These preferences are always advisory. The client MAY ignore them. It is also +up to the client to decide how to interpret these preferences and how to +balance them against other considerations.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "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.", +/// "type": "number", +/// "maximum": 1.0, +/// "minimum": 0.0 +/// }, +/// "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.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ModelHint" +/// } +/// }, +/// "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.", +/// "type": "number", +/// "maximum": 1.0, +/// "minimum": 0.0 +/// }, +/// "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.", +/// "type": "number", +/// "maximum": 1.0, +/// "minimum": 0.0 +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ModelPreferences { + #[serde(rename = "costPriority", default, skip_serializing_if = "::std::option::Option::is_none")] + pub cost_priority: ::std::option::Option, + /**Optional hints to use for model selection. + If multiple hints are specified, the client MUST evaluate them in order + (such that the first match is taken). + The client SHOULD prioritize these hints over the numeric priorities, but + MAY still use the priorities to select from ambiguous matches.*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub hints: ::std::vec::Vec, + #[serde( + rename = "intelligencePriority", + default, + skip_serializing_if = "::std::option::Option::is_none" + )] + pub intelligence_priority: ::std::option::Option, + #[serde(rename = "speedPriority", default, skip_serializing_if = "::std::option::Option::is_none")] + pub speed_priority: ::std::option::Option, +} +///MultiSelectEnumSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/UntitledMultiSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/TitledMultiSelectEnumSchema" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum MultiSelectEnumSchema { + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), +} +impl ::std::convert::From for MultiSelectEnumSchema { + fn from(value: UntitledMultiSelectEnumSchema) -> Self { + Self::UntitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for MultiSelectEnumSchema { + fn from(value: TitledMultiSelectEnumSchema) -> Self { + Self::TitledMultiSelectEnumSchema(value) + } +} +///Notification +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "method" +/// ], +/// "properties": { +/// "method": { +/// "type": "string" +/// }, +/// "params": { +/// "type": "object", +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Notification { + pub method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///NotificationParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct NotificationParams { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///NumberSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "type": "integer" +/// }, +/// "description": { +/// "type": "string" +/// }, +/// "maximum": { +/// "type": "integer" +/// }, +/// "minimum": { +/// "type": "integer" +/// }, +/// "title": { +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "enum": [ +/// "integer", +/// "number" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct NumberSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub maximum: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub minimum: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type")] + pub type_: NumberSchemaType, +} +///NumberSchemaType +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "string", +/// "enum": [ +/// "integer", +/// "number" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum NumberSchemaType { + #[serde(rename = "integer")] + Integer, + #[serde(rename = "number")] + Number, +} +impl ::std::fmt::Display for NumberSchemaType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Integer => write!(f, "integer"), + Self::Number => write!(f, "number"), + } + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct PaginatedMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///PaginatedRequest +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct PaginatedRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::paginated_request_jsonrpc")] + jsonrpc: ::std::string::String, + pub method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl PaginatedRequest { + pub fn new(id: RequestId, method: ::std::string::String, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method, + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} +///Common parameters for paginated requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Common parameters for paginated requests.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "cursor": { +/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct PaginatedRequestParams { + /**An opaque token representing the current pagination position. + If provided, the server should return results starting after this cursor.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cursor: ::std::option::Option<::std::string::String>, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, +} +///PaginatedResult +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "nextCursor": { +/// "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct PaginatedResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "ping" +/// }, +/// "params": { +/// "$ref": "#/$defs/RequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct PingRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::ping_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::ping_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl PingRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "ping".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "ping" + pub fn method_value() -> ::std::string::String { + "ping".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "ping".to_string() + } +} +/**Restricted schema definitions that only allow primitive types +without nested objects or arrays.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Restricted schema definitions that only allow primitive types\nwithout nested objects or arrays.", +/// "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" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum PrimitiveSchemaDefinition { + StringSchema(StringSchema), + NumberSchema(NumberSchema), + BooleanSchema(BooleanSchema), + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), + LegacyTitledEnumSchema(LegacyTitledEnumSchema), +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: StringSchema) -> Self { + Self::StringSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: NumberSchema) -> Self { + Self::NumberSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: BooleanSchema) -> Self { + Self::BooleanSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: UntitledSingleSelectEnumSchema) -> Self { + Self::UntitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: TitledSingleSelectEnumSchema) -> Self { + Self::TitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: UntitledMultiSelectEnumSchema) -> Self { + Self::UntitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: TitledMultiSelectEnumSchema) -> Self { + Self::TitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: LegacyTitledEnumSchema) -> Self { + Self::LegacyTitledEnumSchema(value) + } +} +///An out-of-band notification used to inform the receiver of a progress update for a long-running request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An out-of-band notification used to inform the receiver of a progress update for a long-running request.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/progress" +/// }, +/// "params": { +/// "$ref": "#/$defs/ProgressNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ProgressNotification { + #[serde(deserialize_with = "validate::progress_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::progress_notification_method")] + method: ::std::string::String, + pub params: ProgressNotificationParams, +} +impl ProgressNotification { + pub fn new(params: ProgressNotificationParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/progress".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/progress" + pub fn method_value() -> ::std::string::String { + "notifications/progress".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/progress".to_string() + } +} +///Parameters for a notifications/progress notification. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a notifications/progress notification.", +/// "type": "object", +/// "required": [ +/// "progress", +/// "progressToken" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "description": "The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.", +/// "$ref": "#/$defs/ProgressToken" +/// }, +/// "total": { +/// "description": "Total number of items to process (or total progress required), if known.", +/// "type": "number" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ProgressNotificationParams { + ///An optional message describing the current progress. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub message: ::std::option::Option<::std::string::String>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub progress: f64, + ///The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. + #[serde(rename = "progressToken")] + pub progress_token: ProgressToken, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub total: ::std::option::Option, +} +///A progress token, used to associate progress notifications with the original request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A progress token, used to associate progress notifications with the original request.", +/// "type": [ +/// "string", +/// "integer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ProgressToken { + String(::std::string::String), + Integer(i64), +} +impl ::std::convert::From for ProgressToken { + fn from(value: i64) -> Self { + Self::Integer(value) + } +} +///A prompt or prompt template that the server offers. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A prompt or prompt template that the server offers.", +/// "type": "object", +/// "required": [ +/// "name" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "arguments": { +/// "description": "A list of arguments to use for templating the prompt.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/PromptArgument" +/// } +/// }, +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Prompt { + ///A list of arguments to use for templating the prompt. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub arguments: ::std::vec::Vec, + ///An optional description of what this prompt provides + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, +} +///Describes an argument that a prompt can accept. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Describes an argument that a prompt can accept.", +/// "type": "object", +/// "required": [ +/// "name" +/// ], +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct PromptArgument { + ///A human-readable description of the argument. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + ///Whether this argument must be provided. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub required: ::std::option::Option, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/prompts/list_changed" +/// }, +/// "params": { +/// "$ref": "#/$defs/NotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct PromptListChangedNotification { + #[serde(deserialize_with = "validate::prompt_list_changed_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::prompt_list_changed_notification_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl PromptListChangedNotification { + pub fn new(params: ::std::option::Option) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/prompts/list_changed".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/prompts/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/prompts/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/prompts/list_changed".to_string() + } +} +/**Describes a message returned as part of a prompt. +This is similar to SamplingMessage, but also supports the embedding of +resources from the MCP server.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "content", +/// "role" +/// ], +/// "properties": { +/// "content": { +/// "$ref": "#/$defs/ContentBlock" +/// }, +/// "role": { +/// "$ref": "#/$defs/Role" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct PromptMessage { + pub content: ContentBlock, + pub role: Role, +} +///Identifies a prompt. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Identifies a prompt.", +/// "type": "object", +/// "required": [ +/// "name", +/// "type" +/// ], +/// "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": { +/// "type": "string", +/// "const": "ref/prompt" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct PromptReference { + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::prompt_reference_type_")] + type_: ::std::string::String, +} +impl PromptReference { + pub fn new(name: ::std::string::String, title: ::std::option::Option<::std::string::String>) -> Self { + Self { + name, + title, + type_: "ref/prompt".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "ref/prompt" + pub fn type_value() -> ::std::string::String { + "ref/prompt".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "ref/prompt".to_string() + } +} +///ReadResourceContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextResourceContents" +/// }, +/// { +/// "$ref": "#/$defs/BlobResourceContents" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ReadResourceContent { + TextResourceContents(TextResourceContents), + BlobResourceContents(BlobResourceContents), +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: TextResourceContents) -> Self { + Self::TextResourceContents(value) + } +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: BlobResourceContents) -> Self { + Self::BlobResourceContents(value) + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ReadResourceMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Sent from the client to the server, to read a specific resource URI. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to the server, to read a specific resource URI.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "resources/read" +/// }, +/// "params": { +/// "$ref": "#/$defs/ReadResourceRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ReadResourceRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::read_resource_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::read_resource_request_method")] + method: ::std::string::String, + pub params: ReadResourceRequestParams, +} +impl ReadResourceRequest { + pub fn new(id: RequestId, params: ReadResourceRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "resources/read".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "resources/read" + pub fn method_value() -> ::std::string::String { + "resources/read".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "resources/read".to_string() + } +} +///Parameters for a resources/read request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a resources/read request.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "uri": { +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ReadResourceRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + pub uri: ::std::string::String, +} +///The server's response to a resources/read request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a resources/read request from the client.", +/// "type": "object", +/// "required": [ +/// "contents" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "contents": { +/// "type": "array", +/// "items": { +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextResourceContents" +/// }, +/// { +/// "$ref": "#/$defs/BlobResourceContents" +/// } +/// ] +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ReadResourceResult { + pub contents: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**Metadata for associating messages with a task. +Include this in the _meta field under the key io.modelcontextprotocol/related-task.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Metadata for associating messages with a task.\nInclude this in the _meta field under the key io.modelcontextprotocol/related-task.", +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier this message is associated with.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct RelatedTaskMetadata { + ///The task identifier this message is associated with. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///Request +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "method" +/// ], +/// "properties": { +/// "method": { +/// "type": "string" +/// }, +/// "params": { +/// "type": "object", +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Request { + pub method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///A uniquely identifying ID for a request in JSON-RPC. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A uniquely identifying ID for a request in JSON-RPC.", +/// "type": [ +/// "string", +/// "integer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum RequestId { + String(::std::string::String), + Integer(i64), +} +impl ::std::convert::From for RequestId { + fn from(value: i64) -> Self { + Self::Integer(value) + } +} +///Common params for any request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Common params for any request.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct RequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct RequestParamsMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///A known resource that the server is capable of reading. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A known resource that the server is capable of reading.", +/// "type": "object", +/// "required": [ +/// "name", +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "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.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Resource { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + /**A description of what this resource represents. + This 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.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of this resource, if known. + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. + This can be used by Hosts to display file sizes and estimate context window usage.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub size: ::std::option::Option, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + ///The URI of this resource. + pub uri: ::std::string::String, +} +///The contents of a specific resource or sub-resource. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The contents of a specific resource or sub-resource.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "mimeType": { +/// "description": "The MIME type of this resource, if known.", +/// "type": "string" +/// }, +/// "uri": { +/// "description": "The URI of this resource.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceContents { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of this resource, if known. + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + ///The URI of this resource. + pub uri: ::std::string::String, +} +/**A resource that the server is capable of reading, included in a prompt or tool call result. +Note: resource links returned by tools are not guaranteed to appear in the results of resources/list requests.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "name", +/// "type", +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "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": { +/// "type": "string", +/// "const": "resource_link" +/// }, +/// "uri": { +/// "description": "The URI of this resource.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceLink { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + /**A description of what this resource represents. + This 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.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of this resource, if known. + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. + This can be used by Hosts to display file sizes and estimate context window usage.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub size: ::std::option::Option, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::resource_link_type_")] + type_: ::std::string::String, + ///The URI of this resource. + pub uri: ::std::string::String, +} +impl ResourceLink { + #[allow(clippy::too_many_arguments)] + pub fn new( + icons: ::std::vec::Vec, + name: ::std::string::String, + uri: ::std::string::String, + annotations: ::std::option::Option, + description: ::std::option::Option<::std::string::String>, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + mime_type: ::std::option::Option<::std::string::String>, + size: ::std::option::Option, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + annotations, + description, + icons, + meta, + mime_type, + name, + size, + title, + type_: "resource_link".to_string(), + uri, + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "resource_link" + pub fn type_value() -> ::std::string::String { + "resource_link".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "resource_link".to_string() + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/resources/list_changed" +/// }, +/// "params": { +/// "$ref": "#/$defs/NotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceListChangedNotification { + #[serde(deserialize_with = "validate::resource_list_changed_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::resource_list_changed_notification_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ResourceListChangedNotification { + pub fn new(params: ::std::option::Option) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/resources/list_changed".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/resources/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/resources/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/resources/list_changed".to_string() + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ResourceMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Common parameters when working with resources. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Common parameters when working with resources.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "uri": { +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + pub uri: ::std::string::String, +} +///A template description for resources available on the server. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A template description for resources available on the server.", +/// "type": "object", +/// "required": [ +/// "name", +/// "uriTemplate" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "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.", +/// "type": "string", +/// "format": "uri-template" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceTemplate { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + /**A description of what this template is for. + This 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.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///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. + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + ///A URI template (according to RFC 6570) that can be used to construct resource URIs. + #[serde(rename = "uriTemplate")] + pub uri_template: ::std::string::String, +} +///A reference to a resource or resource template definition. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A reference to a resource or resource template definition.", +/// "type": "object", +/// "required": [ +/// "type", +/// "uri" +/// ], +/// "properties": { +/// "type": { +/// "type": "string", +/// "const": "ref/resource" +/// }, +/// "uri": { +/// "description": "The URI or URI template of the resource.", +/// "type": "string", +/// "format": "uri-template" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceTemplateReference { + #[serde(rename = "type", deserialize_with = "validate::resource_template_reference_type_")] + type_: ::std::string::String, + ///The URI or URI template of the resource. + pub uri: ::std::string::String, +} +impl ResourceTemplateReference { + pub fn new(uri: ::std::string::String) -> Self { + Self { + type_: "ref/resource".to_string(), + uri, + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "ref/resource" + pub fn type_value() -> ::std::string::String { + "ref/resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "ref/resource".to_string() + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/resources/updated" +/// }, +/// "params": { +/// "$ref": "#/$defs/ResourceUpdatedNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceUpdatedNotification { + #[serde(deserialize_with = "validate::resource_updated_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::resource_updated_notification_method")] + method: ::std::string::String, + pub params: ResourceUpdatedNotificationParams, +} +impl ResourceUpdatedNotification { + pub fn new(params: ResourceUpdatedNotificationParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/resources/updated".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/resources/updated" + pub fn method_value() -> ::std::string::String { + "notifications/resources/updated".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/resources/updated".to_string() + } +} +///Parameters for a notifications/resources/updated notification. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a notifications/resources/updated notification.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceUpdatedNotificationParams { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. + pub uri: ::std::string::String, +} +///Result +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct Result { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///The sender or recipient of messages and data in a conversation. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The sender or recipient of messages and data in a conversation.", +/// "type": "string", +/// "enum": [ +/// "assistant", +/// "user" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum Role { + #[serde(rename = "assistant")] + Assistant, + #[serde(rename = "user")] + User, +} +impl ::std::fmt::Display for Role { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Assistant => write!(f, "assistant"), + Self::User => write!(f, "user"), + } + } +} +///Represents a root directory or file that the server can operate on. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Represents a root directory or file that the server can operate on.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Root { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An optional name for the root. This can be used to provide a human-readable + identifier for the root, which may be useful for display purposes or for + referencing the root in other parts of the application.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option<::std::string::String>, + /**The URI identifying the root. This *must* start with file:// for now. + This restriction may be relaxed in future versions of the protocol to allow + other URI schemes.*/ + pub uri: ::std::string::String, +} +/**A notification from the client to the server, informing it that the list of roots has changed. +This notification should be sent whenever the client adds, removes, or modifies any root. +The server should then request an updated list of roots using the ListRootsRequest.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/roots/list_changed" +/// }, +/// "params": { +/// "$ref": "#/$defs/NotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct RootsListChangedNotification { + #[serde(deserialize_with = "validate::roots_list_changed_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::roots_list_changed_notification_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl RootsListChangedNotification { + pub fn new(params: ::std::option::Option) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/roots/list_changed".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/roots/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/roots/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/roots/list_changed".to_string() + } +} +///RpcError +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "code", +/// "message" +/// ], +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct RpcError { + ///The error type that occurred. + pub code: i64, + ///Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.). + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub data: ::std::option::Option<::serde_json::Value>, + ///A short description of the error. The message SHOULD be limited to a concise single sentence. + pub message: ::std::string::String, +} +///Describes a message issued to or received from an LLM API. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Describes a message issued to or received from an LLM API.", +/// "type": "object", +/// "required": [ +/// "content", +/// "role" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "content": { +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// }, +/// { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } +/// } +/// ] +/// }, +/// "role": { +/// "$ref": "#/$defs/Role" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SamplingMessage { + pub content: SamplingMessageContent, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub role: Role, +} +///SamplingMessageContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// }, +/// { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum SamplingMessageContent { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), + SamplingMessageContentBlock(::std::vec::Vec), +} +impl ::std::convert::From for SamplingMessageContent { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for SamplingMessageContent { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for SamplingMessageContent { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} +impl ::std::convert::From for SamplingMessageContent { + fn from(value: ToolUseContent) -> Self { + Self::ToolUseContent(value) + } +} +impl ::std::convert::From for SamplingMessageContent { + fn from(value: ToolResultContent) -> Self { + Self::ToolResultContent(value) + } +} +impl ::std::convert::From<::std::vec::Vec> for SamplingMessageContent { + fn from(value: ::std::vec::Vec) -> Self { + Self::SamplingMessageContentBlock(value) + } +} +///SamplingMessageContentBlock +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum SamplingMessageContentBlock { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: ToolUseContent) -> Self { + Self::ToolUseContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: ToolResultContent) -> Self { + Self::ToolResultContent(value) + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "properties": { +/// "completions": { +/// "description": "Present if the server supports argument autocompletion suggestions.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "experimental": { +/// "description": "Experimental, non-standard capabilities that the server supports.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "logging": { +/// "description": "Present if the server supports sending log messages to the client.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "prompts": { +/// "description": "Present if the server offers any prompt templates.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether this server supports notifications for changes to the prompt list.", +/// "type": "boolean" +/// } +/// } +/// }, +/// "resources": { +/// "description": "Present if the server offers any resources to read.", +/// "type": "object", +/// "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" +/// } +/// } +/// }, +/// "tasks": { +/// "description": "Present if the server supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this server supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this server supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "tools": { +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } +/// }, +/// "tools": { +/// "description": "Present if the server offers any tools to call.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether this server supports notifications for changes to the tool list.", +/// "type": "boolean" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerCapabilities { + ///Present if the server supports argument autocompletion suggestions. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub completions: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Experimental, non-standard capabilities that the server supports. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub experimental: ::std::option::Option< + ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, + >, + ///Present if the server supports sending log messages to the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub logging: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub prompts: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub resources: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tasks: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tools: ::std::option::Option, +} +///Present if the server offers any prompt templates. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the server offers any prompt templates.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether this server supports notifications for changes to the prompt list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerCapabilitiesPrompts { + ///Whether this server supports notifications for changes to the prompt list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} +///Present if the server offers any resources to read. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the server offers any resources to read.", +/// "type": "object", +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerCapabilitiesResources { + ///Whether this server supports notifications for changes to the resource list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, + ///Whether this server supports subscribing to resource updates. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub subscribe: ::std::option::Option, +} +///Present if the server offers any tools to call. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the server offers any tools to call.", +/// "type": "object", +/// "properties": { +/// "listChanged": { +/// "description": "Whether this server supports notifications for changes to the tool list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerCapabilitiesTools { + ///Whether this server supports notifications for changes to the tool list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} +///ServerNotification +/// +///
JSON schema +/// +/// ```json +///{ +/// "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" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ServerNotification { + CancelledNotification(CancelledNotification), + ProgressNotification(ProgressNotification), + ResourceListChangedNotification(ResourceListChangedNotification), + ResourceUpdatedNotification(ResourceUpdatedNotification), + PromptListChangedNotification(PromptListChangedNotification), + ToolListChangedNotification(ToolListChangedNotification), + TaskStatusNotification(TaskStatusNotification), + LoggingMessageNotification(LoggingMessageNotification), + ElicitationCompleteNotification(ElicitationCompleteNotification), +} +impl ::std::convert::From for ServerNotification { + fn from(value: CancelledNotification) -> Self { + Self::CancelledNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: ProgressNotification) -> Self { + Self::ProgressNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: ResourceListChangedNotification) -> Self { + Self::ResourceListChangedNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: ResourceUpdatedNotification) -> Self { + Self::ResourceUpdatedNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: PromptListChangedNotification) -> Self { + Self::PromptListChangedNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: ToolListChangedNotification) -> Self { + Self::ToolListChangedNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::TaskStatusNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: LoggingMessageNotification) -> Self { + Self::LoggingMessageNotification(value) + } +} +impl ::std::convert::From for ServerNotification { + fn from(value: ElicitationCompleteNotification) -> Self { + Self::ElicitationCompleteNotification(value) + } +} +///ServerRequest +/// +///
JSON schema +/// +/// ```json +///{ +/// "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" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum ServerRequest { + PingRequest(PingRequest), + GetTaskRequest(GetTaskRequest), + GetTaskPayloadRequest(GetTaskPayloadRequest), + CancelTaskRequest(CancelTaskRequest), + ListTasksRequest(ListTasksRequest), + CreateMessageRequest(CreateMessageRequest), + ListRootsRequest(ListRootsRequest), + ElicitRequest(ElicitRequest), +} +impl ::std::convert::From for ServerRequest { + fn from(value: PingRequest) -> Self { + Self::PingRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: GetTaskRequest) -> Self { + Self::GetTaskRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::GetTaskPayloadRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: CancelTaskRequest) -> Self { + Self::CancelTaskRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: ListTasksRequest) -> Self { + Self::ListTasksRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: CreateMessageRequest) -> Self { + Self::CreateMessageRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: ListRootsRequest) -> Self { + Self::ListRootsRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: ElicitRequest) -> Self { + Self::ElicitRequest(value) + } +} +///ServerResult +/// +///
JSON schema +/// +/// ```json +///{ +/// "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" +/// }, +/// { +/// "description": "The response to a tasks/get request.", +/// "$ref": "#/$defs/GetTaskResult" +/// }, +/// { +/// "$ref": "#/$defs/GetTaskPayloadResult" +/// }, +/// { +/// "description": "The response to a tasks/cancel request.", +/// "$ref": "#/$defs/CancelTaskResult" +/// }, +/// { +/// "$ref": "#/$defs/ListTasksResult" +/// }, +/// { +/// "$ref": "#/$defs/CompleteResult" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum ServerResult { + InitializeResult(InitializeResult), + ListResourcesResult(ListResourcesResult), + ListResourceTemplatesResult(ListResourceTemplatesResult), + ReadResourceResult(ReadResourceResult), + ListPromptsResult(ListPromptsResult), + GetPromptResult(GetPromptResult), + ListToolsResult(ListToolsResult), + CallToolResult(CallToolResult), + GetTaskResult(GetTaskResult), + GetTaskPayloadResult(GetTaskPayloadResult), + CancelTaskResult(CancelTaskResult), + ListTasksResult(ListTasksResult), + CompleteResult(CompleteResult), + Result(Result), +} +impl ::std::convert::From for ServerResult { + fn from(value: InitializeResult) -> Self { + Self::InitializeResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ListResourcesResult) -> Self { + Self::ListResourcesResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ListResourceTemplatesResult) -> Self { + Self::ListResourceTemplatesResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ReadResourceResult) -> Self { + Self::ReadResourceResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ListPromptsResult) -> Self { + Self::ListPromptsResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: GetPromptResult) -> Self { + Self::GetPromptResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ListToolsResult) -> Self { + Self::ListToolsResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: CallToolResult) -> Self { + Self::CallToolResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: GetTaskResult) -> Self { + Self::GetTaskResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: GetTaskPayloadResult) -> Self { + Self::GetTaskPayloadResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: CancelTaskResult) -> Self { + Self::CancelTaskResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ListTasksResult) -> Self { + Self::ListTasksResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: CompleteResult) -> Self { + Self::CompleteResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: Result) -> Self { + Self::Result(value) + } +} +///Specifies which request types can be augmented with tasks. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "tools": { +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerTaskRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tools: ::std::option::Option, +} +///Task support for tool-related requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerTaskTools { + ///Whether the server supports task-augmented tools/call requests. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub call: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Present if the server supports task-augmented requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the server supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this server supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this server supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "tools": { +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerTasks { + ///Whether this server supports tasks/cancel. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cancel: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Whether this server supports tasks/list. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub list: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub requests: ::std::option::Option, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct SetLevelMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///A request from the client to the server, to enable or adjust logging. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request from the client to the server, to enable or adjust logging.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "logging/setLevel" +/// }, +/// "params": { +/// "$ref": "#/$defs/SetLevelRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SetLevelRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::set_level_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::set_level_request_method")] + method: ::std::string::String, + pub params: SetLevelRequestParams, +} +impl SetLevelRequest { + pub fn new(id: RequestId, params: SetLevelRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "logging/setLevel".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "logging/setLevel" + pub fn method_value() -> ::std::string::String { + "logging/setLevel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "logging/setLevel".to_string() + } +} +///Parameters for a logging/setLevel request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a logging/setLevel request.", +/// "type": "object", +/// "required": [ +/// "level" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "level": { +/// "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.", +/// "$ref": "#/$defs/LoggingLevel" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SetLevelRequestParams { + ///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. + pub level: LoggingLevel, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, +} +///SingleSelectEnumSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/UntitledSingleSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/TitledSingleSelectEnumSchema" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum SingleSelectEnumSchema { + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), +} +impl ::std::convert::From for SingleSelectEnumSchema { + fn from(value: UntitledSingleSelectEnumSchema) -> Self { + Self::UntitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for SingleSelectEnumSchema { + fn from(value: TitledSingleSelectEnumSchema) -> Self { + Self::TitledSingleSelectEnumSchema(value) + } +} +///StringSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "type": "string" +/// }, +/// "description": { +/// "type": "string" +/// }, +/// "format": { +/// "type": "string", +/// "enum": [ +/// "date", +/// "date-time", +/// "email", +/// "uri" +/// ] +/// }, +/// "maxLength": { +/// "type": "integer" +/// }, +/// "minLength": { +/// "type": "integer" +/// }, +/// "title": { +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct StringSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub format: ::std::option::Option, + #[serde(rename = "maxLength", default, skip_serializing_if = "::std::option::Option::is_none")] + pub max_length: ::std::option::Option, + #[serde(rename = "minLength", default, skip_serializing_if = "::std::option::Option::is_none")] + pub min_length: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::string_schema_type_")] + type_: ::std::string::String, +} +impl StringSchema { + pub fn new( + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + format: ::std::option::Option, + max_length: ::std::option::Option, + min_length: ::std::option::Option, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + format, + max_length, + min_length, + title, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///StringSchemaFormat +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "string", +/// "enum": [ +/// "date", +/// "date-time", +/// "email", +/// "uri" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum StringSchemaFormat { + #[serde(rename = "date")] + Date, + #[serde(rename = "date-time")] + DateTime, + #[serde(rename = "email")] + Email, + #[serde(rename = "uri")] + Uri, +} +impl ::std::fmt::Display for StringSchemaFormat { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Date => write!(f, "date"), + Self::DateTime => write!(f, "date-time"), + Self::Email => write!(f, "email"), + Self::Uri => write!(f, "uri"), + } + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct SubscribeMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "resources/subscribe" +/// }, +/// "params": { +/// "$ref": "#/$defs/SubscribeRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SubscribeRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::subscribe_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::subscribe_request_method")] + method: ::std::string::String, + pub params: SubscribeRequestParams, +} +impl SubscribeRequest { + pub fn new(id: RequestId, params: SubscribeRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "resources/subscribe".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "resources/subscribe" + pub fn method_value() -> ::std::string::String { + "resources/subscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "resources/subscribe".to_string() + } +} +///Parameters for a resources/subscribe request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a resources/subscribe request.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "uri": { +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SubscribeRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + pub uri: ::std::string::String, +} +///Data associated with a task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Data associated with a task.", +/// "type": "object", +/// "required": [ +/// "createdAt", +/// "lastUpdatedAt", +/// "status", +/// "taskId", +/// "ttl" +/// ], +/// "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" +/// }, +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Task { + ///ISO 8601 timestamp when the task was created. + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + ///ISO 8601 timestamp when the task was last updated. + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///Suggested polling interval in milliseconds. + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + /**Optional human-readable message describing the current task state. + This can provide context for any status, including: + - Reasons for "cancelled" status + - Summaries for "completed" status + - Diagnostic information for "failed" status (e.g., error details, what went wrong)*/ + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + ///The task identifier. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + ///Actual retention duration from creation in milliseconds, null for unlimited. + pub ttl: i64, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct TaskAugmentedMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Common params for any task-augmented request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Common params for any task-augmented request.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct TaskAugmentedRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, +} +/**Metadata for augmenting a request with task execution. +Include this in the task field of the request parameters.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Metadata for augmenting a request with task execution.\nInclude this in the task field of the request parameters.", +/// "type": "object", +/// "properties": { +/// "ttl": { +/// "description": "Requested duration in milliseconds to retain task from creation.", +/// "type": "integer" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct TaskMetadata { + ///Requested duration in milliseconds to retain task from creation. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ttl: ::std::option::Option, +} +///The status of a task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The status of a task.", +/// "type": "string", +/// "enum": [ +/// "cancelled", +/// "completed", +/// "failed", +/// "input_required", +/// "working" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum TaskStatus { + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "completed")] + Completed, + #[serde(rename = "failed")] + Failed, + #[serde(rename = "input_required")] + InputRequired, + #[serde(rename = "working")] + Working, +} +impl ::std::fmt::Display for TaskStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Cancelled => write!(f, "cancelled"), + Self::Completed => write!(f, "completed"), + Self::Failed => write!(f, "failed"), + Self::InputRequired => write!(f, "input_required"), + Self::Working => write!(f, "working"), + } + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/tasks/status" +/// }, +/// "params": { +/// "$ref": "#/$defs/TaskStatusNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TaskStatusNotification { + #[serde(deserialize_with = "validate::task_status_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::task_status_notification_method")] + method: ::std::string::String, + pub params: TaskStatusNotificationParams, +} +impl TaskStatusNotification { + pub fn new(params: TaskStatusNotificationParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/tasks/status".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/tasks/status" + pub fn method_value() -> ::std::string::String { + "notifications/tasks/status".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/tasks/status".to_string() + } +} +///Parameters for a notifications/tasks/status notification. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a notifications/tasks/status notification.", +/// "allOf": [ +/// { +/// "$ref": "#/$defs/NotificationParams" +/// }, +/// { +/// "$ref": "#/$defs/Task" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TaskStatusNotificationParams { + ///ISO 8601 timestamp when the task was created. + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + ///ISO 8601 timestamp when the task was last updated. + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Suggested polling interval in milliseconds. + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + /**Optional human-readable message describing the current task state. + This can provide context for any status, including: + - Reasons for "cancelled" status + - Summaries for "completed" status + - Diagnostic information for "failed" status (e.g., error details, what went wrong)*/ + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + ///The task identifier. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + ///Actual retention duration from creation in milliseconds, null for unlimited. + pub ttl: i64, +} +///Text provided to or from an LLM. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Text provided to or from an LLM.", +/// "type": "object", +/// "required": [ +/// "text", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "text": { +/// "description": "The text content of the message.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "text" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TextContent { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The text content of the message. + pub text: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::text_content_type_")] + type_: ::std::string::String, +} +impl TextContent { + pub fn new( + text: ::std::string::String, + annotations: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + annotations, + meta, + text, + type_: "text".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "text" + pub fn type_value() -> ::std::string::String { + "text".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "text".to_string() + } +} +///TextResourceContents +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "text", +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TextResourceContents { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The MIME type of this resource, if known. + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + ///The text of the item. This must only be set if the item can actually be represented as text (not binary data). + pub text: ::std::string::String, + ///The URI of this resource. + pub uri: ::std::string::String, +} +///Schema for multiple-selection enumeration with display titles for each option. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for multiple-selection enumeration with display titles for each option.", +/// "type": "object", +/// "required": [ +/// "items", +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "description": "Optional default value.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "description": { +/// "description": "Optional description for the enum field.", +/// "type": "string" +/// }, +/// "items": { +/// "description": "Schema for array items with enum options and display labels.", +/// "type": "object", +/// "required": [ +/// "anyOf" +/// ], +/// "properties": { +/// "anyOf": { +/// "description": "Array of enum options with values and display labels.", +/// "type": "array", +/// "items": { +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The constant enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display title for this option.", +/// "type": "string" +/// } +/// } +/// } +/// } +/// } +/// }, +/// "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": { +/// "type": "string", +/// "const": "array" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledMultiSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub default: ::std::vec::Vec<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub items: TitledMultiSelectEnumSchemaItems, + ///Maximum number of items to select. + #[serde(rename = "maxItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub max_items: ::std::option::Option, + ///Minimum number of items to select. + #[serde(rename = "minItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub min_items: ::std::option::Option, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::titled_multi_select_enum_schema_type_")] + type_: ::std::string::String, +} +impl TitledMultiSelectEnumSchema { + pub fn new( + default: ::std::vec::Vec<::std::string::String>, + items: TitledMultiSelectEnumSchemaItems, + description: ::std::option::Option<::std::string::String>, + max_items: ::std::option::Option, + min_items: ::std::option::Option, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + items, + max_items, + min_items, + title, + type_: "array".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "array" + pub fn type_value() -> ::std::string::String { + "array".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "array".to_string() + } +} +///Schema for array items with enum options and display labels. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for array items with enum options and display labels.", +/// "type": "object", +/// "required": [ +/// "anyOf" +/// ], +/// "properties": { +/// "anyOf": { +/// "description": "Array of enum options with values and display labels.", +/// "type": "array", +/// "items": { +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The constant enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display title for this option.", +/// "type": "string" +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledMultiSelectEnumSchemaItems { + ///Array of enum options with values and display labels. + #[serde(rename = "anyOf")] + pub any_of: ::std::vec::Vec, +} +///TitledMultiSelectEnumSchemaItemsAnyOfItem +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The constant enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display title for this option.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledMultiSelectEnumSchemaItemsAnyOfItem { + ///The constant enum value. + #[serde(rename = "const")] + pub const_: ::std::string::String, + ///Display title for this option. + pub title: ::std::string::String, +} +///Schema for single-selection enumeration with display titles for each option. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for single-selection enumeration with display titles for each option.", +/// "type": "object", +/// "required": [ +/// "oneOf", +/// "type" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display label for this option.", +/// "type": "string" +/// } +/// } +/// } +/// }, +/// "title": { +/// "description": "Optional title for the enum field.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledSingleSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + ///Array of enum options with values and display labels. + #[serde(rename = "oneOf")] + pub one_of: ::std::vec::Vec, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::titled_single_select_enum_schema_type_")] + type_: ::std::string::String, +} +impl TitledSingleSelectEnumSchema { + pub fn new( + one_of: ::std::vec::Vec, + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + one_of, + title, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///TitledSingleSelectEnumSchemaOneOfItem +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display label for this option.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledSingleSelectEnumSchemaOneOfItem { + ///The enum value. + #[serde(rename = "const")] + pub const_: ::std::string::String, + ///Display label for this option. + pub title: ::std::string::String, +} +///Definition for a tool the client can call. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Definition for a tool the client can call.", +/// "type": "object", +/// "required": [ +/// "inputSchema", +/// "name" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional additional tool information.\n\nDisplay name precedence order is: title, annotations.title, then name.", +/// "$ref": "#/$defs/ToolAnnotations" +/// }, +/// "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": { +/// "description": "Execution-related properties for this tool.", +/// "$ref": "#/$defs/ToolExecution" +/// }, +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "inputSchema": { +/// "description": "A JSON Schema object defining the expected parameters for the tool.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "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.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Tool { + /**Optional additional tool information. + Display name precedence order is: title, annotations.title, then name.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + /**A human-readable description of the tool. + This 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.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + ///Execution-related properties for this tool. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub execution: ::std::option::Option, + /**Optional set of sized icons that the client can display in a user interface. + Clients that support rendering icons MUST support at least the following MIME types: + - image/png - PNG images (safe, universal compatibility) + - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility) + Clients that support rendering icons SHOULD also support: + - image/svg+xml - SVG images (scalable but requires security precautions) + - image/webp - WebP images (modern, efficient format)*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub icons: ::std::vec::Vec, + #[serde(rename = "inputSchema")] + pub input_schema: ToolInputSchema, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + pub name: ::std::string::String, + #[serde(rename = "outputSchema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub output_schema: ::std::option::Option, + /**Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + even by those unfamiliar with domain-specific terminology. + If not provided, the name should be used for display (except for Tool, + where annotations.title should be given precedence over using name, + if present).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, +} +/**Additional properties describing a Tool to clients. +NOTE: all properties in ToolAnnotations are **hints**. +They are not guaranteed to provide a faithful description of +tool behavior (including descriptive properties like title). +Clients should never make tool use decisions based on ToolAnnotations +received from untrusted servers.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "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" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ToolAnnotations { + /**If true, the tool may perform destructive updates to its environment. + If false, the tool performs only additive updates. + (This property is meaningful only when readOnlyHint == false) + Default: true*/ + #[serde(rename = "destructiveHint", default, skip_serializing_if = "::std::option::Option::is_none")] + pub destructive_hint: ::std::option::Option, + /**If true, calling the tool repeatedly with the same arguments + will have no additional effect on its environment. + (This property is meaningful only when readOnlyHint == false) + Default: false*/ + #[serde(rename = "idempotentHint", default, skip_serializing_if = "::std::option::Option::is_none")] + pub idempotent_hint: ::std::option::Option, + /**If true, this tool may interact with an "open world" of external + entities. If false, the tool's domain of interaction is closed. + For example, the world of a web search tool is open, whereas that + of a memory tool is not. + Default: true*/ + #[serde(rename = "openWorldHint", default, skip_serializing_if = "::std::option::Option::is_none")] + pub open_world_hint: ::std::option::Option, + /**If true, the tool does not modify its environment. + Default: false*/ + #[serde(rename = "readOnlyHint", default, skip_serializing_if = "::std::option::Option::is_none")] + pub read_only_hint: ::std::option::Option, + ///A human-readable title for the tool. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, +} +///Controls tool selection behavior for sampling requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Controls tool selection behavior for sampling requests.", +/// "type": "object", +/// "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", +/// "type": "string", +/// "enum": [ +/// "auto", +/// "none", +/// "required" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ToolChoice { + /**Controls the tool use ability of the model: + - "auto": Model decides whether to use tools (default) + - "required": Model MUST use at least one tool before completing + - "none": Model MUST NOT use any tools*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub mode: ::std::option::Option, +} +/**Controls the tool use ability of the model: +- "auto": Model decides whether to use tools (default) +- "required": Model MUST use at least one tool before completing +- "none": Model MUST NOT use any tools*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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", +/// "type": "string", +/// "enum": [ +/// "auto", +/// "none", +/// "required" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum ToolChoiceMode { + #[serde(rename = "auto")] + Auto, + #[serde(rename = "none")] + None, + #[serde(rename = "required")] + Required, +} +impl ::std::fmt::Display for ToolChoiceMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Auto => write!(f, "auto"), + Self::None => write!(f, "none"), + Self::Required => write!(f, "required"), + } + } +} +///Execution-related properties for a tool. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Execution-related properties for a tool.", +/// "type": "object", +/// "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\"", +/// "type": "string", +/// "enum": [ +/// "forbidden", +/// "optional", +/// "required" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ToolExecution { + /**Indicates whether this tool supports task-augmented execution. + This allows clients to handle long-running operations through polling + the task system. + - "forbidden": Tool does not support task-augmented execution (default when absent) + - "optional": Tool may support task-augmented execution + - "required": Tool requires task-augmented execution + "*/ + #[serde(rename = "taskSupport", default, skip_serializing_if = "::std::option::Option::is_none")] + pub task_support: ::std::option::Option, +} +/**Indicates whether this tool supports task-augmented execution. +This allows clients to handle long-running operations through polling +the task system. +- "forbidden": Tool does not support task-augmented execution (default when absent) +- "optional": Tool may support task-augmented execution +- "required": Tool requires task-augmented execution + "*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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\"", +/// "type": "string", +/// "enum": [ +/// "forbidden", +/// "optional", +/// "required" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum ToolExecutionTaskSupport { + #[serde(rename = "forbidden")] + Forbidden, + #[serde(rename = "optional")] + Optional, + #[serde(rename = "required")] + Required, +} +impl ::std::fmt::Display for ToolExecutionTaskSupport { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Forbidden => write!(f, "forbidden"), + Self::Optional => write!(f, "optional"), + Self::Required => write!(f, "required"), + } + } +} +///A JSON Schema object defining the expected parameters for the tool. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A JSON Schema object defining the expected parameters for the tool.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolInputSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub properties: ::std::option::Option< + ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, + >, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub required: ::std::vec::Vec<::std::string::String>, + #[serde(rename = "$schema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub schema: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::tool_input_schema_type_")] + type_: ::std::string::String, +} +impl ToolInputSchema { + pub fn new( + required: ::std::vec::Vec<::std::string::String>, + properties: ::std::option::Option< + ::std::collections::HashMap< + ::std::string::String, + ::serde_json::Map<::std::string::String, ::serde_json::Value>, + >, + >, + schema: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + properties, + required, + schema, + type_: "object".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "object".to_string() + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/tools/list_changed" +/// }, +/// "params": { +/// "$ref": "#/$defs/NotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolListChangedNotification { + #[serde(deserialize_with = "validate::tool_list_changed_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::tool_list_changed_notification_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ToolListChangedNotification { + pub fn new(params: ::std::option::Option) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/tools/list_changed".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/tools/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/tools/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/tools/list_changed".to_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.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolOutputSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub properties: ::std::option::Option< + ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, + >, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub required: ::std::vec::Vec<::std::string::String>, + #[serde(rename = "$schema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub schema: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::tool_output_schema_type_")] + type_: ::std::string::String, +} +impl ToolOutputSchema { + pub fn new( + required: ::std::vec::Vec<::std::string::String>, + properties: ::std::option::Option< + ::std::collections::HashMap< + ::std::string::String, + ::serde_json::Map<::std::string::String, ::serde_json::Value>, + >, + >, + schema: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + properties, + required, + schema, + type_: "object".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "object".to_string() + } +} +///The result of a tool use, provided by the user back to the assistant. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The result of a tool use, provided by the user back to the assistant.", +/// "type": "object", +/// "required": [ +/// "content", +/// "toolUseId", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "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](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ContentBlock" +/// } +/// }, +/// "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": { +/// "description": "An optional structured result object.\n\nIf the tool defined an outputSchema, this SHOULD conform to that schema.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "string", +/// "const": "tool_result" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolResultContent { + /**The unstructured result content of the tool use. + This has the same format as CallToolResult.content and can include text, images, + audio, resource links, and embedded resources.*/ + pub content: ::std::vec::Vec, + /**Whether the tool use resulted in an error. + If true, the content typically describes the error that occurred. + Default: false*/ + #[serde(rename = "isError", default, skip_serializing_if = "::std::option::Option::is_none")] + pub is_error: ::std::option::Option, + /**Optional metadata about the tool result. Clients SHOULD preserve this field when + including tool results in subsequent sampling requests to enable caching optimizations. + See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.*/ + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An optional structured result object. + If the tool defined an outputSchema, this SHOULD conform to that schema.*/ + #[serde( + rename = "structuredContent", + default, + skip_serializing_if = "::std::option::Option::is_none" + )] + pub structured_content: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**The ID of the tool use this result corresponds to. + This MUST match the ID from a previous ToolUseContent.*/ + #[serde(rename = "toolUseId")] + pub tool_use_id: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::tool_result_content_type_")] + type_: ::std::string::String, +} +impl ToolResultContent { + pub fn new( + content: ::std::vec::Vec, + tool_use_id: ::std::string::String, + is_error: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + structured_content: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + content, + is_error, + meta, + structured_content, + tool_use_id, + type_: "tool_result".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "tool_result" + pub fn type_value() -> ::std::string::String { + "tool_result".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "tool_result".to_string() + } +} +///A request from the assistant to call a tool. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request from the assistant to call a tool.", +/// "type": "object", +/// "required": [ +/// "id", +/// "input", +/// "name", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "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](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "description": "The arguments to pass to the tool, conforming to the tool's input schema.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "name": { +/// "description": "The name of the tool to call.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "tool_use" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolUseContent { + /**A unique identifier for this tool use. + This ID is used to match tool results to their corresponding tool uses.*/ + pub id: ::std::string::String, + ///The arguments to pass to the tool, conforming to the tool's input schema. + pub input: ::serde_json::Map<::std::string::String, ::serde_json::Value>, + /**Optional metadata about the tool use. Clients SHOULD preserve this field when + including tool uses in subsequent sampling requests to enable caching optimizations. + See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.*/ + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The name of the tool to call. + pub name: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::tool_use_content_type_")] + type_: ::std::string::String, +} +impl ToolUseContent { + pub fn new( + id: ::std::string::String, + input: ::serde_json::Map<::std::string::String, ::serde_json::Value>, + name: ::std::string::String, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + id, + input, + meta, + name, + type_: "tool_use".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "tool_use" + pub fn type_value() -> ::std::string::String { + "tool_use".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "tool_use".to_string() + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct UnsubscribeMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "resources/unsubscribe" +/// }, +/// "params": { +/// "$ref": "#/$defs/UnsubscribeRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UnsubscribeRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::unsubscribe_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::unsubscribe_request_method")] + method: ::std::string::String, + pub params: UnsubscribeRequestParams, +} +impl UnsubscribeRequest { + pub fn new(id: RequestId, params: UnsubscribeRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "resources/unsubscribe".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "resources/unsubscribe" + pub fn method_value() -> ::std::string::String { + "resources/unsubscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "resources/unsubscribe".to_string() + } +} +///Parameters for a resources/unsubscribe request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a resources/unsubscribe request.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/2025-11-25/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "uri": { +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UnsubscribeRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + pub uri: ::std::string::String, +} +///Schema for multiple-selection enumeration without display titles for options. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for multiple-selection enumeration without display titles for options.", +/// "type": "object", +/// "required": [ +/// "items", +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "description": "Optional default value.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "description": { +/// "description": "Optional description for the enum field.", +/// "type": "string" +/// }, +/// "items": { +/// "description": "Schema for the array items.", +/// "type": "object", +/// "required": [ +/// "enum", +/// "type" +/// ], +/// "properties": { +/// "enum": { +/// "description": "Array of enum values to choose from.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +/// }, +/// "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": { +/// "type": "string", +/// "const": "array" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UntitledMultiSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub default: ::std::vec::Vec<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub items: UntitledMultiSelectEnumSchemaItems, + ///Maximum number of items to select. + #[serde(rename = "maxItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub max_items: ::std::option::Option, + ///Minimum number of items to select. + #[serde(rename = "minItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub min_items: ::std::option::Option, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::untitled_multi_select_enum_schema_type_")] + type_: ::std::string::String, +} +impl UntitledMultiSelectEnumSchema { + pub fn new( + default: ::std::vec::Vec<::std::string::String>, + items: UntitledMultiSelectEnumSchemaItems, + description: ::std::option::Option<::std::string::String>, + max_items: ::std::option::Option, + min_items: ::std::option::Option, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + items, + max_items, + min_items, + title, + type_: "array".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "array" + pub fn type_value() -> ::std::string::String { + "array".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "array".to_string() + } +} +///Schema for the array items. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for the array items.", +/// "type": "object", +/// "required": [ +/// "enum", +/// "type" +/// ], +/// "properties": { +/// "enum": { +/// "description": "Array of enum values to choose from.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UntitledMultiSelectEnumSchemaItems { + ///Array of enum values to choose from. + #[serde(rename = "enum")] + pub enum_: ::std::vec::Vec<::std::string::String>, + #[serde( + rename = "type", + deserialize_with = "validate::untitled_multi_select_enum_schema_items_type_" + )] + type_: ::std::string::String, +} +impl UntitledMultiSelectEnumSchemaItems { + pub fn new(enum_: ::std::vec::Vec<::std::string::String>) -> Self { + Self { + enum_, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///Schema for single-selection enumeration without display titles for options. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for single-selection enumeration without display titles for options.", +/// "type": "object", +/// "required": [ +/// "enum", +/// "type" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "title": { +/// "description": "Optional title for the enum field.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UntitledSingleSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + ///Array of enum values to choose from. + #[serde(rename = "enum")] + pub enum_: ::std::vec::Vec<::std::string::String>, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::untitled_single_select_enum_schema_type_")] + type_: ::std::string::String, +} +impl UntitledSingleSelectEnumSchema { + pub fn new( + enum_: ::std::vec::Vec<::std::string::String>, + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + enum_, + title, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///UrlElicitError +/// +///
JSON schema +/// +/// ```json +///{ +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Error" +/// }, +/// { +/// "type": "object", +/// "required": [ +/// "code", +/// "data" +/// ], +/// "properties": { +/// "code": { +/// "type": "integer" +/// }, +/// "data": { +/// "type": "object", +/// "required": [ +/// "elicitations" +/// ], +/// "properties": { +/// "elicitations": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// } +/// } +/// }, +/// "additionalProperties": {} +/// } +/// } +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UrlElicitError { + #[serde(deserialize_with = "validate::url_elicit_error_code")] + code: i64, + pub data: UrlElicitErrorData, + ///A short description of the error. The message SHOULD be limited to a concise single sentence. + pub message: ::std::string::String, +} +impl UrlElicitError { + pub fn new(data: UrlElicitErrorData, message: ::std::string::String) -> Self { + Self { + code: -32042i64, + data, + message, + } + } + pub fn code(&self) -> &i64 { + &self.code + } + /// returns -32042i64 + pub fn code_value() -> i64 { + -32042i64 + } + #[deprecated(since = "0.8.0", note = "Use `code_value()` instead.")] + pub fn code_name() -> i64 { + -32042i64 + } +} +///UrlElicitErrorData +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "elicitations" +/// ], +/// "properties": { +/// "elicitations": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// } +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UrlElicitErrorData { + pub elicitations: ::std::vec::Vec, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///An error response that indicates that the server requires the client to provide additional information via an elicitation request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An error response that indicates that the server requires the client to provide additional information via an elicitation request.", +/// "type": "object", +/// "required": [ +/// "error", +/// "jsonrpc" +/// ], +/// "properties": { +/// "error": { +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Error" +/// }, +/// { +/// "type": "object", +/// "required": [ +/// "code", +/// "data" +/// ], +/// "properties": { +/// "code": { +/// "type": "integer" +/// }, +/// "data": { +/// "type": "object", +/// "required": [ +/// "elicitations" +/// ], +/// "properties": { +/// "elicitations": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// } +/// } +/// }, +/// "additionalProperties": {} +/// } +/// } +/// } +/// ] +/// }, +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UrlElicitationRequiredError { + pub error: UrlElicitError, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub id: ::std::option::Option, + #[serde(deserialize_with = "validate::url_elicitation_required_error_jsonrpc")] + jsonrpc: ::std::string::String, +} +impl UrlElicitationRequiredError { + pub fn new(error: UrlElicitError, id: ::std::option::Option) -> Self { + Self { + error, + id, + jsonrpc: JSONRPC_VERSION.to_string(), + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} +/// Implementing the Deserialize trait +/// This allows enum to be deserialized into correct type based on the value of the "method" +impl<'de> serde::Deserialize<'de> for ClientRequest { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + let value: serde_json::Value = serde::Deserialize::deserialize(deserializer)?; + let method_option = value.get("method").and_then(|v| v.as_str()); + if let Some(method) = method_option { + match method { + "initialize" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::InitializeRequest(req)) + } + "ping" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::PingRequest(req)) + } + "resources/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ListResourcesRequest(req)) + } + "resources/templates/list" => { + let req = + serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ListResourceTemplatesRequest(req)) + } + "resources/read" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ReadResourceRequest(req)) + } + "resources/subscribe" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::SubscribeRequest(req)) + } + "resources/unsubscribe" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::UnsubscribeRequest(req)) + } + "prompts/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ListPromptsRequest(req)) + } + "prompts/get" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::GetPromptRequest(req)) + } + "tools/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ListToolsRequest(req)) + } + "tools/call" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::CallToolRequest(req)) + } + "tasks/get" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::GetTaskRequest(req)) + } + "tasks/result" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::GetTaskPayloadRequest(req)) + } + "tasks/cancel" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::CancelTaskRequest(req)) + } + "tasks/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ListTasksRequest(req)) + } + "logging/setLevel" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::SetLevelRequest(req)) + } + "completion/complete" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::CompleteRequest(req)) + } + _ => Err(serde::de::Error::unknown_variant("method", &[""])), + } + } else { + Err(serde::de::Error::missing_field("method")) + } + } +} +impl ClientRequest { + pub fn method(&self) -> &str { + match self { + ClientRequest::InitializeRequest(request) => request.method(), + ClientRequest::PingRequest(request) => request.method(), + ClientRequest::ListResourcesRequest(request) => request.method(), + ClientRequest::ListResourceTemplatesRequest(request) => request.method(), + ClientRequest::ReadResourceRequest(request) => request.method(), + ClientRequest::SubscribeRequest(request) => request.method(), + ClientRequest::UnsubscribeRequest(request) => request.method(), + ClientRequest::ListPromptsRequest(request) => request.method(), + ClientRequest::GetPromptRequest(request) => request.method(), + ClientRequest::ListToolsRequest(request) => request.method(), + ClientRequest::CallToolRequest(request) => request.method(), + ClientRequest::GetTaskRequest(request) => request.method(), + ClientRequest::GetTaskPayloadRequest(request) => request.method(), + ClientRequest::CancelTaskRequest(request) => request.method(), + ClientRequest::ListTasksRequest(request) => request.method(), + ClientRequest::SetLevelRequest(request) => request.method(), + ClientRequest::CompleteRequest(request) => request.method(), + } + } +} +/// Implementing the Deserialize trait +/// This allows enum to be deserialized into correct type based on the value of the "method" +impl<'de> serde::Deserialize<'de> for ClientNotification { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + let value: serde_json::Value = serde::Deserialize::deserialize(deserializer)?; + let method_option = value.get("method").and_then(|v| v.as_str()); + if let Some(method) = method_option { + match method { + "notifications/cancelled" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientNotification::CancelledNotification(req)) + } + "notifications/initialized" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientNotification::InitializedNotification(req)) + } + "notifications/progress" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientNotification::ProgressNotification(req)) + } + "notifications/tasks/status" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientNotification::TaskStatusNotification(req)) + } + "notifications/roots/list_changed" => { + let req = + serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientNotification::RootsListChangedNotification(req)) + } + _ => Err(serde::de::Error::unknown_variant("method", &[""])), + } + } else { + Err(serde::de::Error::missing_field("method")) + } + } +} +impl ClientNotification { + pub fn method(&self) -> &str { + match self { + ClientNotification::CancelledNotification(request) => request.method(), + ClientNotification::InitializedNotification(request) => request.method(), + ClientNotification::ProgressNotification(request) => request.method(), + ClientNotification::TaskStatusNotification(request) => request.method(), + ClientNotification::RootsListChangedNotification(request) => request.method(), + } + } +} +/// Implementing the Deserialize trait +/// This allows enum to be deserialized into correct type based on the value of the "method" +impl<'de> serde::Deserialize<'de> for ServerRequest { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + let value: serde_json::Value = serde::Deserialize::deserialize(deserializer)?; + let method_option = value.get("method").and_then(|v| v.as_str()); + if let Some(method) = method_option { + match method { + "ping" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::PingRequest(req)) + } + "tasks/get" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::GetTaskRequest(req)) + } + "tasks/result" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::GetTaskPayloadRequest(req)) + } + "tasks/cancel" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::CancelTaskRequest(req)) + } + "tasks/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::ListTasksRequest(req)) + } + "sampling/createMessage" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::CreateMessageRequest(req)) + } + "roots/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::ListRootsRequest(req)) + } + "elicitation/create" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::ElicitRequest(req)) + } + _ => Err(serde::de::Error::unknown_variant("method", &[""])), + } + } else { + Err(serde::de::Error::missing_field("method")) + } + } +} +impl ServerRequest { + pub fn method(&self) -> &str { + match self { + ServerRequest::PingRequest(request) => request.method(), + ServerRequest::GetTaskRequest(request) => request.method(), + ServerRequest::GetTaskPayloadRequest(request) => request.method(), + ServerRequest::CancelTaskRequest(request) => request.method(), + ServerRequest::ListTasksRequest(request) => request.method(), + ServerRequest::CreateMessageRequest(request) => request.method(), + ServerRequest::ListRootsRequest(request) => request.method(), + ServerRequest::ElicitRequest(request) => request.method(), + } + } +} +/// Implementing the Deserialize trait +/// This allows enum to be deserialized into correct type based on the value of the "method" +impl<'de> serde::Deserialize<'de> for ServerNotification { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + let value: serde_json::Value = serde::Deserialize::deserialize(deserializer)?; + let method_option = value.get("method").and_then(|v| v.as_str()); + if let Some(method) = method_option { + match method { + "notifications/cancelled" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::CancelledNotification(req)) + } + "notifications/progress" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::ProgressNotification(req)) + } + "notifications/resources/list_changed" => { + let req = serde_json::from_value::(value) + .map_err(serde::de::Error::custom)?; + Ok(ServerNotification::ResourceListChangedNotification(req)) + } + "notifications/resources/updated" => { + let req = + serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::ResourceUpdatedNotification(req)) + } + "notifications/prompts/list_changed" => { + let req = + serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::PromptListChangedNotification(req)) + } + "notifications/tools/list_changed" => { + let req = + serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::ToolListChangedNotification(req)) + } + "notifications/tasks/status" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::TaskStatusNotification(req)) + } + "notifications/message" => { + let req = + serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::LoggingMessageNotification(req)) + } + "notifications/elicitation/complete" => { + let req = serde_json::from_value::(value) + .map_err(serde::de::Error::custom)?; + Ok(ServerNotification::ElicitationCompleteNotification(req)) + } + _ => Err(serde::de::Error::unknown_variant("method", &[""])), + } + } else { + Err(serde::de::Error::missing_field("method")) + } + } +} +impl ServerNotification { + pub fn method(&self) -> &str { + match self { + ServerNotification::CancelledNotification(request) => request.method(), + ServerNotification::ProgressNotification(request) => request.method(), + ServerNotification::ResourceListChangedNotification(request) => request.method(), + ServerNotification::ResourceUpdatedNotification(request) => request.method(), + ServerNotification::PromptListChangedNotification(request) => request.method(), + ServerNotification::ToolListChangedNotification(request) => request.method(), + ServerNotification::TaskStatusNotification(request) => request.method(), + ServerNotification::LoggingMessageNotification(request) => request.method(), + ServerNotification::ElicitationCompleteNotification(request) => request.method(), + } + } +} +/// Deprecating the old auto-generated verbose names. +/// These were renamed to clearer, shorter names in v0.8.0. +/// The old names are deprecated but kept for backward-compatibility for a smooth migration period. +/// +#[deprecated(since = "0.8.0", note = "Use `IncludeContext` instead.")] +pub type CreateMessageRequestParamsIncludeContext = IncludeContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestContext` instead.")] +pub type CompleteRequestParamsContext = CompleteRequestContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestArgument` instead.")] +pub type CompleteRequestParamsArgument = CompleteRequestArgument; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestRef` instead.")] +pub type CompleteRequestParamsRef = CompleteRequestRef; +#[deprecated(since = "0.8.0", note = "Use `CreateMessageContent` instead.")] +pub type CreateMessageResultContent = CreateMessageContent; +#[deprecated(since = "0.8.0", note = "Use `ElicitResultContent` instead.")] +pub type ElicitResultContentValue = ElicitResultContent; +#[deprecated(since = "0.8.0", note = "Use `ClientRoots` instead.")] +pub type ClientCapabilitiesRoots = ClientRoots; +#[deprecated(since = "0.8.0", note = "Use `ReadResourceContent` instead.")] +pub type ReadResourceResultContentsItem = ReadResourceContent; diff --git a/src/generated_schema/2025_11_25/schema_utils.rs b/src/generated_schema/2025_11_25/schema_utils.rs new file mode 100644 index 0000000..d04c6a3 --- /dev/null +++ b/src/generated_schema/2025_11_25/schema_utils.rs @@ -0,0 +1,5231 @@ +use crate::generated_schema::*; + +use serde::ser::SerializeStruct; +use serde_json::{json, Value}; +use std::hash::{Hash, Hasher}; +use std::result; +use std::{fmt::Display, str::FromStr}; + +#[derive(Debug, PartialEq)] +pub enum MessageTypes { + Request, + Response, + Notification, + Error, +} +/// Implements the `Display` trait for the `MessageTypes` enum, +/// allowing it to be converted into a human-readable string. +impl Display for MessageTypes { + /// Formats the `MessageTypes` enum variant as a string. + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + // Match the current enum variant and return a corresponding string + match self { + MessageTypes::Request => "Request", + MessageTypes::Response => "Response", + MessageTypes::Notification => "Notification", + MessageTypes::Error => "Error", + } + ) + } +} + +/// A utility function used internally to detect the message type from the payload. +/// This function is used when deserializing a `ClientMessage` into strongly-typed structs that represent the specific message received. +#[allow(dead_code)] +fn detect_message_type(value: &serde_json::Value) -> MessageTypes { + let id_field = value.get("id"); + + if id_field.is_some() && value.get("error").is_some() { + return MessageTypes::Error; + } + + let method_field = value.get("method"); + let result_field = value.get("result"); + + if id_field.is_some() { + if result_field.is_some() && method_field.is_none() { + return MessageTypes::Response; + } else if method_field.is_some() { + return MessageTypes::Request; + } + } else if method_field.is_some() { + return MessageTypes::Notification; + } + + MessageTypes::Request +} + +/// Represents a generic MCP (Model Context Protocol) message. +/// This trait defines methods to classify and extract information from messages. +pub trait RpcMessage: McpMessage { + fn request_id(&self) -> Option<&RequestId>; + fn jsonrpc(&self) -> &str; +} + +pub trait McpMessage { + fn is_response(&self) -> bool; + fn is_request(&self) -> bool; + fn is_notification(&self) -> bool; + fn is_error(&self) -> bool; + fn message_type(&self) -> MessageTypes; +} + +/// A trait for converting a message of type `T` into `Self`. +/// This is useful for transforming mcp messages into a Type that could be serialized into a JsonrpcMessage. +/// +/// For example, a ServerMessage can be constructed from a rust_mcp_schema::PingRequest by attaching a RequestId. +/// Eventually, the ServerMessage can be serialized into a valid JsonrpcMessage for transmission over the transport. +pub trait FromMessage +where + Self: Sized, +{ + fn from_message(message: T, request_id: Option) -> std::result::Result; +} + +pub trait ToMessage +where + T: FromMessage, + Self: Sized, +{ + fn to_message(self, request_id: Option) -> std::result::Result; +} + +//*******************************// +//** RequestId Implementations **// +//*******************************// + +// Implement PartialEq and Eq for RequestId +impl PartialEq for RequestId { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (RequestId::String(a), RequestId::String(b)) => a == b, + (RequestId::Integer(a), RequestId::Integer(b)) => a == b, + _ => false, // Different variants are never equal + } + } +} + +impl PartialEq for &RequestId { + fn eq(&self, other: &RequestId) -> bool { + (*self).eq(other) + } +} + +impl Eq for RequestId {} + +// Implement Hash for RequestId, so we can store it in HashMaps, HashSets, etc. +impl Hash for RequestId { + fn hash(&self, state: &mut H) { + match self { + RequestId::String(s) => { + 0u8.hash(state); // Prefix with 0 for String variant + s.hash(state); + } + RequestId::Integer(i) => { + 1u8.hash(state); // Prefix with 1 for Integer variant + i.hash(state); + } + } + } +} + +//*******************// +//** ClientMessage **// +//*******************// + +/// "Similar to JsonrpcMessage, but with the variants restricted to client-side messages." +/// ClientMessage represents a message sent by an MCP Client and received by an MCP Server. +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ClientMessage { + Request(ClientJsonrpcRequest), + Notification(ClientJsonrpcNotification), + Response(ClientJsonrpcResponse), + Error(JsonrpcErrorResponse), +} + +impl ClientMessage { + /// Converts the current message into a `ClientJsonrpcResponse` if it's of the correct type. + /// + /// This function checks if the current message is of type `Response`. If so, it returns the + /// `ClientJsonrpcResponse` wrapped in a `Result::Ok`. If the message is not a `Response`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(ClientJsonrpcResponse)` if the message is a valid `Response`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_response(self) -> std::result::Result { + if let Self::Response(response) = self { + Ok(response) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Response, + self.message_type() + ))) + } + } + + /// Converts the current message into a `ClientJsonrpcRequest` if it's of the correct type. + /// + /// This function checks if the current message is of type `Request`. If so, it returns the + /// `ClientJsonrpcRequest` wrapped in a `Result::Ok`. If the message is not a `Request`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(ClientJsonrpcRequest)` if the message is a valid `Request`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_request(self) -> std::result::Result { + if let Self::Request(request) = self { + Ok(request) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Request, + self.message_type() + ))) + } + } + + /// Converts the current message into a `ClientJsonrpcNotification` if it's of the correct type. + /// + /// This function checks if the current message is of type `Notification`. If so, it returns the + /// `ClientJsonrpcNotification` wrapped in a `Result::Ok`. If the message is not a `Notification`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(ClientJsonrpcNotification)` if the message is a valid `Notification`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_notification(self) -> std::result::Result { + if let Self::Notification(notification) = self { + Ok(notification) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Notification, + self.message_type() + ))) + } + } + + /// Converts the current message into a `JsonrpcErrorResponse` if it's of the correct type. + /// + /// This function checks if the current message is of type `Error`. If so, it returns the + /// `JsonrpcErrorResponse` wrapped in a `Result::Ok`. If the message is not a `Error`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(JsonrpcErrorResponse)` if the message is a valid `Error`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_error(self) -> std::result::Result { + if let Self::Error(error) = self { + Ok(error) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Error, + self.message_type() + ))) + } + } + + /// Returns `true` if message is an `InitializeRequest`. + pub fn is_initialize_request(&self) -> bool { + matches!(self, Self::Request(request) if request.request.is_initialize_request()) + } + + /// Returns `true` if the message is an `InitializedNotification` + pub fn is_initialized_notification(&self) -> bool { + matches!(self, Self::Notification(notofication) if notofication.notification.is_initialized_notification()) + } +} + +impl From for ClientMessage { + fn from(value: ClientJsonrpcNotification) -> Self { + Self::Notification(value) + } +} + +impl From for ClientMessage { + fn from(value: ClientJsonrpcRequest) -> Self { + Self::Request(value) + } +} + +impl From for ClientMessage { + fn from(value: ClientJsonrpcResponse) -> Self { + Self::Response(value) + } +} + +impl RpcMessage for ClientMessage { + // Retrieves the request ID associated with the message, if applicable + fn request_id(&self) -> Option<&RequestId> { + match self { + // If the message is a request, return the associated request ID + ClientMessage::Request(client_jsonrpc_request) => Some(&client_jsonrpc_request.id), + // Notifications do not have request IDs + ClientMessage::Notification(_) => None, + // If the message is a response, return the associated request ID + ClientMessage::Response(client_jsonrpc_response) => Some(&client_jsonrpc_response.id), + // If the message is an error, return the associated request ID + ClientMessage::Error(jsonrpc_error) => jsonrpc_error.id.as_ref(), + } + } + + fn jsonrpc(&self) -> &str { + match self { + ClientMessage::Request(client_jsonrpc_request) => client_jsonrpc_request.jsonrpc(), + ClientMessage::Notification(notification) => notification.jsonrpc(), + ClientMessage::Response(client_jsonrpc_response) => client_jsonrpc_response.jsonrpc(), + ClientMessage::Error(jsonrpc_error) => jsonrpc_error.jsonrpc(), + } + } +} + +// Implementing the `McpMessage` trait for `ClientMessage` +impl McpMessage for ClientMessage { + // Returns true if the message is a response type + fn is_response(&self) -> bool { + matches!(self, ClientMessage::Response(_)) + } + + // Returns true if the message is a request type + fn is_request(&self) -> bool { + matches!(self, ClientMessage::Request(_)) + } + + // Returns true if the message is a notification type (i.e., does not expect a response) + fn is_notification(&self) -> bool { + matches!(self, ClientMessage::Notification(_)) + } + + // Returns true if the message represents an error + fn is_error(&self) -> bool { + matches!(self, ClientMessage::Error(_)) + } + + /// Determines the type of the message and returns the corresponding `MessageTypes` variant. + fn message_type(&self) -> MessageTypes { + match self { + ClientMessage::Request(_) => MessageTypes::Request, + ClientMessage::Notification(_) => MessageTypes::Notification, + ClientMessage::Response(_) => MessageTypes::Response, + ClientMessage::Error(_) => MessageTypes::Error, + } + } +} + +//**************************// +//** ClientJsonrpcRequest **// +//**************************// + +/// "Similar to JsonrpcRequest , but with the variants restricted to client-side requests." +#[derive(Clone, Debug)] +pub struct ClientJsonrpcRequest { + pub id: RequestId, + jsonrpc: ::std::string::String, + pub method: String, + pub request: RequestFromClient, +} + +impl ClientJsonrpcRequest { + pub fn new(id: RequestId, request: RequestFromClient) -> Self { + let method = request.method().to_string(); + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method, + request, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} + +/// Formats the ClientJsonrpcRequest as a JSON string. +impl Display for ClientJsonrpcRequest { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for ClientJsonrpcRequest { + type Err = RpcError; + + /// Parses a JSON-RPC request from a string. + /// + /// This implementation allows `ClientJsonrpcRequest` to be created + /// from a JSON string using the `from_str` method. + /// + /// # Arguments + /// * `s` - A JSON string representing a JSON-RPC request. + /// + /// # Returns + /// * `Ok(ClientJsonrpcRequest)` if parsing is successful. + /// * `Err(RpcError)` if the string is not valid JSON. + /// + /// # Example + /// ``` + /// use std::str::FromStr; + /// use rust_mcp_schema::schema_utils::ClientJsonrpcRequest; + /// + /// let json = r#"{"jsonrpc": "2.0", "method": "initialize", "id": 1}"#; + /// let request = ClientJsonrpcRequest::from_str(json); + /// assert!(request.is_ok()); + /// ``` + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} + +//*************************// +//** Request From Client **// +//*************************// + +/// To determine standard and custom request from the client side +/// Custom requests are of type serde_json::Value and can be deserialized into any custom type. +#[allow(clippy::large_enum_variant)] +#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum RequestFromClient { + ClientRequest(ClientRequest), + CustomRequest(serde_json::Value), +} + +impl TryFrom for ClientRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> result::Result { + if let RequestFromClient::ClientRequest(client_request) = value { + Ok(client_request) + } else { + Err(RpcError::internal_error().with_message("Not a ClientRequest".to_string())) + } + } +} + +impl RequestFromClient { + pub fn method(&self) -> &str { + match self { + RequestFromClient::ClientRequest(request) => request.method(), + RequestFromClient::CustomRequest(request) => request["method"].as_str().unwrap(), + } + } + /// Returns `true` if the request is an `InitializeRequest`. + pub fn is_initialize_request(&self) -> bool { + matches!(self, RequestFromClient::ClientRequest(ClientRequest::InitializeRequest(_))) + } +} + +impl From for RequestFromClient { + fn from(value: ClientRequest) -> Self { + Self::ClientRequest(value) + } +} + +impl From for RequestFromClient { + fn from(value: serde_json::Value) -> Self { + Self::CustomRequest(value) + } +} + +impl<'de> serde::Deserialize<'de> for RequestFromClient { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + let raw_value = Value::deserialize(deserializer)?; + + let client_result = ClientRequest::deserialize(&raw_value); + + match client_result { + Ok(client_request) => Ok(Self::ClientRequest(client_request)), + Err(_) => Ok(Self::CustomRequest(raw_value)), + } + } +} + +//*******************************// +//** ClientJsonrpcNotification **// +//*******************************// + +/// "Similar to JsonrpcNotification , but with the variants restricted to client-side notifications." +#[derive(Clone, Debug)] +pub struct ClientJsonrpcNotification { + jsonrpc: ::std::string::String, + pub method: ::std::string::String, + pub notification: NotificationFromClient, +} + +impl ClientJsonrpcNotification { + pub fn new(notification: NotificationFromClient) -> Self { + let method = notification.method().to_string(); + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method, + notification, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} + +/// Formats the ClientJsonrpcNotification as a JSON string. +impl Display for ClientJsonrpcNotification { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for ClientJsonrpcNotification { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} + +//*******************************// +//** NotificationFromClient **// +//*******************************// + +/// To determine standard and custom notifications received from the MCP Client +/// Custom notifications are of type serde_json::Value and can be deserialized into any custom type. +#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum NotificationFromClient { + ClientNotification(ClientNotification), + CustomNotification(serde_json::Value), +} + +impl TryFrom for ClientNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> result::Result { + if let NotificationFromClient::ClientNotification(client_notification) = value { + Ok(client_notification) + } else { + Err(RpcError::internal_error().with_message("Not a ClientNotification".to_string())) + } + } +} + +impl NotificationFromClient { + /// Returns `true` if the message is an `InitializedNotification` + pub fn is_initialized_notification(&self) -> bool { + matches!( + self, + NotificationFromClient::ClientNotification(ClientNotification::InitializedNotification(_)) + ) + } + + fn method(&self) -> &str { + match self { + NotificationFromClient::ClientNotification(notification) => notification.method(), + NotificationFromClient::CustomNotification(notification) => notification["method"].as_str().unwrap(), + } + } +} + +impl<'de> serde::Deserialize<'de> for NotificationFromClient { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + let raw_value = Value::deserialize(deserializer)?; + + let result = ClientNotification::deserialize(&raw_value); + + match result { + Ok(client_notification) => Ok(Self::ClientNotification(client_notification)), + Err(_) => Ok(Self::CustomNotification(raw_value)), + } + } +} + +//*******************************// +//** ClientJsonrpcResponse **// +//*******************************// + +/// "Similar to JsonrpcResponse , but with the variants restricted to client-side responses." +#[derive(Clone, Debug)] +pub struct ClientJsonrpcResponse { + pub id: RequestId, + jsonrpc: ::std::string::String, + pub result: ResultFromClient, +} + +impl ClientJsonrpcResponse { + pub fn new(id: RequestId, result: ResultFromClient) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + result, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} + +/// Formats the ClientJsonrpcResponse as a JSON string. +impl Display for ClientJsonrpcResponse { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for ClientJsonrpcResponse { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} +//*******************************// +//** ResultFromClient **// +//*******************************// + +/// To determine standard and custom results from the client side +/// Custom results (CustomResult) are of type serde_json::Value and can be deserialized into any custom type. +#[allow(clippy::large_enum_variant)] +#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ResultFromClient { + ClientResult(ClientResult), + /// **Deprecated**: Use `ClientResult::Result` with extra attributes instead. + CustomResult(serde_json::Value), +} + +impl TryFrom for ClientResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> result::Result { + if let ResultFromClient::ClientResult(client_result) = value { + Ok(client_result) + } else { + Err(RpcError::internal_error().with_message("Not a ClientResult".to_string())) + } + } +} + +impl From for ResultFromClient { + fn from(value: ClientResult) -> Self { + Self::ClientResult(value) + } +} + +impl From for ResultFromClient { + fn from(value: serde_json::Value) -> Self { + Self::CustomResult(value) + } +} + +impl<'de> serde::Deserialize<'de> for ResultFromClient { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + let raw_value = Value::deserialize(deserializer)?; + + let result = ClientResult::deserialize(&raw_value); + + match result { + Ok(client_result) => Ok(Self::ClientResult(client_result)), + Err(_) => Ok(Self::CustomResult(raw_value)), + } + } +} + +//*******************************// +//** ClientMessage **// +//*******************************// + +impl FromStr for ClientMessage { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} + +impl Display for ClientMessage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +//*******************// +//** ServerMessage **// +//*******************// + +/// "Similar to JsonrpcMessage, but with the variants restricted to client-side messages." +/// ServerMessage represents a message sent by an MCP Server and received by an MCP Client. +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ServerMessage { + Request(ServerJsonrpcRequest), + Notification(ServerJsonrpcNotification), + Response(ServerJsonrpcResponse), + Error(JsonrpcErrorResponse), +} + +impl ServerMessage { + /// Converts the current message into a `ServerJsonrpcResponse` if it's of the correct type. + /// + /// This function checks if the current message is of type `Response`. If so, it returns the + /// `ServerJsonrpcResponse` wrapped in a `Result::Ok`. If the message is not a `Response`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(ServerJsonrpcResponse)` if the message is a valid `Response`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_response(self) -> std::result::Result { + if let Self::Response(response) = self { + Ok(response) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Response, + self.message_type() + ))) + } + } + + /// Converts the current message into a `ServerJsonrpcRequest` if it's of the correct type. + /// + /// This function checks if the current message is of type `Request`. If so, it returns the + /// `ServerJsonrpcRequest` wrapped in a `Result::Ok`. If the message is not a `Request`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(ServerJsonrpcRequest)` if the message is a valid `Request`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_request(self) -> std::result::Result { + if let Self::Request(request) = self { + Ok(request) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Request, + self.message_type() + ))) + } + } + + /// Converts the current message into a `ServerJsonrpcNotification` if it's of the correct type. + /// + /// This function checks if the current message is of type `Notification`. If so, it returns the + /// `ServerJsonrpcNotification` wrapped in a `Result::Ok`. If the message is not a `Notification`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(ServerJsonrpcNotification)` if the message is a valid `Notification`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_notification(self) -> std::result::Result { + if let Self::Notification(notification) = self { + Ok(notification) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Notification, + self.message_type() + ))) + } + } + + /// Converts the current message into a `JsonrpcErrorResponse` if it's of the correct type. + /// + /// This function checks if the current message is of type `Error`. If so, it returns the + /// `JsonrpcErrorResponse` wrapped in a `Result::Ok`. If the message is not a `Error`, + /// it returns an error with a descriptive message indicating the mismatch in expected message types. + /// + /// # Returns + /// - `Ok(JsonrpcErrorResponse)` if the message is a valid `Error`. + /// - `Err(RpcError)` if the message type is invalid + pub fn as_error(self) -> std::result::Result { + if let Self::Error(error) = self { + Ok(error) + } else { + Err(RpcError::internal_error().with_message(format!( + "Invalid message type, expected: \"{}\" received\"{}\"", + MessageTypes::Error, + self.message_type() + ))) + } + } +} + +impl From for ServerMessage { + fn from(value: ServerJsonrpcNotification) -> Self { + Self::Notification(value) + } +} + +impl From for ServerMessage { + fn from(value: ServerJsonrpcRequest) -> Self { + Self::Request(value) + } +} + +impl From for ServerMessage { + fn from(value: ServerJsonrpcResponse) -> Self { + Self::Response(value) + } +} + +impl RpcMessage for ServerMessage { + // Retrieves the request ID associated with the message, if applicable + fn request_id(&self) -> Option<&RequestId> { + match self { + // If the message is a request, return the associated request ID + ServerMessage::Request(server_jsonrpc_request) => Some(&server_jsonrpc_request.id), + // Notifications do not have request IDs + ServerMessage::Notification(_) => None, + // If the message is a response, return the associated request ID + ServerMessage::Response(server_jsonrpc_response) => Some(&server_jsonrpc_response.id), + // If the message is an error, return the associated request ID + ServerMessage::Error(jsonrpc_error) => jsonrpc_error.id.as_ref(), + } + } + + fn jsonrpc(&self) -> &str { + match self { + // If the message is a request, return the associated request ID + ServerMessage::Request(server_jsonrpc_request) => server_jsonrpc_request.jsonrpc(), + // Notifications do not have request IDs + ServerMessage::Notification(notification) => notification.jsonrpc(), + // If the message is a response, return the associated request ID + ServerMessage::Response(server_jsonrpc_response) => server_jsonrpc_response.jsonrpc(), + // If the message is an error, return the associated request ID + ServerMessage::Error(jsonrpc_error) => jsonrpc_error.jsonrpc(), + } + } +} + +// Implementing the `McpMessage` trait for `ServerMessage` +impl McpMessage for ServerMessage { + // Returns true if the message is a response type + fn is_response(&self) -> bool { + matches!(self, ServerMessage::Response(_)) + } + + // Returns true if the message is a request type + fn is_request(&self) -> bool { + matches!(self, ServerMessage::Request(_)) + } + + // Returns true if the message is a notification type (i.e., does not expect a response) + fn is_notification(&self) -> bool { + matches!(self, ServerMessage::Notification(_)) + } + + // Returns true if the message represents an error + fn is_error(&self) -> bool { + matches!(self, ServerMessage::Error(_)) + } + + /// Determines the type of the message and returns the corresponding `MessageTypes` variant. + fn message_type(&self) -> MessageTypes { + match self { + ServerMessage::Request(_) => MessageTypes::Request, + ServerMessage::Notification(_) => MessageTypes::Notification, + ServerMessage::Response(_) => MessageTypes::Response, + ServerMessage::Error(_) => MessageTypes::Error, + } + } +} + +impl FromStr for ServerMessage { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} + +impl Display for ServerMessage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +//**************************// +//** ServerJsonrpcRequest **// +//**************************// + +/// "Similar to JsonrpcRequest , but with the variants restricted to client-side requests." +#[derive(Clone, Debug)] +#[allow(clippy::large_enum_variant)] +pub struct ServerJsonrpcRequest { + pub id: RequestId, + jsonrpc: ::std::string::String, + pub method: String, + pub request: RequestFromServer, +} + +impl ServerJsonrpcRequest { + pub fn new(id: RequestId, request: RequestFromServer) -> Self { + let method = request.method().to_string(); + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method, + request, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} + +/// Formats the ServerJsonrpcRequest as a JSON string. +impl Display for ServerJsonrpcRequest { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for ServerJsonrpcRequest { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} +//*************************// +//** Request From Server **// +//*************************// + +/// To determine standard and custom request from the server side +/// Custom requests are of type serde_json::Value and can be deserialized into any custom type. +#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum RequestFromServer { + ServerRequest(ServerRequest), + CustomRequest(serde_json::Value), +} + +impl TryFrom for ServerRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> result::Result { + if let RequestFromServer::ServerRequest(server_request) = value { + Ok(server_request) + } else { + Err(RpcError::internal_error().with_message("Not a ServerRequest".to_string())) + } + } +} + +impl RequestFromServer { + pub fn method(&self) -> &str { + match self { + RequestFromServer::ServerRequest(request) => request.method(), + RequestFromServer::CustomRequest(request) => request["method"].as_str().unwrap(), + } + } +} + +impl From for RequestFromServer { + fn from(value: ServerRequest) -> Self { + Self::ServerRequest(value) + } +} + +impl From for RequestFromServer { + fn from(value: serde_json::Value) -> Self { + Self::CustomRequest(value) + } +} + +impl<'de> serde::Deserialize<'de> for RequestFromServer { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + let raw_value = Value::deserialize(deserializer)?; + + let server_result = ServerRequest::deserialize(&raw_value); + + match server_result { + Ok(server_request) => Ok(Self::ServerRequest(server_request)), + Err(_) => Ok(Self::CustomRequest(raw_value)), + } + } +} + +//*******************************// +//** ServerJsonrpcNotification **// +//*******************************// + +/// "Similar to JsonrpcNotification , but with the variants restricted to server-side notifications." +#[derive(Clone, Debug)] +pub struct ServerJsonrpcNotification { + jsonrpc: ::std::string::String, + pub method: ::std::string::String, + pub notification: NotificationFromServer, +} + +impl ServerJsonrpcNotification { + pub fn new(notification: NotificationFromServer) -> Self { + let method = notification.method().to_string(); + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method, + notification, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} + +/// Formats the ServerJsonrpcNotification as a JSON string. +impl Display for ServerJsonrpcNotification { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for ServerJsonrpcNotification { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} +//*******************************// +//** NotificationFromServer **// +//*******************************// + +/// To determine standard and custom notifications received from the MCP Server +/// Custom notifications are of type serde_json::Value and can be deserialized into any custom type. +#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum NotificationFromServer { + ServerNotification(ServerNotification), + CustomNotification(serde_json::Value), +} + +impl TryFrom for ServerNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> result::Result { + if let NotificationFromServer::ServerNotification(server_notification) = value { + Ok(server_notification) + } else { + Err(RpcError::internal_error().with_message("Not a ServerNotification".to_string())) + } + } +} + +impl NotificationFromServer { + pub fn method(&self) -> &str { + match self { + NotificationFromServer::ServerNotification(notification) => notification.method(), + NotificationFromServer::CustomNotification(notification) => notification["method"].as_str().unwrap(), + } + } +} + +impl<'de> serde::Deserialize<'de> for NotificationFromServer { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + let raw_value = Value::deserialize(deserializer)?; + + let result = ServerNotification::deserialize(&raw_value); + + match result { + Ok(client_notification) => Ok(Self::ServerNotification(client_notification)), + Err(_) => Ok(Self::CustomNotification(raw_value)), + } + } +} + +//*******************************// +//** ServerJsonrpcResponse **// +//*******************************// + +/// "Similar to JsonrpcResponse , but with the variants restricted to server-side responses." +#[derive(Clone, Debug)] +pub struct ServerJsonrpcResponse { + pub id: RequestId, + jsonrpc: ::std::string::String, + pub result: ResultFromServer, +} + +impl ServerJsonrpcResponse { + pub fn new(id: RequestId, result: ResultFromServer) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + result, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } +} + +/// Formats the ServerJsonrpcResponse as a JSON string. +impl Display for ServerJsonrpcResponse { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for ServerJsonrpcResponse { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} +//*******************************// +//** ResultFromServer **// +//*******************************// + +/// To determine standard and custom results from the server side +/// Custom results (CustomResult) are of type serde_json::Value and can be deserialized into any custom type. +#[allow(clippy::large_enum_variant)] +#[derive(::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ResultFromServer { + ServerResult(ServerResult), + /// **Deprecated**: Use `ServerResult::Result` with extra attributes instead. + CustomResult(serde_json::Value), +} + +impl TryFrom for ServerResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> result::Result { + if let ResultFromServer::ServerResult(server_result) = value { + Ok(server_result) + } else { + Err(RpcError::internal_error().with_message("Not a ServerResult".to_string())) + } + } +} + +impl From for ResultFromServer { + fn from(value: ServerResult) -> Self { + Self::ServerResult(value) + } +} + +impl From for ResultFromServer { + fn from(value: serde_json::Value) -> Self { + Self::CustomResult(value) + } +} + +impl<'de> serde::Deserialize<'de> for ResultFromServer { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + let raw_value = Value::deserialize(deserializer)?; + + let result = ServerResult::deserialize(&raw_value); + + match result { + Ok(server_result) => Ok(Self::ServerResult(server_result)), + Err(_) => Ok(Self::CustomResult(raw_value)), + } + } +} + +//***************************// +//** impl for JsonrpcErrorResponse **// +//***************************// + +/// Formats the ServerJsonrpcResponse as a JSON string. +impl Display for JsonrpcErrorResponse { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +impl FromStr for JsonrpcErrorResponse { + type Err = RpcError; + + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} + +//**************************// +//** MessageFromServer **// +//**************************// + +/// An enum representing various types of messages that can be sent from an MCP Server. +/// It provides a typed structure for the message payload while skipping internal details like +/// `requestId` and protocol version, which are used solely by the transport layer and +/// do not need to be exposed to the user. +#[derive(::serde::Serialize, ::serde::Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum MessageFromServer { + RequestFromServer(RequestFromServer), + ResultFromServer(ResultFromServer), + NotificationFromServer(NotificationFromServer), + Error(RpcError), +} + +impl From for MessageFromServer { + fn from(value: RequestFromServer) -> Self { + Self::RequestFromServer(value) + } +} + +impl From for MessageFromServer { + fn from(value: ResultFromServer) -> Self { + Self::ResultFromServer(value) + } +} + +impl From for MessageFromServer { + fn from(value: NotificationFromServer) -> Self { + Self::NotificationFromServer(value) + } +} + +impl From for MessageFromServer { + fn from(value: RpcError) -> Self { + Self::Error(value) + } +} + +impl McpMessage for MessageFromServer { + fn is_response(&self) -> bool { + matches!(self, MessageFromServer::ResultFromServer(_)) + } + + fn is_request(&self) -> bool { + matches!(self, MessageFromServer::RequestFromServer(_)) + } + + fn is_notification(&self) -> bool { + matches!(self, MessageFromServer::NotificationFromServer(_)) + } + + fn is_error(&self) -> bool { + matches!(self, MessageFromServer::Error(_)) + } + + fn message_type(&self) -> MessageTypes { + match self { + MessageFromServer::RequestFromServer(_) => MessageTypes::Request, + MessageFromServer::ResultFromServer(_) => MessageTypes::Response, + MessageFromServer::NotificationFromServer(_) => MessageTypes::Notification, + MessageFromServer::Error(_) => MessageTypes::Error, + } + } +} + +impl FromMessage for ServerMessage { + fn from_message(message: MessageFromServer, request_id: Option) -> std::result::Result { + match message { + MessageFromServer::RequestFromServer(request_from_server) => { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new( + request_id, + request_from_server, + ))) + } + MessageFromServer::ResultFromServer(result_from_server) => { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + result_from_server, + ))) + } + MessageFromServer::NotificationFromServer(notification_from_server) => { + if request_id.is_some() { + return Err(RpcError::internal_error() + .with_message("request_id expected to be None for Notifications!".to_string())); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new( + notification_from_server, + ))) + } + MessageFromServer::Error(jsonrpc_error_error) => { + Ok(ServerMessage::Error(JsonrpcErrorResponse::new(jsonrpc_error_error, request_id))) + } + } + } +} + +//**************************// +//** MessageFromClient **// +//**************************// + +/// An enum representing various types of messages that can be sent from an MCP Client. +/// It provides a typed structure for the message payload while skipping internal details like +/// `requestId` and protocol version, which are used solely by the transport layer and +/// do not need to be exposed to the user. +#[derive(::serde::Serialize, ::serde::Deserialize, Clone, Debug)] +#[serde(untagged)] +pub enum MessageFromClient { + RequestFromClient(RequestFromClient), + ResultFromClient(ResultFromClient), + NotificationFromClient(NotificationFromClient), + Error(RpcError), +} + +impl MessageFromClient { + /// Returns `true` if the message is an `InitializeRequest`. + pub fn is_initialize_request(&self) -> bool { + matches!(self, Self::RequestFromClient(request) if request.is_initialize_request()) + } + + /// Returns `true` if the message is an `InitializedNotification` + pub fn is_initialized_notification(&self) -> bool { + matches!(self, Self::NotificationFromClient(notofication) if notofication.is_initialized_notification()) + } +} + +impl From for MessageFromClient { + fn from(value: RequestFromClient) -> Self { + Self::RequestFromClient(value) + } +} + +impl From for MessageFromClient { + fn from(value: ResultFromClient) -> Self { + Self::ResultFromClient(value) + } +} + +impl From for MessageFromClient { + fn from(value: NotificationFromClient) -> Self { + Self::NotificationFromClient(value) + } +} + +impl From for MessageFromClient { + fn from(value: RpcError) -> Self { + Self::Error(value) + } +} + +impl McpMessage for MessageFromClient { + fn is_response(&self) -> bool { + matches!(self, MessageFromClient::ResultFromClient(_)) + } + + fn is_request(&self) -> bool { + matches!(self, MessageFromClient::RequestFromClient(_)) + } + + fn is_notification(&self) -> bool { + matches!(self, MessageFromClient::NotificationFromClient(_)) + } + + fn is_error(&self) -> bool { + matches!(self, MessageFromClient::Error(_)) + } + + fn message_type(&self) -> MessageTypes { + match self { + MessageFromClient::RequestFromClient(_) => MessageTypes::Request, + MessageFromClient::ResultFromClient(_) => MessageTypes::Response, + MessageFromClient::NotificationFromClient(_) => MessageTypes::Notification, + MessageFromClient::Error(_) => MessageTypes::Error, + } + } +} + +impl FromMessage for ClientMessage { + fn from_message(message: MessageFromClient, request_id: Option) -> std::result::Result { + match message { + MessageFromClient::RequestFromClient(request_from_client) => { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new( + request_id, + request_from_client, + ))) + } + MessageFromClient::ResultFromClient(result_from_client) => { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + result_from_client, + ))) + } + MessageFromClient::NotificationFromClient(notification_from_client) => { + if request_id.is_some() { + return Err(RpcError::internal_error() + .with_message("request_id expected to be None for Notifications!".to_string())); + } + + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new( + notification_from_client, + ))) + } + MessageFromClient::Error(jsonrpc_error_error) => { + Ok(ClientMessage::Error(JsonrpcErrorResponse::new(jsonrpc_error_error, request_id))) + } + } + } +} + +//**************************// +//** UnknownTool Error **// +//**************************// + +/// A custom error type `UnknownTool` that wraps a `String`. +/// This can be used as the error type in the result of a `CallToolRequest` when a non-existent or unimplemented tool is called. +#[derive(Debug)] +pub struct UnknownTool(pub String); + +// Implement `Display` for `UnknownTool` to format the error message. +impl core::fmt::Display for UnknownTool { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + // The formatted string will display "Unknown tool: " + write!(f, "Unknown tool: {}", self.0) + } +} + +// Implement the `Error` trait for `UnknownTool`, making it a valid error type. +impl std::error::Error for UnknownTool {} + +//***************************// +//** CallToolError Error **// +//***************************// +/// A specific error type that can hold any kind of error and is used to +/// encapsulate various error scenarios when a `CallToolRequest` fails. +#[derive(Debug)] +pub struct CallToolError(pub Box); + +// Implement methods for `CallToolError` to handle different error types. +impl CallToolError { + /// Constructor to create a new `CallToolError` from a generic error. + pub fn new(err: E) -> Self { + // Box the error to fit inside the `CallToolError` struct + CallToolError(Box::new(err)) + } + + /// Specific constructor to create a `CallToolError` for an `UnknownTool` error. + pub fn unknown_tool(tool_name: impl Into) -> Self { + // Create a `CallToolError` from an `UnknownTool` error (wrapped in a `Box`). + CallToolError(Box::new(UnknownTool(tool_name.into()))) + } + + /// Creates a `CallToolError` for invalid arguments with optional details. + /// + pub fn invalid_arguments(tool_name: impl AsRef, message: Option) -> Self { + // Trim tool_name to remove whitespace and check for emptiness + let tool_name = tool_name.as_ref().trim(); + if tool_name.is_empty() { + return Self::from_message("Invalid arguments: tool name cannot be empty".to_string()); + } + + // Use a descriptive default message if none provided + let default_message = "no additional details provided".to_string(); + let message = message.unwrap_or(default_message); + + // Format the full error message + let full_message = format!("Invalid arguments for tool '{tool_name}': {message}"); + + Self::from_message(full_message) + } + + /// Creates a new `CallToolError` from a string message. + /// + /// This is useful for generating ad-hoc or one-off errors without defining a custom error type. + /// Internally, it wraps the string in a lightweight error type that implements the `Error` trait. + /// + /// # Examples + /// + /// ``` + /// let err = rust_mcp_schema::schema_utils::CallToolError::from_message("Something went wrong"); + /// println!("{:?}", err); + /// ``` + /// + /// # Parameters + /// + /// - `message`: Any type that can be converted into a `String` (e.g., `&str` or `String`) + /// + /// # Returns + /// + /// A `CallToolError` wrapping a dynamic error created from the provided message. + pub fn from_message(message: impl Into) -> Self { + struct MsgError(String); + impl std::fmt::Debug for MsgError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } + } + impl std::fmt::Display for MsgError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } + } + impl std::error::Error for MsgError {} + + CallToolError::new(MsgError(message.into())) + } +} + +/// Converts a `CallToolError` into a `RpcError`. +/// +/// The conversion creates an internal error variant of `RpcError` +/// and attaches the string representation of the original `CallToolError` as a message. +/// +impl From for RpcError { + fn from(value: CallToolError) -> Self { + Self::internal_error().with_message(value.to_string()) + } +} + +/// Conversion of `CallToolError` into a `CallToolResult` with an error. +impl From for CallToolResult { + fn from(value: CallToolError) -> Self { + // Convert `CallToolError` to a `CallToolResult` + CallToolResult { + content: vec![TextContent::new(value.to_string(), None, None).into()], + is_error: Some(true), + meta: None, + structured_content: None, + } + } +} + +// Implement `Display` for `CallToolError` to provide a user-friendly error message. +impl core::fmt::Display for CallToolError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{}", self.0) + } +} + +// Implement `Error` for `CallToolError` to propagate the source of the error. +impl std::error::Error for CallToolError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.0.source() + } +} + +impl CallToolRequest { + /// Retrieves the name of the tool from the request parameters. + /// + /// This method provides access to the tool name stored within the `params` field + /// of the `CallToolRequest` struct, returning it as a string reference. + /// + /// # Returns + /// A reference to the string containing the tool's name. + pub fn tool_name(&self) -> &str { + &self.params.name + } +} + +impl> From for TextContent { + fn from(value: T) -> Self { + TextContent::new(value.into(), None, None) + } +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum ClientMessages { + Single(ClientMessage), + Batch(Vec), +} + +impl ClientMessages { + pub fn is_batch(&self) -> bool { + matches!(self, ClientMessages::Batch(_)) + } + + pub fn includes_request(&self) -> bool { + match self { + ClientMessages::Single(client_message) => client_message.is_request(), + ClientMessages::Batch(client_messages) => client_messages.iter().any(ClientMessage::is_request), + } + } + + pub fn as_single(self) -> result::Result { + match self { + ClientMessages::Single(client_message) => Ok(client_message), + ClientMessages::Batch(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert ClientMessages::Batch to ClientMessage::Single")), + } + } + pub fn as_batch(self) -> result::Result, SdkError> { + match self { + ClientMessages::Single(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert ClientMessage::Single to ClientMessages::Batch")), + ClientMessages::Batch(client_messages) => Ok(client_messages), + } + } +} + +impl From for ClientMessages { + fn from(value: ClientMessage) -> Self { + Self::Single(value) + } +} + +impl From> for ClientMessages { + fn from(value: Vec) -> Self { + Self::Batch(value) + } +} + +impl Display for ClientMessages { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum ServerMessages { + Single(ServerMessage), + Batch(Vec), +} + +impl ServerMessages { + pub fn is_batch(&self) -> bool { + matches!(self, ServerMessages::Batch(_)) + } + + pub fn includes_request(&self) -> bool { + match self { + ServerMessages::Single(server_message) => server_message.is_request(), + ServerMessages::Batch(server_messages) => server_messages.iter().any(ServerMessage::is_request), + } + } + + pub fn as_single(self) -> result::Result { + match self { + ServerMessages::Single(server_message) => Ok(server_message), + ServerMessages::Batch(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert ServerMessages::Batch to ServerMessage::Single")), + } + } + pub fn as_batch(self) -> result::Result, SdkError> { + match self { + ServerMessages::Single(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert ServerMessage::Single to ServerMessages::Batch")), + ServerMessages::Batch(server_messages) => Ok(server_messages), + } + } +} + +impl From for ServerMessages { + fn from(value: ServerMessage) -> Self { + Self::Single(value) + } +} + +impl From> for ServerMessages { + fn from(value: Vec) -> Self { + Self::Batch(value) + } +} + +impl Display for ServerMessages { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum MessagesFromServer { + Single(MessageFromServer), + Batch(Vec), +} + +impl MessagesFromServer { + pub fn is_batch(&self) -> bool { + matches!(self, MessagesFromServer::Batch(_)) + } + + pub fn includes_request(&self) -> bool { + match self { + MessagesFromServer::Single(server_message) => server_message.is_request(), + MessagesFromServer::Batch(server_messages) => server_messages.iter().any(MessageFromServer::is_request), + } + } + + pub fn as_single(self) -> result::Result { + match self { + MessagesFromServer::Single(server_message) => Ok(server_message), + MessagesFromServer::Batch(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert MessagesFromServer::Batch to MessageFromServer::Single")), + } + } + pub fn as_batch(self) -> result::Result, SdkError> { + match self { + MessagesFromServer::Single(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert MessageFromServer::Single to MessagesFromServer::Batch")), + MessagesFromServer::Batch(server_messages) => Ok(server_messages), + } + } +} + +impl From for MessagesFromServer { + fn from(value: MessageFromServer) -> Self { + Self::Single(value) + } +} + +impl From> for MessagesFromServer { + fn from(value: Vec) -> Self { + Self::Batch(value) + } +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(untagged)] +#[allow(clippy::large_enum_variant)] +pub enum MessagesFromClient { + Single(MessageFromClient), + Batch(Vec), +} + +impl MessagesFromClient { + pub fn is_batch(&self) -> bool { + matches!(self, MessagesFromClient::Batch(_)) + } + + pub fn includes_request(&self) -> bool { + match self { + MessagesFromClient::Single(server_message) => server_message.is_request(), + MessagesFromClient::Batch(server_messages) => server_messages.iter().any(MessageFromClient::is_request), + } + } + + pub fn as_single(self) -> result::Result { + match self { + MessagesFromClient::Single(server_message) => Ok(server_message), + MessagesFromClient::Batch(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert MessagesFromClient::Batch to MessageFromClient::Single")), + } + } + pub fn as_batch(self) -> result::Result, SdkError> { + match self { + MessagesFromClient::Single(_) => Err(SdkError::internal_error() + .with_message("Error: cannot convert MessageFromClient::Single to MessagesFromClient::Batch")), + MessagesFromClient::Batch(server_messages) => Ok(server_messages), + } + } +} + +impl From for MessagesFromClient { + fn from(value: MessageFromClient) -> Self { + Self::Single(value) + } +} + +impl From> for MessagesFromClient { + fn from(value: Vec) -> Self { + Self::Batch(value) + } +} + +#[derive(Debug)] +pub struct StringSchemaFormatError { + invalid_value: String, +} + +impl core::fmt::Display for StringSchemaFormatError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "Invalid string schema format: '{}'", self.invalid_value) + } +} + +impl std::error::Error for StringSchemaFormatError {} + +impl FromStr for StringSchemaFormat { + type Err = StringSchemaFormatError; + + fn from_str(s: &str) -> std::result::Result { + match s { + "date" => Ok(Self::Date), + "date-time" => Ok(Self::DateTime), + "email" => Ok(Self::Email), + "uri" => Ok(Self::Uri), + _ => Err(StringSchemaFormatError { + invalid_value: s.to_string(), + }), + } + } +} + + +// Helper: handle all single-select enum variants +fn try_from_enum_schema(map: &serde_json::Map) -> result::Result { + // All enum schemas should have type: "string" (or missing, but usually present) + let has_one_of = map.contains_key("oneOf"); + let has_enum = map.contains_key("enum"); + let has_enum_names = map.contains_key("enumNames"); + + if has_one_of { + let schema: TitledSingleSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse TitledSingleSelectEnumSchema: {e}")) + })?; + + Ok(PrimitiveSchemaDefinition::TitledSingleSelectEnumSchema(schema)) + } else if has_enum && has_enum_names { + let schema: LegacyTitledEnumSchema = serde_json::from_value(Value::Object(map.clone())) + .map_err(|e| RpcError::parse_error().with_message(format!("Failed to parse LegacyTitledEnumSchema: {e}")))?; + Ok(PrimitiveSchemaDefinition::LegacyTitledEnumSchema(schema)) + } else if has_enum { + let schema: UntitledSingleSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse UntitledSingleSelectEnumSchema: {e}")) + })?; + Ok(PrimitiveSchemaDefinition::UntitledSingleSelectEnumSchema(schema)) + } else { + Err(RpcError::parse_error().with_message("Invalid enum schema: missing 'enum' or 'oneOf'".to_string())) + } +} + +// Helper: handle multi-select (array) enum schemas +fn try_from_multi_select_schema( + map: &serde_json::Map, +) -> result::Result { + let items = map + .get("items") + .ok_or(RpcError::parse_error().with_message("Array schema missing 'items' field".to_string()))?; + + let items_obj = items + .as_object() + .ok_or(RpcError::parse_error().with_message("Field 'items' must be an object".to_string()))?; + + if items_obj.contains_key("anyOf") { + let schema: TitledMultiSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse TitledMultiSelectEnumSchema: {e}")) + })?; + Ok(PrimitiveSchemaDefinition::TitledMultiSelectEnumSchema(schema)) + } else if items_obj.contains_key("enum") { + let schema: UntitledMultiSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse UntitledMultiSelectEnumSchema: {e}")) + })?; + Ok(PrimitiveSchemaDefinition::UntitledMultiSelectEnumSchema(schema)) + } else { + Err(RpcError::parse_error() + .with_message("Array schema 'items' must contain 'enum' or 'oneOf' to be a multi-select enum".to_string())) + } +} + +impl TryFrom<&serde_json::Map> for PrimitiveSchemaDefinition { + type Error = RpcError; + + fn try_from(value: &serde_json::Map) -> result::Result { + // 1. First: detect enum schemas (they look like strings but have enum/oneOf) + if value.contains_key("enum") || value.contains_key("oneOf") { + return try_from_enum_schema(value); + } + + // 2. Then: detect multi-select array schemas (type: "array" + items with enum/oneOf) + if value.get("type").and_then(|v| v.as_str()) == Some("array") { + return try_from_multi_select_schema(value); + } + + let input_type = value + .get("type") + .and_then(|v| v.as_str()) + .or_else(|| value.get("oneOf").map(|_| "enum")) // if "oneOf" exists, return "enum" + .ok_or_else(|| { + RpcError::parse_error().with_message("'type' is missing and data type is not supported!".to_string()) + })?; + + let description = value.get("description").and_then(|v| v.as_str().map(|s| s.to_string())); + let title = value.get("title").and_then(|v| v.as_str().map(|s| s.to_string())); + + let schema_definition: PrimitiveSchemaDefinition = match input_type { + "string" => { + let max_length = value.get("maxLength").and_then(|v| v.as_number().and_then(|n| n.as_i64())); + let min_length = value.get("minLength").and_then(|v| v.as_number().and_then(|n| n.as_i64())); + let default = value.get("default").and_then(|v| v.as_str().map(|s| s.to_string())); + + let format_str = value.get("format").and_then(|v| v.as_str()); + let format = format_str.and_then(|s| StringSchemaFormat::from_str(s).ok()); + + PrimitiveSchemaDefinition::StringSchema(StringSchema::new( + default, + description, + format, + max_length, + min_length, + title, + )) + } + "number" | "integer" => { + let maximum = value.get("maximum").and_then(|v| v.as_number().and_then(|n| n.as_i64())); + let minimum = value.get("minimum").and_then(|v| v.as_number().and_then(|n| n.as_i64())); + let default = value.get("default").and_then(|v| v.as_number().and_then(|n| n.as_i64())); + + PrimitiveSchemaDefinition::NumberSchema(NumberSchema { + default, + description, + maximum, + minimum, + title, + type_: if input_type == "integer" { + NumberSchemaType::Integer + } else { + NumberSchemaType::Number + }, + }) + } + "boolean" => { + let default = value.get("default").and_then(|v| v.as_bool().map(|s| s.to_owned())); + PrimitiveSchemaDefinition::BooleanSchema(BooleanSchema::new(default, description, title)) + } + other => { + return Err(RpcError::parse_error().with_message(format!("'{other}' type is not currently supported"))); + } + }; + + Ok(schema_definition) + } +} + +#[deprecated(since = "0.4.0", note = "This trait was renamed to RpcMessage. Use RpcMessage instead.")] +pub type RPCMessage = (); +#[deprecated(since = "0.4.0", note = "This trait was renamed to McpMessage. Use McpMessage instead.")] +pub type MCPMessage = (); + +/// BEGIN AUTO GENERATED +impl ::serde::Serialize for ClientJsonrpcRequest { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: ::serde::Serializer, + { + let mut state = serializer.serialize_struct("JsonrpcRequest", 4)?; + state.serialize_field("id", &self.id)?; + state.serialize_field("jsonrpc", &self.jsonrpc)?; + state.serialize_field("method", &self.method)?; + use ClientRequest::*; + match &self.request { + RequestFromClient::ClientRequest(message) => match message { + InitializeRequest(msg) => state.serialize_field("params", &msg.params)?, + PingRequest(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + ListResourcesRequest(msg) => state.serialize_field("params", &msg.params)?, + ListResourceTemplatesRequest(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + ReadResourceRequest(msg) => state.serialize_field("params", &msg.params)?, + SubscribeRequest(msg) => state.serialize_field("params", &msg.params)?, + UnsubscribeRequest(msg) => state.serialize_field("params", &msg.params)?, + ListPromptsRequest(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + GetPromptRequest(msg) => state.serialize_field("params", &msg.params)?, + ListToolsRequest(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + CallToolRequest(msg) => state.serialize_field("params", &msg.params)?, + GetTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + GetTaskPayloadRequest(msg) => state.serialize_field("params", &msg.params)?, + CancelTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + ListTasksRequest(msg) => state.serialize_field("params", &msg.params)?, + SetLevelRequest(msg) => state.serialize_field("params", &msg.params)?, + CompleteRequest(msg) => state.serialize_field("params", &msg.params)?, + }, + RequestFromClient::CustomRequest(value) => state.serialize_field("params", value)?, + } + state.end() + } +} +impl<'de> ::serde::Deserialize<'de> for ClientJsonrpcRequest { + fn deserialize(deserializer: D) -> std::result::Result + where + D: ::serde::Deserializer<'de>, + { + use serde::de::{self, MapAccess, Visitor}; + use std::fmt; + struct ClientJsonrpcRequestVisitor; + impl<'de> Visitor<'de> for ClientJsonrpcRequestVisitor { + type Value = ClientJsonrpcRequest; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a valid JSON-RPC request object") + } + fn visit_map(self, mut map: M) -> std::result::Result + where + M: MapAccess<'de>, + { + let mut id: Option = None; + let mut jsonrpc: Option = None; + let mut method: Option = None; + let mut params: Option = None; + while let Some(key) = map.next_key::()? { + match key.as_str() { + "id" => id = Some(map.next_value()?), + "jsonrpc" => jsonrpc = Some(map.next_value()?), + "method" => method = Some(map.next_value()?), + "params" => params = Some(map.next_value()?), + _ => { + return Err(de::Error::unknown_field(&key, &["id", "jsonrpc", "method", "params"])); + } + } + } + let id = id.ok_or_else(|| de::Error::missing_field("id"))?; + let jsonrpc = jsonrpc.ok_or_else(|| de::Error::missing_field("jsonrpc"))?; + let method = method.ok_or_else(|| de::Error::missing_field("method"))?; + let params = params.unwrap_or_default(); + let req_object = json!({ "method" : method, "params" : params }); + let request = serde_json::from_value::(req_object).map_err(de::Error::custom)?; + Ok(ClientJsonrpcRequest { + id, + jsonrpc, + method, + request, + }) + } + } + deserializer.deserialize_struct( + "JsonrpcRequest", + &["id", "jsonrpc", "method", "params"], + ClientJsonrpcRequestVisitor, + ) + } +} +impl ::serde::Serialize for ServerJsonrpcRequest { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: ::serde::Serializer, + { + let mut state = serializer.serialize_struct("JsonrpcRequest", 4)?; + state.serialize_field("id", &self.id)?; + state.serialize_field("jsonrpc", &self.jsonrpc)?; + state.serialize_field("method", &self.method)?; + use ServerRequest::*; + match &self.request { + RequestFromServer::ServerRequest(message) => match message { + PingRequest(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + GetTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + GetTaskPayloadRequest(msg) => state.serialize_field("params", &msg.params)?, + CancelTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + ListTasksRequest(msg) => state.serialize_field("params", &msg.params)?, + CreateMessageRequest(msg) => state.serialize_field("params", &msg.params)?, + ListRootsRequest(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + ElicitRequest(msg) => state.serialize_field("params", &msg.params)?, + }, + RequestFromServer::CustomRequest(value) => state.serialize_field("params", value)?, + } + state.end() + } +} +impl<'de> ::serde::Deserialize<'de> for ServerJsonrpcRequest { + fn deserialize(deserializer: D) -> std::result::Result + where + D: ::serde::Deserializer<'de>, + { + use serde::de::{self, MapAccess, Visitor}; + use std::fmt; + struct ServerJsonrpcRequestVisitor; + impl<'de> Visitor<'de> for ServerJsonrpcRequestVisitor { + type Value = ServerJsonrpcRequest; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a valid JSON-RPC request object") + } + fn visit_map(self, mut map: M) -> std::result::Result + where + M: MapAccess<'de>, + { + let mut id: Option = None; + let mut jsonrpc: Option = None; + let mut method: Option = None; + let mut params: Option = None; + while let Some(key) = map.next_key::()? { + match key.as_str() { + "id" => id = Some(map.next_value()?), + "jsonrpc" => jsonrpc = Some(map.next_value()?), + "method" => method = Some(map.next_value()?), + "params" => params = Some(map.next_value()?), + _ => { + return Err(de::Error::unknown_field(&key, &["id", "jsonrpc", "method", "params"])); + } + } + } + let id = id.ok_or_else(|| de::Error::missing_field("id"))?; + let jsonrpc = jsonrpc.ok_or_else(|| de::Error::missing_field("jsonrpc"))?; + let method = method.ok_or_else(|| de::Error::missing_field("method"))?; + let params = params.unwrap_or_default(); + let req_object = json!({ "method" : method, "params" : params }); + let request = serde_json::from_value::(req_object).map_err(de::Error::custom)?; + Ok(ServerJsonrpcRequest { + id, + jsonrpc, + method, + request, + }) + } + } + deserializer.deserialize_struct( + "JsonrpcRequest", + &["id", "jsonrpc", "method", "params"], + ServerJsonrpcRequestVisitor, + ) + } +} +impl ::serde::Serialize for ClientJsonrpcNotification { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: ::serde::Serializer, + { + let mut state = serializer.serialize_struct("JsonrpcNotification", 3)?; + state.serialize_field("jsonrpc", &self.jsonrpc)?; + state.serialize_field("method", &self.method)?; + use ClientNotification::*; + match &self.notification { + NotificationFromClient::ClientNotification(message) => match message { + CancelledNotification(msg) => state.serialize_field("params", &msg.params)?, + InitializedNotification(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + ProgressNotification(msg) => state.serialize_field("params", &msg.params)?, + TaskStatusNotification(msg) => state.serialize_field("params", &msg.params)?, + RootsListChangedNotification(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + }, + NotificationFromClient::CustomNotification(value) => state.serialize_field("params", value)?, + } + state.end() + } +} +impl<'de> ::serde::Deserialize<'de> for ClientJsonrpcNotification { + fn deserialize(deserializer: D) -> std::result::Result + where + D: ::serde::Deserializer<'de>, + { + use serde::de::{self, MapAccess, Visitor}; + use std::fmt; + struct ClientJsonrpcNotificationVisitor; + impl<'de> Visitor<'de> for ClientJsonrpcNotificationVisitor { + type Value = ClientJsonrpcNotification; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a valid JSON-RPC notification object") + } + fn visit_map(self, mut map: M) -> std::result::Result + where + M: MapAccess<'de>, + { + let mut jsonrpc: Option = None; + let mut method: Option = None; + let mut params: Option = None; + while let Some(key) = map.next_key::()? { + match key.as_str() { + "jsonrpc" => jsonrpc = Some(map.next_value()?), + "method" => method = Some(map.next_value()?), + "params" => params = Some(map.next_value()?), + _ => { + return Err(de::Error::unknown_field(&key, &["id", "jsonrpc", "method", "params"])); + } + } + } + let jsonrpc = jsonrpc.ok_or_else(|| de::Error::missing_field("jsonrpc"))?; + let method = method.ok_or_else(|| de::Error::missing_field("method"))?; + let params = params.unwrap_or_default(); + let req_object = json!({ "method" : method, "params" : params }); + let notification = + serde_json::from_value::(req_object).map_err(de::Error::custom)?; + Ok(ClientJsonrpcNotification { + jsonrpc, + method, + notification, + }) + } + } + deserializer.deserialize_struct( + "JsonrpcRequest", + &["jsonrpc", "method", "params"], + ClientJsonrpcNotificationVisitor, + ) + } +} +impl ::serde::Serialize for ServerJsonrpcNotification { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: ::serde::Serializer, + { + let mut state = serializer.serialize_struct("JsonrpcNotification", 3)?; + state.serialize_field("jsonrpc", &self.jsonrpc)?; + state.serialize_field("method", &self.method)?; + use ServerNotification::*; + match &self.notification { + NotificationFromServer::ServerNotification(message) => match message { + CancelledNotification(msg) => state.serialize_field("params", &msg.params)?, + ProgressNotification(msg) => state.serialize_field("params", &msg.params)?, + ResourceListChangedNotification(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + ResourceUpdatedNotification(msg) => state.serialize_field("params", &msg.params)?, + PromptListChangedNotification(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + ToolListChangedNotification(msg) => { + if let Some(params) = &msg.params { + state.serialize_field("params", params)? + } + } + TaskStatusNotification(msg) => state.serialize_field("params", &msg.params)?, + LoggingMessageNotification(msg) => state.serialize_field("params", &msg.params)?, + ElicitationCompleteNotification(msg) => state.serialize_field("params", &msg.params)?, + }, + NotificationFromServer::CustomNotification(value) => state.serialize_field("params", value)?, + } + state.end() + } +} +impl<'de> ::serde::Deserialize<'de> for ServerJsonrpcNotification { + fn deserialize(deserializer: D) -> std::result::Result + where + D: ::serde::Deserializer<'de>, + { + use serde::de::{self, MapAccess, Visitor}; + use std::fmt; + struct ServerJsonrpcNotificationVisitor; + impl<'de> Visitor<'de> for ServerJsonrpcNotificationVisitor { + type Value = ServerJsonrpcNotification; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a valid JSON-RPC notification object") + } + fn visit_map(self, mut map: M) -> std::result::Result + where + M: MapAccess<'de>, + { + let mut jsonrpc: Option = None; + let mut method: Option = None; + let mut params: Option = None; + while let Some(key) = map.next_key::()? { + match key.as_str() { + "jsonrpc" => jsonrpc = Some(map.next_value()?), + "method" => method = Some(map.next_value()?), + "params" => params = Some(map.next_value()?), + _ => { + return Err(de::Error::unknown_field(&key, &["id", "jsonrpc", "method", "params"])); + } + } + } + let jsonrpc = jsonrpc.ok_or_else(|| de::Error::missing_field("jsonrpc"))?; + let method = method.ok_or_else(|| de::Error::missing_field("method"))?; + let params = params.unwrap_or_default(); + let req_object = json!({ "method" : method, "params" : params }); + let notification = + serde_json::from_value::(req_object).map_err(de::Error::custom)?; + Ok(ServerJsonrpcNotification { + jsonrpc, + method, + notification, + }) + } + } + deserializer.deserialize_struct( + "JsonrpcRequest", + &["jsonrpc", "method", "params"], + ServerJsonrpcNotificationVisitor, + ) + } +} +impl ::serde::Serialize for ServerJsonrpcResponse { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: ::serde::Serializer, + { + let mut state = serializer.serialize_struct("JsonrpcResponse", 3)?; + state.serialize_field("id", &self.id)?; + state.serialize_field("jsonrpc", &self.jsonrpc)?; + state.serialize_field("result", &self.result)?; + state.end() + } +} +impl<'de> ::serde::Deserialize<'de> for ServerJsonrpcResponse { + fn deserialize(deserializer: D) -> std::result::Result + where + D: ::serde::Deserializer<'de>, + { + use serde::de::{self, MapAccess, Visitor}; + use std::fmt; + struct ServerJsonrpcResultVisitor; + impl<'de> Visitor<'de> for ServerJsonrpcResultVisitor { + type Value = ServerJsonrpcResponse; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a valid JSON-RPC response object") + } + fn visit_map(self, mut map: M) -> std::result::Result + where + M: MapAccess<'de>, + { + let mut id: Option = None; + let mut jsonrpc: Option = None; + let mut result: Option = None; + while let Some(key) = map.next_key::()? { + match key.as_str() { + "id" => id = Some(map.next_value()?), + "jsonrpc" => jsonrpc = Some(map.next_value()?), + "result" => result = Some(map.next_value()?), + _ => { + return Err(de::Error::unknown_field(&key, &["id", "jsonrpc", "result"])); + } + } + } + let id = id.ok_or_else(|| de::Error::missing_field("id"))?; + let jsonrpc = jsonrpc.ok_or_else(|| de::Error::missing_field("jsonrpc"))?; + let result = result.ok_or_else(|| de::Error::missing_field("result"))?; + let result = serde_json::from_value::(result).map_err(de::Error::custom)?; + Ok(ServerJsonrpcResponse { id, jsonrpc, result }) + } + } + deserializer.deserialize_struct("JsonrpcResponse", &["id", "jsonrpc", "result"], ServerJsonrpcResultVisitor) + } +} +impl ::serde::Serialize for ClientJsonrpcResponse { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: ::serde::Serializer, + { + let mut state = serializer.serialize_struct("JsonrpcResponse", 3)?; + state.serialize_field("id", &self.id)?; + state.serialize_field("jsonrpc", &self.jsonrpc)?; + state.serialize_field("result", &self.result)?; + state.end() + } +} +impl<'de> ::serde::Deserialize<'de> for ClientJsonrpcResponse { + fn deserialize(deserializer: D) -> std::result::Result + where + D: ::serde::Deserializer<'de>, + { + use serde::de::{self, MapAccess, Visitor}; + use std::fmt; + struct ClientJsonrpcResultVisitor; + impl<'de> Visitor<'de> for ClientJsonrpcResultVisitor { + type Value = ClientJsonrpcResponse; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a valid JSON-RPC response object") + } + fn visit_map(self, mut map: M) -> std::result::Result + where + M: MapAccess<'de>, + { + let mut id: Option = None; + let mut jsonrpc: Option = None; + let mut result: Option = None; + while let Some(key) = map.next_key::()? { + match key.as_str() { + "id" => id = Some(map.next_value()?), + "jsonrpc" => jsonrpc = Some(map.next_value()?), + "result" => result = Some(map.next_value()?), + _ => { + return Err(de::Error::unknown_field(&key, &["id", "jsonrpc", "result"])); + } + } + } + let id = id.ok_or_else(|| de::Error::missing_field("id"))?; + let jsonrpc = jsonrpc.ok_or_else(|| de::Error::missing_field("jsonrpc"))?; + let result = result.ok_or_else(|| de::Error::missing_field("result"))?; + let result = serde_json::from_value::(result).map_err(de::Error::custom)?; + Ok(ClientJsonrpcResponse { id, jsonrpc, result }) + } + } + deserializer.deserialize_struct("JsonrpcResponse", &["id", "jsonrpc", "result"], ClientJsonrpcResultVisitor) + } +} +impl From for RequestFromClient { + fn from(value: InitializeRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: PingRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ListResourcesRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ListResourceTemplatesRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ReadResourceRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: SubscribeRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: UnsubscribeRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ListPromptsRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: GetPromptRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ListToolsRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: CallToolRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: GetTaskRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: CancelTaskRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ListTasksRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: SetLevelRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: CompleteRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: InitializeRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: PingRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListResourcesRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListResourceTemplatesRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ReadResourceRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: SubscribeRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: UnsubscribeRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListPromptsRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetPromptRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListToolsRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CallToolRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetTaskRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetTaskPayloadRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CancelTaskRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListTasksRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: SetLevelRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CompleteRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for NotificationFromClient { + fn from(value: CancelledNotification) -> Self { + Self::ClientNotification(value.into()) + } +} +impl From for NotificationFromClient { + fn from(value: InitializedNotification) -> Self { + Self::ClientNotification(value.into()) + } +} +impl From for NotificationFromClient { + fn from(value: ProgressNotification) -> Self { + Self::ClientNotification(value.into()) + } +} +impl From for NotificationFromClient { + fn from(value: TaskStatusNotification) -> Self { + Self::ClientNotification(value.into()) + } +} +impl From for NotificationFromClient { + fn from(value: RootsListChangedNotification) -> Self { + Self::ClientNotification(value.into()) + } +} +impl From for ClientJsonrpcNotification { + fn from(value: CancelledNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ClientJsonrpcNotification { + fn from(value: InitializedNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ClientJsonrpcNotification { + fn from(value: ProgressNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ClientJsonrpcNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ClientJsonrpcNotification { + fn from(value: RootsListChangedNotification) -> Self { + Self::new(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CancelledNotification) -> Self { + MessageFromClient::NotificationFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: InitializedNotification) -> Self { + MessageFromClient::NotificationFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ProgressNotification) -> Self { + MessageFromClient::NotificationFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: TaskStatusNotification) -> Self { + MessageFromClient::NotificationFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: RootsListChangedNotification) -> Self { + MessageFromClient::NotificationFromClient(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: Result) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: GetTaskResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: GetTaskPayloadResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: CancelTaskResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: ListTasksResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: CreateMessageResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: ListRootsResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: ElicitResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: Result) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetTaskResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetTaskPayloadResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CancelTaskResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListTasksResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CreateMessageResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListRootsResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ElicitResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +/// Enum representing SDK error codes. +#[allow(non_camel_case_types)] +pub enum SdkErrorCodes { + CONNECTION_CLOSED = -32000, + REQUEST_TIMEOUT = -32001, + RESOURCE_NOT_FOUND = -32002, + BAD_REQUEST = -32015, + SESSION_NOT_FOUND = -32016, + INVALID_REQUEST = -32600, + METHOD_NOT_FOUND = -32601, + INVALID_PARAMS = -32602, + INTERNAL_ERROR = -32603, + PARSE_ERROR = -32700, + URL_ELICITATION_REQUIRED = -32042, +} +impl core::fmt::Display for SdkErrorCodes { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + SdkErrorCodes::CONNECTION_CLOSED => write!(f, "Connection closed"), + SdkErrorCodes::REQUEST_TIMEOUT => write!(f, "Request timeout"), + SdkErrorCodes::INVALID_REQUEST => write!(f, "Invalid request"), + SdkErrorCodes::METHOD_NOT_FOUND => write!(f, "Method not found"), + SdkErrorCodes::INVALID_PARAMS => write!(f, "Invalid params"), + SdkErrorCodes::INTERNAL_ERROR => write!(f, "Internal error"), + SdkErrorCodes::PARSE_ERROR => write!(f, "Parse Error"), + SdkErrorCodes::RESOURCE_NOT_FOUND => write!(f, "Resource not found"), + SdkErrorCodes::BAD_REQUEST => write!(f, "Bad request"), + SdkErrorCodes::SESSION_NOT_FOUND => write!(f, "Session not found"), + SdkErrorCodes::URL_ELICITATION_REQUIRED => { + write!( + f, + "A required URL was not provided. Please supply the requested URL to continue." + ) + } + } + } +} +impl From for i64 { + fn from(code: SdkErrorCodes) -> Self { + code as i64 + } +} +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SdkError { + ///The error type that occurred. + pub code: i64, + ///Additional information about the error. + pub data: ::std::option::Option<::serde_json::Value>, + ///A short description of the error. + pub message: ::std::string::String, +} +impl core::fmt::Display for SdkError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "MCP error {}: {}", self.code, self.message) + } +} +impl std::error::Error for SdkError { + fn description(&self) -> &str { + &self.message + } +} +impl SdkError { + pub fn new( + error_code: SdkErrorCodes, + message: ::std::string::String, + data: ::std::option::Option<::serde_json::Value>, + ) -> Self { + Self { + code: error_code.into(), + data, + message, + } + } + pub fn connection_closed() -> Self { + Self { + code: SdkErrorCodes::CONNECTION_CLOSED.into(), + data: None, + message: SdkErrorCodes::CONNECTION_CLOSED.to_string(), + } + } + pub fn request_timeout(timeout: u128) -> Self { + Self { + code: SdkErrorCodes::REQUEST_TIMEOUT.into(), + data: Some(json!({ "timeout" : timeout })), + message: SdkErrorCodes::REQUEST_TIMEOUT.to_string(), + } + } + pub fn session_not_found() -> Self { + Self { + code: SdkErrorCodes::SESSION_NOT_FOUND.into(), + data: None, + message: SdkErrorCodes::SESSION_NOT_FOUND.to_string(), + } + } + pub fn invalid_request() -> Self { + Self { + code: SdkErrorCodes::INVALID_REQUEST.into(), + data: None, + message: SdkErrorCodes::INVALID_REQUEST.to_string(), + } + } + pub fn method_not_found() -> Self { + Self { + code: SdkErrorCodes::METHOD_NOT_FOUND.into(), + data: None, + message: SdkErrorCodes::METHOD_NOT_FOUND.to_string(), + } + } + pub fn invalid_params() -> Self { + Self { + code: SdkErrorCodes::INVALID_PARAMS.into(), + data: None, + message: SdkErrorCodes::INVALID_PARAMS.to_string(), + } + } + pub fn internal_error() -> Self { + Self { + code: SdkErrorCodes::INTERNAL_ERROR.into(), + data: None, + message: SdkErrorCodes::INTERNAL_ERROR.to_string(), + } + } + pub fn parse_error() -> Self { + Self { + code: SdkErrorCodes::PARSE_ERROR.into(), + data: None, + message: SdkErrorCodes::PARSE_ERROR.to_string(), + } + } + /// Creates a new `RpcError` indicating that a URL elicitation failed + /// and was required for the operation to continue. + /// + /// The resulting error uses the -32042 value as introduced in mcp protocol 2025-11-25 + /// The result json matches a UrlElicitError and the `data` value could be deserialized into UrlElicitErrorData + /// + pub fn url_elicit_required(elicit_url_params: Vec) -> Self { + Self { + code: UrlElicitError::code_value(), + data: Some(serde_json::to_value(elicit_url_params).unwrap_or_else(|_| { + json!( + { "elicitations" : [], "error" : + "failed to UrlElicitError data" } + ) + })), + message: "URL required. Please provide a URL.".to_string(), + } + } + pub fn resource_not_found() -> Self { + Self { + code: SdkErrorCodes::RESOURCE_NOT_FOUND.into(), + data: None, + message: SdkErrorCodes::RESOURCE_NOT_FOUND.to_string(), + } + } + pub fn bad_request() -> Self { + Self { + code: SdkErrorCodes::BAD_REQUEST.into(), + data: None, + message: SdkErrorCodes::RESOURCE_NOT_FOUND.to_string(), + } + } + pub fn with_message(mut self, message: &str) -> Self { + self.message = message.to_string(); + self + } + pub fn with_data(mut self, data: ::std::option::Option<::serde_json::Value>) -> Self { + self.data = data; + self + } +} +/// Enum representing standard and mcp specific JSON-RPC error codes. +#[allow(non_camel_case_types)] +pub enum RpcErrorCodes { + PARSE_ERROR = -32700isize, + INVALID_REQUEST = -32600isize, + METHOD_NOT_FOUND = -32601isize, + INVALID_PARAMS = -32602isize, + INTERNAL_ERROR = -32603isize, + URL_ELICITATION_REQUIRED = -32042isize, +} +impl From for i64 { + fn from(code: RpcErrorCodes) -> Self { + code as i64 + } +} +impl RpcError { + /// Constructs a new `RpcError` with the provided arguments. + /// + /// # Arguments + /// * `error_code` - The JSON-RPC error code. + /// * `message` - A descriptive error message. + /// * `data` - Optional additional data. + /// + /// # Example + /// ``` + /// use serde_json::json; + /// use rust_mcp_schema::{RpcError, schema_utils::RpcErrorCodes}; + /// + /// let error = RpcError::new(RpcErrorCodes::INVALID_PARAMS, "Invalid params!".to_string(), Some(json!({"details": "Missing method field"}))); + /// assert_eq!(error.code, -32602); + /// assert_eq!(error.message, "Invalid params!".to_string()); + /// ``` + pub fn new( + error_code: RpcErrorCodes, + message: ::std::string::String, + data: ::std::option::Option<::serde_json::Value>, + ) -> Self { + Self { + code: error_code.into(), + data, + message, + } + } + /// Creates a new `RpcError` for "Method not found". + /// + /// # Example + /// ``` + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::method_not_found(); + /// assert_eq!(error.code, -32601); + /// assert_eq!(error.message, "Method not found"); + /// ``` + pub fn method_not_found() -> Self { + Self { + code: RpcErrorCodes::METHOD_NOT_FOUND.into(), + data: None, + message: "Method not found".to_string(), + } + } + /// Creates a new `RpcError` indicating that a URL elicitation failed + /// and was required for the operation to continue. + /// + /// The resulting error uses the -32042 value as introduced in mcp protocol 2025-11-25 + /// The result json matches a UrlElicitError and the `data` value could be deserialized into UrlElicitErrorData + /// + pub fn url_elicit_required(elicit_url_params: Vec) -> Self { + Self { + code: UrlElicitError::code_value(), + data: Some(serde_json::to_value(elicit_url_params).unwrap_or_else(|_| { + json!( + { "elicitations" : [], "error" : + "failed to UrlElicitError data" } + ) + })), + message: "URL required. Please provide a URL.".to_string(), + } + } + /// Creates a new `RpcError` for "Invalid parameters". + /// + /// # Example + /// ``` + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::invalid_params(); + /// assert_eq!(error.code, -32602); + /// ``` + pub fn invalid_params() -> Self { + Self { + code: RpcErrorCodes::INVALID_PARAMS.into(), + data: None, + message: "Invalid params".to_string(), + } + } + /// Creates a new `RpcError` for "Invalid request". + /// + /// # Example + /// ``` + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::invalid_request(); + /// assert_eq!(error.code, -32600); + /// ``` + pub fn invalid_request() -> Self { + Self { + code: RpcErrorCodes::INVALID_REQUEST.into(), + data: None, + message: "Invalid request".to_string(), + } + } + /// Creates a new `RpcError` for "Internal error". + /// + /// # Example + /// ``` + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::internal_error(); + /// assert_eq!(error.code, -32603); + /// ``` + pub fn internal_error() -> Self { + Self { + code: RpcErrorCodes::INTERNAL_ERROR.into(), + data: None, + message: "Internal error".to_string(), + } + } + /// Creates a new `RpcError` for "Parse error". + /// + /// # Example + /// ``` + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::parse_error(); + /// assert_eq!(error.code, -32700); + /// ``` + pub fn parse_error() -> Self { + Self { + code: RpcErrorCodes::PARSE_ERROR.into(), + data: None, + message: "Parse error".to_string(), + } + } + /// Sets a custom error message. + /// + /// # Example + /// ``` + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::invalid_request().with_message("Request format is invalid".to_string()); + /// assert_eq!(error.message, "Request format is invalid".to_string()); + /// ``` + pub fn with_message(mut self, message: String) -> Self { + self.message = message; + self + } + /// Attaches optional data to the error. + /// + /// # Example + /// ``` + /// use serde_json::json; + /// use rust_mcp_schema::RpcError; + /// + /// let error = RpcError::invalid_request().with_data(Some(json!({"reason": "Missing ID"}))); + /// assert!(error.data.is_some()); + /// ``` + pub fn with_data(mut self, data: ::std::option::Option<::serde_json::Value>) -> Self { + self.data = data; + self + } +} +impl std::error::Error for RpcError { + fn description(&self) -> &str { + &self.message + } +} +impl Display for RpcError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string(self).unwrap_or_else(|err| format!("Serialization error: {err}")) + ) + } +} +impl FromStr for RpcError { + type Err = RpcError; + fn from_str(s: &str) -> std::result::Result { + serde_json::from_str(s) + .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) + } +} +///Constructs a new `JsonrpcErrorResponse` using the provided arguments. +impl JsonrpcErrorResponse { + pub fn create( + id: Option, + error_code: RpcErrorCodes, + error_message: ::std::string::String, + error_data: ::std::option::Option<::serde_json::Value>, + ) -> Self { + Self::new(RpcError::new(error_code, error_message, error_data), id) + } +} +impl From for NotificationFromServer { + fn from(value: CancelledNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: ProgressNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: ResourceListChangedNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: ResourceUpdatedNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: PromptListChangedNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: ToolListChangedNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: TaskStatusNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: LoggingMessageNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for NotificationFromServer { + fn from(value: ElicitationCompleteNotification) -> Self { + Self::ServerNotification(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: CancelledNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: ProgressNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: ResourceListChangedNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: ResourceUpdatedNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: PromptListChangedNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: ToolListChangedNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: LoggingMessageNotification) -> Self { + Self::new(value.into()) + } +} +impl From for ServerJsonrpcNotification { + fn from(value: ElicitationCompleteNotification) -> Self { + Self::new(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CancelledNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ProgressNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ResourceListChangedNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ResourceUpdatedNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: PromptListChangedNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ToolListChangedNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: TaskStatusNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: LoggingMessageNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ElicitationCompleteNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: PingRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: GetTaskRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: CancelTaskRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: ListTasksRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: CreateMessageRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: ListRootsRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: ElicitRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: PingRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetTaskRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetTaskPayloadRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CancelTaskRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListTasksRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CreateMessageRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListRootsRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ElicitRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: Result) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: InitializeResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ListResourcesResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ListResourceTemplatesResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ReadResourceResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ListPromptsResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: GetPromptResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ListToolsResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: CallToolResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: GetTaskResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: GetTaskPayloadResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: CancelTaskResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ListTasksResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: CompleteResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: Result) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: InitializeResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListResourcesResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListResourceTemplatesResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ReadResourceResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListPromptsResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetPromptResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListToolsResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CallToolResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetTaskResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetTaskPayloadResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CancelTaskResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListTasksResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CompleteResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: InitializeRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for InitializeRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: PingRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for PingRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListResourcesRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListResourcesRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message( + message: ListResourceTemplatesRequest, + request_id: Option, + ) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListResourceTemplatesRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ReadResourceRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ReadResourceRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: SubscribeRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for SubscribeRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: UnsubscribeRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for UnsubscribeRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListPromptsRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListPromptsRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetPromptRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetPromptRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListToolsRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListToolsRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CallToolRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CallToolRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskPayloadRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskPayloadRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CancelTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CancelTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListTasksRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListTasksRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: SetLevelRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for SetLevelRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CompleteRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CompleteRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: Result, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for Result { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskPayloadResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskPayloadResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CancelTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CancelTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListTasksResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListTasksResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CreateMessageResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CreateMessageResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListRootsResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListRootsResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ElicitResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ElicitResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CancelledNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for CancelledNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: InitializedNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for InitializedNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ProgressNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ProgressNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: TaskStatusNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for TaskStatusNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message( + message: RootsListChangedNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for RootsListChangedNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: PingRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for PingRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskPayloadRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskPayloadRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CancelTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CancelTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListTasksRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListTasksRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CreateMessageRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CreateMessageRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListRootsRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListRootsRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ElicitRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ElicitRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: Result, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for Result { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: InitializeResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for InitializeResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListResourcesResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListResourcesResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: ListResourceTemplatesResult, + request_id: Option, + ) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListResourceTemplatesResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ReadResourceResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ReadResourceResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListPromptsResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListPromptsResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetPromptResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetPromptResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListToolsResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListToolsResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CallToolResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CallToolResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskPayloadResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskPayloadResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CancelTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CancelTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListTasksResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListTasksResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CompleteResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CompleteResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CancelledNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for CancelledNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ProgressNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ProgressNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: ResourceListChangedNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ResourceListChangedNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: ResourceUpdatedNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ResourceUpdatedNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: PromptListChangedNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for PromptListChangedNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: ToolListChangedNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ToolListChangedNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: TaskStatusNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for TaskStatusNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: LoggingMessageNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for LoggingMessageNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message( + message: ElicitationCompleteNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ElicitationCompleteNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl TryFrom for InitializeRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::InitializeRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a InitializeRequest".to_string())) + } + } +} +impl TryFrom for PingRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::PingRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a PingRequest".to_string())) + } + } +} +impl TryFrom for ListResourcesRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ListResourcesRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListResourcesRequest".to_string())) + } + } +} +impl TryFrom for ListResourceTemplatesRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ListResourceTemplatesRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListResourceTemplatesRequest".to_string())) + } + } +} +impl TryFrom for ReadResourceRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ReadResourceRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ReadResourceRequest".to_string())) + } + } +} +impl TryFrom for SubscribeRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::SubscribeRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a SubscribeRequest".to_string())) + } + } +} +impl TryFrom for UnsubscribeRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::UnsubscribeRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a UnsubscribeRequest".to_string())) + } + } +} +impl TryFrom for ListPromptsRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ListPromptsRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListPromptsRequest".to_string())) + } + } +} +impl TryFrom for GetPromptRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::GetPromptRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetPromptRequest".to_string())) + } + } +} +impl TryFrom for ListToolsRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ListToolsRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListToolsRequest".to_string())) + } + } +} +impl TryFrom for CallToolRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::CallToolRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CallToolRequest".to_string())) + } + } +} +impl TryFrom for GetTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::GetTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskRequest".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::GetTaskPayloadRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadRequest".to_string())) + } + } +} +impl TryFrom for CancelTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::CancelTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskRequest".to_string())) + } + } +} +impl TryFrom for ListTasksRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ListTasksRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksRequest".to_string())) + } + } +} +impl TryFrom for SetLevelRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::SetLevelRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a SetLevelRequest".to_string())) + } + } +} +impl TryFrom for CompleteRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::CompleteRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CompleteRequest".to_string())) + } + } +} +impl TryFrom for Result { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::Result(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a Result".to_string())) + } + } +} +impl TryFrom for GetTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::GetTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskResult".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::GetTaskPayloadResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadResult".to_string())) + } + } +} +impl TryFrom for CancelTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::CancelTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskResult".to_string())) + } + } +} +impl TryFrom for ListTasksResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::ListTasksResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksResult".to_string())) + } + } +} +impl TryFrom for CreateMessageResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::CreateMessageResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CreateMessageResult".to_string())) + } + } +} +impl TryFrom for ListRootsResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::ListRootsResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListRootsResult".to_string())) + } + } +} +impl TryFrom for ElicitResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::ElicitResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ElicitResult".to_string())) + } + } +} +impl TryFrom for CancelledNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> std::result::Result { + let matched_type: ClientNotification = value.try_into()?; + if let ClientNotification::CancelledNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelledNotification".to_string())) + } + } +} +impl TryFrom for InitializedNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> std::result::Result { + let matched_type: ClientNotification = value.try_into()?; + if let ClientNotification::InitializedNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a InitializedNotification".to_string())) + } + } +} +impl TryFrom for ProgressNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> std::result::Result { + let matched_type: ClientNotification = value.try_into()?; + if let ClientNotification::ProgressNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ProgressNotification".to_string())) + } + } +} +impl TryFrom for TaskStatusNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> std::result::Result { + let matched_type: ClientNotification = value.try_into()?; + if let ClientNotification::TaskStatusNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a TaskStatusNotification".to_string())) + } + } +} +impl TryFrom for RootsListChangedNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> std::result::Result { + let matched_type: ClientNotification = value.try_into()?; + if let ClientNotification::RootsListChangedNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a RootsListChangedNotification".to_string())) + } + } +} +impl TryFrom for PingRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::PingRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a PingRequest".to_string())) + } + } +} +impl TryFrom for GetTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::GetTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskRequest".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::GetTaskPayloadRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadRequest".to_string())) + } + } +} +impl TryFrom for CancelTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::CancelTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskRequest".to_string())) + } + } +} +impl TryFrom for ListTasksRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::ListTasksRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksRequest".to_string())) + } + } +} +impl TryFrom for CreateMessageRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::CreateMessageRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CreateMessageRequest".to_string())) + } + } +} +impl TryFrom for ListRootsRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::ListRootsRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListRootsRequest".to_string())) + } + } +} +impl TryFrom for ElicitRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::ElicitRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ElicitRequest".to_string())) + } + } +} +impl TryFrom for Result { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::Result(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a Result".to_string())) + } + } +} +impl TryFrom for InitializeResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::InitializeResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a InitializeResult".to_string())) + } + } +} +impl TryFrom for ListResourcesResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ListResourcesResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListResourcesResult".to_string())) + } + } +} +impl TryFrom for ListResourceTemplatesResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ListResourceTemplatesResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListResourceTemplatesResult".to_string())) + } + } +} +impl TryFrom for ReadResourceResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ReadResourceResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ReadResourceResult".to_string())) + } + } +} +impl TryFrom for ListPromptsResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ListPromptsResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListPromptsResult".to_string())) + } + } +} +impl TryFrom for GetPromptResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::GetPromptResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetPromptResult".to_string())) + } + } +} +impl TryFrom for ListToolsResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ListToolsResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListToolsResult".to_string())) + } + } +} +impl TryFrom for CallToolResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::CallToolResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CallToolResult".to_string())) + } + } +} +impl TryFrom for GetTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::GetTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskResult".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::GetTaskPayloadResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadResult".to_string())) + } + } +} +impl TryFrom for CancelTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::CancelTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskResult".to_string())) + } + } +} +impl TryFrom for ListTasksResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ListTasksResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksResult".to_string())) + } + } +} +impl TryFrom for CompleteResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::CompleteResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CompleteResult".to_string())) + } + } +} +impl TryFrom for CancelledNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::CancelledNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelledNotification".to_string())) + } + } +} +impl TryFrom for ProgressNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::ProgressNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ProgressNotification".to_string())) + } + } +} +impl TryFrom for ResourceListChangedNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::ResourceListChangedNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ResourceListChangedNotification".to_string())) + } + } +} +impl TryFrom for ResourceUpdatedNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::ResourceUpdatedNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ResourceUpdatedNotification".to_string())) + } + } +} +impl TryFrom for PromptListChangedNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::PromptListChangedNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a PromptListChangedNotification".to_string())) + } + } +} +impl TryFrom for ToolListChangedNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::ToolListChangedNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ToolListChangedNotification".to_string())) + } + } +} +impl TryFrom for TaskStatusNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::TaskStatusNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a TaskStatusNotification".to_string())) + } + } +} +impl TryFrom for LoggingMessageNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::LoggingMessageNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a LoggingMessageNotification".to_string())) + } + } +} +impl TryFrom for ElicitationCompleteNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::ElicitationCompleteNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ElicitationCompleteNotification".to_string())) + } + } +} +impl ContentBlock { + ///Create a ContentBlock::TextContent + pub fn text_content(text: ::std::string::String) -> Self { + TextContent::new(text, None, None).into() + } + ///Create a ContentBlock::ImageContent + pub fn image_content(data: ::std::string::String, mime_type: ::std::string::String) -> Self { + ImageContent::new(data, mime_type, None, None).into() + } + ///Create a ContentBlock::AudioContent + pub fn audio_content(data: ::std::string::String, mime_type: ::std::string::String) -> Self { + AudioContent::new(data, mime_type, None, None).into() + } + ///Create a ContentBlock::ResourceLink + pub fn resource_link(value: ResourceLink) -> Self { + value.into() + } + ///Create a ContentBlock::EmbeddedResource + pub fn embedded_resource(resource: EmbeddedResourceResource) -> Self { + EmbeddedResource::new(resource, None, None).into() + } + ///Returns the content type as a string based on the variant of `ContentBlock` + pub fn content_type(&self) -> &str { + match self { + ContentBlock::TextContent(text_content) => text_content.type_(), + ContentBlock::ImageContent(image_content) => image_content.type_(), + ContentBlock::AudioContent(audio_content) => audio_content.type_(), + ContentBlock::ResourceLink(resource_link) => resource_link.type_(), + ContentBlock::EmbeddedResource(embedded_resource) => embedded_resource.type_(), + } + } + /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid. + pub fn as_text_content(&self) -> std::result::Result<&TextContent, RpcError> { + match &self { + ContentBlock::TextContent(text_content) => Ok(text_content), + _ => Err(RpcError::internal_error().with_message(format!( + "Invalid conversion, \"{}\" is not a {}", + self.content_type(), + "TextContent" + ))), + } + } + /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid. + pub fn as_image_content(&self) -> std::result::Result<&ImageContent, RpcError> { + match &self { + ContentBlock::ImageContent(image_content) => Ok(image_content), + _ => Err(RpcError::internal_error().with_message(format!( + "Invalid conversion, \"{}\" is not a {}", + self.content_type(), + "ImageContent" + ))), + } + } + /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid. + pub fn as_audio_content(&self) -> std::result::Result<&AudioContent, RpcError> { + match &self { + ContentBlock::AudioContent(audio_content) => Ok(audio_content), + _ => Err(RpcError::internal_error().with_message(format!( + "Invalid conversion, \"{}\" is not a {}", + self.content_type(), + "AudioContent" + ))), + } + } + /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid. + pub fn as_resource_link(&self) -> std::result::Result<&ResourceLink, RpcError> { + match &self { + ContentBlock::ResourceLink(resource_link) => Ok(resource_link), + _ => Err(RpcError::internal_error().with_message(format!( + "Invalid conversion, \"{}\" is not a {}", + self.content_type(), + "ResourceLink" + ))), + } + } + /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid. + pub fn as_embedded_resource(&self) -> std::result::Result<&EmbeddedResource, RpcError> { + match &self { + ContentBlock::EmbeddedResource(embedded_resource) => Ok(embedded_resource), + _ => Err(RpcError::internal_error().with_message(format!( + "Invalid conversion, \"{}\" is not a {}", + self.content_type(), + "EmbeddedResource" + ))), + } + } +} +impl CallToolResult { + pub fn text_content(content: Vec) -> Self { + Self { + content: content.into_iter().map(Into::into).collect(), + is_error: None, + meta: None, + structured_content: None, + } + } + pub fn image_content(content: Vec) -> Self { + Self { + content: content.into_iter().map(Into::into).collect(), + is_error: None, + meta: None, + structured_content: None, + } + } + pub fn audio_content(content: Vec) -> Self { + Self { + content: content.into_iter().map(Into::into).collect(), + is_error: None, + meta: None, + structured_content: None, + } + } + pub fn resource_link(content: Vec) -> Self { + Self { + content: content.into_iter().map(Into::into).collect(), + is_error: None, + meta: None, + structured_content: None, + } + } + pub fn embedded_resource(content: Vec) -> Self { + Self { + content: content.into_iter().map(Into::into).collect(), + is_error: None, + meta: None, + structured_content: None, + } + } + /// Create a `CallToolResult` with an error, containing an error message in the content + pub fn with_error(error: CallToolError) -> Self { + Self { + content: vec![ContentBlock::TextContent(TextContent::new(error.to_string(), None, None))], + is_error: Some(true), + meta: None, + structured_content: None, + } + } + /// Assigns metadata to the CallToolResult, enabling the inclusion of extra context or details. + pub fn with_meta(mut self, meta: Option>) -> Self { + self.meta = meta; + self + } + /// Assigns structured_content to the CallToolResult + pub fn with_structured_content( + mut self, + structured_content: ::serde_json::Map<::std::string::String, ::serde_json::Value>, + ) -> Self { + self.structured_content = Some(structured_content); + self + } +} +/// END AUTO GENERATED +#[cfg(test)] +mod tests { + // use super::*; + // use serde_json::json; + + // #[test] + // fn test_detect_message_type() { + // // standard request + // let message = ClientJsonrpcRequest::new(RequestId::Integer(0), PingRequest::new(None).into()); + // let result = detect_message_type(&json!(message)); + // assert!(matches!(result, MessageTypes::Request)); + + // // custom request + + // let result = detect_message_type(&json!({ + // "id":0, + // "method":"add_numbers", + // "params":{}, + // "jsonrpc":"2.0" + // })); + // assert!(matches!(result, MessageTypes::Request)); + + // // standard notification + // let message = ClientJsonrpcNotification::new(RootsListChangedNotification::new(None).into()); + // let result = detect_message_type(&json!(message)); + // assert!(matches!(result, MessageTypes::Notification)); + + // // custom notification + // let result = detect_message_type(&json!({ + // "method":"notifications/email_sent", + // "jsonrpc":"2.0" + // })); + // assert!(matches!(result, MessageTypes::Notification)); + + // // standard response + // let message = ClientJsonrpcResponse::new( + // RequestId::Integer(0), + // ListRootsResult { + // meta: None, + // roots: vec![], + // } + // .into(), + // ); + // let result = detect_message_type(&json!(message)); + // assert!(matches!(result, MessageTypes::Response)); + + // //custom response + + // let result = detect_message_type(&json!({ + // "id":1, + // "jsonrpc":"2.0", + // "result":"{}", + // })); + // assert!(matches!(result, MessageTypes::Response)); + + // // error message + // let message = JsonrpcErrorResponse::create( + // RequestId::Integer(0), + // RpcErrorCodes::INVALID_PARAMS, + // "Invalid params!".to_string(), + // None, + // ); + // let result = detect_message_type(&json!(message)); + // assert!(matches!(result, MessageTypes::Error)); + + // // default + // let result = detect_message_type(&json!({})); + // assert!(matches!(result, MessageTypes::Request)); + // } +} diff --git a/src/generated_schema/2025_11_25/validators.rs b/src/generated_schema/2025_11_25/validators.rs new file mode 100644 index 0000000..62d4da6 --- /dev/null +++ b/src/generated_schema/2025_11_25/validators.rs @@ -0,0 +1,368 @@ +/// Validates that a deserialized string field matches a given constant value. +/// +/// This function is intended for use with `#[serde(deserialize_with)]` to enforce +/// that a field in a struct always has a fixed, expected string value during deserialization. +/// +/// # Parameters +/// - `struct_name`: The name of the struct where this validation is applied. +/// - `field_name`: The name of the field being validated. +/// - `expected`: The expected constant string value for the field. +/// - `deserializer`: The Serde deserializer for the field. +/// +/// # Returns +/// - `Ok(String)` if the deserialized value matches the expected value. +/// - `Err(D::Error)` if the value differs, with an error message indicating +/// which struct and field failed validation. +/// +pub fn const_str_validator<'de, D>( + struct_name: &'static str, + field_name: &'static str, + expected: &'static str, + deserializer: D, +) -> Result +where + D: serde::de::Deserializer<'de>, +{ + let value: String = serde::Deserialize::deserialize(deserializer)?; + if value == expected { + Ok(value) + } else { + Err(serde::de::Error::custom(format!( + "Expected field `{field_name}` in struct `{struct_name}` as const value '{expected}', but got '{value}'", + ))) + } +} + +/// Validator for `Option` fields: +/// - None → accepted +/// - Some(s) → s must exactly match `expected` +pub fn const_str_option_validator<'de, D>( + struct_name: &'static str, + field_name: &'static str, + expected: &'static str, + deserializer: D, +) -> Result, D::Error> +where + D: serde::de::Deserializer<'de>, +{ + let opt: Option = serde::Deserialize::deserialize(deserializer)?; + match opt { + Some(ref value) if value != expected => { + Err(serde::de::Error::custom(format!( + "Expected field `{field_name}` in struct `{struct_name}` to be None or exactly \"{expected}\", but got Some(\"{value}\")", + ))) + } + Some(value) => Ok(Some(value)), // value == expected + None => Ok(None), + } +} + +fn i64_validator<'de, D>( + struct_name: &'static str, + field_name: &'static str, + expected: i64, + deserializer: D, +) -> Result +where + D: serde::de::Deserializer<'de>, +{ + let value = serde::Deserialize::deserialize(deserializer)?; + if value == expected { + Ok(value) + } else { + Err(serde::de::Error::custom(format!( + "Invalid {struct_name}::{field_name}: expected {expected}, got {value}" + ))) + } +} + +macro_rules! validate { + // === String validation (required) === + ($func_name:ident, $struct:expr, $field:expr, $expected:expr $(,)?) => { + pub(crate) fn $func_name<'de, D>(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + const_str_validator($struct, $field, $expected, deserializer) + } + }; + + // Optional String case (with trailing `, option`) + ($func_name:ident, $struct:expr, $field:expr, $expected:expr, option $(,)?) => { + pub(crate) fn $func_name<'de, D>(deserializer: D) -> Result, D::Error> + where + D: serde::de::Deserializer<'de>, + { + const_str_option_validator($struct, $field, $expected, deserializer) + } + }; + + // === i64 validation (required) === + ($func_name:ident, $struct:expr, $field:expr, $expected:expr, i64 $(,)?) => { + pub(crate) fn $func_name<'de, D>(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + i64_validator($struct, $field, $expected, deserializer) + } + }; +} + +//* Validator Functions *// +validate!(audio_content_type_, "AudioContent", "type_", "audio"); +validate!(boolean_schema_type_, "BooleanSchema", "type_", "boolean"); +validate!(call_tool_request_jsonrpc, "CallToolRequest", "jsonrpc", "2.0"); +validate!(call_tool_request_method, "CallToolRequest", "method", "tools/call"); +validate!(cancel_task_request_jsonrpc, "CancelTaskRequest", "jsonrpc", "2.0"); +validate!(cancel_task_request_method, "CancelTaskRequest", "method", "tasks/cancel"); +validate!(cancelled_notification_jsonrpc, "CancelledNotification", "jsonrpc", "2.0"); +validate!( + cancelled_notification_method, + "CancelledNotification", + "method", + "notifications/cancelled" +); +validate!(complete_request_jsonrpc, "CompleteRequest", "jsonrpc", "2.0"); +validate!(complete_request_method, "CompleteRequest", "method", "completion/complete"); +validate!(create_message_request_jsonrpc, "CreateMessageRequest", "jsonrpc", "2.0"); +validate!( + create_message_request_method, + "CreateMessageRequest", + "method", + "sampling/createMessage" +); +validate!(elicit_form_schema_type_, "ElicitFormSchema", "type_", "object"); +validate!(elicit_request_jsonrpc, "ElicitRequest", "jsonrpc", "2.0"); +validate!(elicit_request_method, "ElicitRequest", "method", "elicitation/create"); +validate!( + elicit_request_form_params_mode, + "ElicitRequestFormParams", + "mode", + "form", + option +); +validate!(elicit_request_url_params_mode, "ElicitRequestUrlParams", "mode", "url"); +validate!( + elicitation_complete_notification_jsonrpc, + "ElicitationCompleteNotification", + "jsonrpc", + "2.0" +); +validate!( + elicitation_complete_notification_method, + "ElicitationCompleteNotification", + "method", + "notifications/elicitation/complete" +); +validate!(embedded_resource_type_, "EmbeddedResource", "type_", "resource"); +validate!(get_prompt_request_jsonrpc, "GetPromptRequest", "jsonrpc", "2.0"); +validate!(get_prompt_request_method, "GetPromptRequest", "method", "prompts/get"); +validate!(get_task_payload_request_jsonrpc, "GetTaskPayloadRequest", "jsonrpc", "2.0"); +validate!( + get_task_payload_request_method, + "GetTaskPayloadRequest", + "method", + "tasks/result" +); +validate!(get_task_request_jsonrpc, "GetTaskRequest", "jsonrpc", "2.0"); +validate!(get_task_request_method, "GetTaskRequest", "method", "tasks/get"); +validate!(image_content_type_, "ImageContent", "type_", "image"); +validate!(initialize_request_jsonrpc, "InitializeRequest", "jsonrpc", "2.0"); +validate!(initialize_request_method, "InitializeRequest", "method", "initialize"); +validate!(initialized_notification_jsonrpc, "InitializedNotification", "jsonrpc", "2.0"); +validate!( + initialized_notification_method, + "InitializedNotification", + "method", + "notifications/initialized" +); +validate!(jsonrpc_error_response_jsonrpc, "JsonrpcErrorResponse", "jsonrpc", "2.0"); +validate!(jsonrpc_notification_jsonrpc, "JsonrpcNotification", "jsonrpc", "2.0"); +validate!(jsonrpc_request_jsonrpc, "JsonrpcRequest", "jsonrpc", "2.0"); +validate!(jsonrpc_result_response_jsonrpc, "JsonrpcResultResponse", "jsonrpc", "2.0"); +validate!(legacy_titled_enum_schema_type_, "LegacyTitledEnumSchema", "type_", "string"); +validate!(list_prompts_request_jsonrpc, "ListPromptsRequest", "jsonrpc", "2.0"); +validate!(list_prompts_request_method, "ListPromptsRequest", "method", "prompts/list"); +validate!( + list_resource_templates_request_jsonrpc, + "ListResourceTemplatesRequest", + "jsonrpc", + "2.0" +); +validate!( + list_resource_templates_request_method, + "ListResourceTemplatesRequest", + "method", + "resources/templates/list" +); +validate!(list_resources_request_jsonrpc, "ListResourcesRequest", "jsonrpc", "2.0"); +validate!( + list_resources_request_method, + "ListResourcesRequest", + "method", + "resources/list" +); +validate!(list_roots_request_jsonrpc, "ListRootsRequest", "jsonrpc", "2.0"); +validate!(list_roots_request_method, "ListRootsRequest", "method", "roots/list"); +validate!(list_tasks_request_jsonrpc, "ListTasksRequest", "jsonrpc", "2.0"); +validate!(list_tasks_request_method, "ListTasksRequest", "method", "tasks/list"); +validate!(list_tools_request_jsonrpc, "ListToolsRequest", "jsonrpc", "2.0"); +validate!(list_tools_request_method, "ListToolsRequest", "method", "tools/list"); +validate!( + logging_message_notification_jsonrpc, + "LoggingMessageNotification", + "jsonrpc", + "2.0" +); +validate!( + logging_message_notification_method, + "LoggingMessageNotification", + "method", + "notifications/message" +); +validate!(paginated_request_jsonrpc, "PaginatedRequest", "jsonrpc", "2.0"); +validate!(ping_request_jsonrpc, "PingRequest", "jsonrpc", "2.0"); +validate!(ping_request_method, "PingRequest", "method", "ping"); +validate!(progress_notification_jsonrpc, "ProgressNotification", "jsonrpc", "2.0"); +validate!( + progress_notification_method, + "ProgressNotification", + "method", + "notifications/progress" +); +validate!( + prompt_list_changed_notification_jsonrpc, + "PromptListChangedNotification", + "jsonrpc", + "2.0" +); +validate!( + prompt_list_changed_notification_method, + "PromptListChangedNotification", + "method", + "notifications/prompts/list_changed" +); +validate!(prompt_reference_type_, "PromptReference", "type_", "ref/prompt"); +validate!(read_resource_request_jsonrpc, "ReadResourceRequest", "jsonrpc", "2.0"); +validate!( + read_resource_request_method, + "ReadResourceRequest", + "method", + "resources/read" +); +validate!(resource_link_type_, "ResourceLink", "type_", "resource_link"); +validate!( + resource_list_changed_notification_jsonrpc, + "ResourceListChangedNotification", + "jsonrpc", + "2.0" +); +validate!( + resource_list_changed_notification_method, + "ResourceListChangedNotification", + "method", + "notifications/resources/list_changed" +); +validate!( + resource_template_reference_type_, + "ResourceTemplateReference", + "type_", + "ref/resource" +); +validate!( + resource_updated_notification_jsonrpc, + "ResourceUpdatedNotification", + "jsonrpc", + "2.0" +); +validate!( + resource_updated_notification_method, + "ResourceUpdatedNotification", + "method", + "notifications/resources/updated" +); +validate!( + roots_list_changed_notification_jsonrpc, + "RootsListChangedNotification", + "jsonrpc", + "2.0" +); +validate!( + roots_list_changed_notification_method, + "RootsListChangedNotification", + "method", + "notifications/roots/list_changed" +); +validate!(set_level_request_jsonrpc, "SetLevelRequest", "jsonrpc", "2.0"); +validate!(set_level_request_method, "SetLevelRequest", "method", "logging/setLevel"); +validate!(string_schema_type_, "StringSchema", "type_", "string"); +validate!(subscribe_request_jsonrpc, "SubscribeRequest", "jsonrpc", "2.0"); +validate!(subscribe_request_method, "SubscribeRequest", "method", "resources/subscribe"); +validate!(task_status_notification_jsonrpc, "TaskStatusNotification", "jsonrpc", "2.0"); +validate!( + task_status_notification_method, + "TaskStatusNotification", + "method", + "notifications/tasks/status" +); +validate!(text_content_type_, "TextContent", "type_", "text"); +validate!( + titled_multi_select_enum_schema_type_, + "TitledMultiSelectEnumSchema", + "type_", + "array" +); +validate!( + titled_single_select_enum_schema_type_, + "TitledSingleSelectEnumSchema", + "type_", + "string" +); +validate!(tool_input_schema_type_, "ToolInputSchema", "type_", "object"); +validate!( + tool_list_changed_notification_jsonrpc, + "ToolListChangedNotification", + "jsonrpc", + "2.0" +); +validate!( + tool_list_changed_notification_method, + "ToolListChangedNotification", + "method", + "notifications/tools/list_changed" +); +validate!(tool_output_schema_type_, "ToolOutputSchema", "type_", "object"); +validate!(tool_result_content_type_, "ToolResultContent", "type_", "tool_result"); +validate!(tool_use_content_type_, "ToolUseContent", "type_", "tool_use"); +validate!(unsubscribe_request_jsonrpc, "UnsubscribeRequest", "jsonrpc", "2.0"); +validate!( + unsubscribe_request_method, + "UnsubscribeRequest", + "method", + "resources/unsubscribe" +); +validate!( + untitled_multi_select_enum_schema_type_, + "UntitledMultiSelectEnumSchema", + "type_", + "array" +); +validate!( + untitled_multi_select_enum_schema_items_type_, + "UntitledMultiSelectEnumSchemaItems", + "type_", + "string" +); +validate!( + untitled_single_select_enum_schema_type_, + "UntitledSingleSelectEnumSchema", + "type_", + "string" +); +validate!(url_elicit_error_code, "UrlElicitError", "code", -32042i64, i64); +validate!( + url_elicitation_required_error_jsonrpc, + "UrlElicitationRequiredError", + "jsonrpc", + "2.0" +); diff --git a/src/generated_schema/draft/mcp_schema.rs b/src/generated_schema/draft/mcp_schema.rs index 4c9206d..88ce39c 100644 --- a/src/generated_schema/draft/mcp_schema.rs +++ b/src/generated_schema/draft/mcp_schema.rs @@ -1,12 +1,15 @@ +/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) +/// Licensed under the MIT License. See LICENSE in the project root. +/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- -/// This file is auto-generated by mcp-schema-gen v0.4.4. +/// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: /// It is not recommended to modify this file directly. You are free to /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : 71204c22f8e062795dca00a87d31070033572ba2 -/// Generated at : 2025-10-03 15:17:04 +/// Hash : UNKNOWN +/// Generated at : 2025-12-01 14:17:35 /// ---------------------------------------------------------------------------- /// use super::validators as validate; @@ -24,6 +27,8 @@ pub const METHOD_NOT_FOUND: i64 = -32601i64; pub const INVALID_PARAMS: i64 = -32602i64; /// Internal error. Internal JSON-RPC error. pub const INTERNAL_ERROR: i64 = -32603i64; +/// The server cannot proceed without additional client input. +pub const URL_ELICITATION_REQUIRED: i64 = -32042i64; ///Optional annotations for the client. The client can use annotations to inform how objects are used or displayed /// ///
JSON schema @@ -34,10 +39,10 @@ pub const INTERNAL_ERROR: i64 = -32603i64; /// "type": "object", /// "properties": { /// "audience": { -/// "description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., [\"user\", \"assistant\"]).", +/// "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\"]).", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Role" +/// "$ref": "#/$defs/Role" /// } /// }, /// "lastModified": { @@ -56,7 +61,7 @@ pub const INTERNAL_ERROR: i64 = -32603i64; ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct Annotations { - /**Describes who the intended customer of this object or data is. + /**Describes who the intended audience of this object or data is. It can include multiple entries to indicate content useful for multiple audiences (e.g., ["user", "assistant"]).*/ #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] pub audience: ::std::vec::Vec, @@ -84,13 +89,13 @@ pub struct Annotations { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "annotations": { /// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" +/// "$ref": "#/$defs/Annotations" /// }, /// "data": { /// "description": "The base64-encoded audio data.", @@ -116,7 +121,7 @@ pub struct AudioContent { pub annotations: ::std::option::Option, ///The base64-encoded audio data. pub data: ::std::string::String, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of the audio. Different providers may support different audio types. @@ -143,6 +148,11 @@ impl AudioContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "audio" + pub fn type_value() -> ::std::string::String { + "audio".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "audio".to_string() } @@ -196,7 +206,7 @@ pub struct BaseMetadata { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -222,7 +232,7 @@ pub struct BaseMetadata { pub struct BlobResourceContents { ///A base64-encoded string representing the binary data of the item. pub blob: ::std::string::String, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -286,10 +296,41 @@ impl BooleanSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "boolean" + pub fn type_value() -> ::std::string::String { + "boolean".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "boolean".to_string() } } +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CallToolMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} ///Used by the client to invoke a tool provided by the server. /// ///
JSON schema @@ -306,7 +347,7 @@ impl BooleanSchema { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -317,19 +358,7 @@ impl BooleanSchema { /// "const": "tools/call" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "name" -/// ], -/// "properties": { -/// "arguments": { -/// "type": "object", -/// "additionalProperties": {} -/// }, -/// "name": { -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/CallToolRequestParams" /// } /// } ///} @@ -359,27 +388,50 @@ impl CallToolRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tools/call" + pub fn method_value() -> ::std::string::String { + "tools/call".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "tools/call".to_string() } } -///CallToolRequestParams +///Parameters for a tools/call request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a tools/call request.", /// "type": "object", /// "required": [ /// "name" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "arguments": { +/// "description": "Arguments to use for the tool call.", /// "type": "object", /// "additionalProperties": {} /// }, /// "name": { +/// "description": "The name of the tool.", /// "type": "string" +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" /// } /// } ///} @@ -387,9 +439,20 @@ impl CallToolRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CallToolRequestParams { + ///Arguments to use for the tool call. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub arguments: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The name of the tool. pub name: ::std::string::String, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, } ///The server's response to a tool call. /// @@ -404,7 +467,7 @@ pub struct CallToolRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -412,7 +475,7 @@ pub struct CallToolRequestParams { /// "description": "A list of content objects that represent the unstructured result of the tool call.", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/ContentBlock" +/// "$ref": "#/$defs/ContentBlock" /// } /// }, /// "isError": { @@ -443,7 +506,7 @@ pub struct CallToolResult { should be reported as an MCP error response.*/ #[serde(rename = "isError", default, skip_serializing_if = "::std::option::Option::is_none")] pub is_error: ::std::option::Option, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///An optional JSON object that represents the structured result of the tool call. @@ -454,44 +517,66 @@ pub struct CallToolResult { )] pub structured_content: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -/**This notification can be sent by either side to indicate that it is cancelling a previously-issued request. -The 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. -This notification indicates that the result will be unused, so any associated processing SHOULD cease. -A client MUST NOT attempt to cancel its initialize request.*/ +///CancelTaskParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to cancel.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelTaskParams { + ///The task identifier to cancel. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///A request to cancel a task. /// ///
JSON schema /// /// ```json ///{ -/// "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.", +/// "description": "A request to cancel a task.", /// "type": "object", /// "required": [ +/// "id", /// "jsonrpc", /// "method", /// "params" /// ], /// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, /// "jsonrpc": { /// "type": "string", /// "const": "2.0" /// }, /// "method": { /// "type": "string", -/// "const": "notifications/cancelled" +/// "const": "tasks/cancel" /// }, /// "params": { /// "type": "object", /// "required": [ -/// "requestId" +/// "taskId" /// ], /// "properties": { -/// "reason": { -/// "description": "An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.", +/// "taskId": { +/// "description": "The task identifier to cancel.", /// "type": "string" -/// }, -/// "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.", -/// "$ref": "#/definitions/RequestId" /// } /// } /// } @@ -500,6 +585,110 @@ A client MUST NOT attempt to cancel its initialize request.*/ /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelTaskRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::cancel_task_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::cancel_task_request_method")] + method: ::std::string::String, + pub params: CancelTaskParams, +} +impl CancelTaskRequest { + pub fn new(id: RequestId, params: CancelTaskParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/cancel".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/cancel" + pub fn method_value() -> ::std::string::String { + "tasks/cancel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/cancel".to_string() + } +} +///The response to a tasks/cancel request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The response to a tasks/cancel request.", +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "$ref": "#/$defs/Task" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CancelTaskResult { + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + pub ttl: i64, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**This notification can be sent by either side to indicate that it is cancelling a previously-issued request. +The 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. +This notification indicates that the result will be unused, so any associated processing SHOULD cease. +A client MUST NOT attempt to cancel its initialize request. +For task cancellation, use the tasks/cancel request instead of this notification.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/cancelled" +/// }, +/// "params": { +/// "$ref": "#/$defs/CancelledNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CancelledNotification { #[serde(deserialize_with = "validate::cancelled_notification_jsonrpc")] jsonrpc: ::std::string::String, @@ -521,42 +710,55 @@ impl CancelledNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/cancelled" + pub fn method_value() -> ::std::string::String { + "notifications/cancelled".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/cancelled".to_string() } } -///CancelledNotificationParams +///Parameters for a notifications/cancelled notification. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a notifications/cancelled notification.", /// "type": "object", -/// "required": [ -/// "requestId" -/// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, /// "reason": { /// "description": "An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.", /// "type": "string" /// }, /// "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.", -/// "$ref": "#/definitions/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).", +/// "$ref": "#/$defs/RequestId" /// } /// } ///} /// ``` ///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct CancelledNotificationParams { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub reason: ::std::option::Option<::std::string::String>, /**The ID of the request to cancel. - This MUST correspond to the ID of a request previously issued in the same direction.*/ - #[serde(rename = "requestId")] - pub request_id: RequestId, + This MUST correspond to the ID of a request previously issued in the same direction. + This MUST be provided for cancelling non-task requests. + This MUST NOT be used for cancelling tasks (use the tasks/cancel request instead).*/ + #[serde(rename = "requestId", default, skip_serializing_if = "::std::option::Option::is_none")] + pub request_id: ::std::option::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. /// @@ -570,7 +772,16 @@ pub struct CancelledNotificationParams { /// "elicitation": { /// "description": "Present if the client supports elicitation from the server.", /// "type": "object", -/// "additionalProperties": true +/// "properties": { +/// "form": { +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "url": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// } /// }, /// "experimental": { /// "description": "Experimental, non-standard capabilities that the client supports.", @@ -593,7 +804,62 @@ pub struct CancelledNotificationParams { /// "sampling": { /// "description": "Present if the client supports sampling from an LLM.", /// "type": "object", -/// "additionalProperties": true +/// "properties": { +/// "context": { +/// "description": "Whether the client supports context inclusion via includeContext parameter.\nIf not declared, servers SHOULD only use includeContext: \"none\" (or omit it).", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "tools": { +/// "description": "Whether the client supports tool use via tools and toolChoice parameters.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "tasks": { +/// "description": "Present if the client supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this client supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this client supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "elicitation": { +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// }, +/// "sampling": { +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } /// } /// } ///} @@ -601,42 +867,47 @@ pub struct CancelledNotificationParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct ClientCapabilities { - ///Present if the client supports elicitation from the server. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub elicitation: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub elicitation: ::std::option::Option, ///Experimental, non-standard capabilities that the client supports. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub experimental: ::std::option::Option< ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, >, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub roots: ::std::option::Option, - ///Present if the client supports sampling from an LLM. + pub roots: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sampling: ::std::option::Option, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub sampling: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub tasks: ::std::option::Option, } -///Present if the client supports listing roots. +///Present if the client supports elicitation from the server. /// ///
JSON schema /// /// ```json ///{ -/// "description": "Present if the client supports listing roots.", +/// "description": "Present if the client supports elicitation from the server.", /// "type": "object", /// "properties": { -/// "listChanged": { -/// "description": "Whether the client supports notifications for changes to the roots list.", -/// "type": "boolean" +/// "form": { +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "url": { +/// "type": "object", +/// "additionalProperties": true /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ClientCapabilitiesRoots { - ///Whether the client supports notifications for changes to the roots list. - #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] - pub list_changed: ::std::option::Option, +pub struct ClientElicitation { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub form: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } ///ClientNotification /// @@ -646,16 +917,19 @@ pub struct ClientCapabilitiesRoots { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/CancelledNotification" +/// "$ref": "#/$defs/CancelledNotification" +/// }, +/// { +/// "$ref": "#/$defs/InitializedNotification" /// }, /// { -/// "$ref": "#/definitions/InitializedNotification" +/// "$ref": "#/$defs/ProgressNotification" /// }, /// { -/// "$ref": "#/definitions/ProgressNotification" +/// "$ref": "#/$defs/TaskStatusNotification" /// }, /// { -/// "$ref": "#/definitions/RootsListChangedNotification" +/// "$ref": "#/$defs/RootsListChangedNotification" /// } /// ] ///} @@ -667,6 +941,7 @@ pub enum ClientNotification { CancelledNotification(CancelledNotification), InitializedNotification(InitializedNotification), ProgressNotification(ProgressNotification), + TaskStatusNotification(TaskStatusNotification), RootsListChangedNotification(RootsListChangedNotification), } impl ::std::convert::From for ClientNotification { @@ -684,6 +959,11 @@ impl ::std::convert::From for ClientNotification { Self::ProgressNotification(value) } } +impl ::std::convert::From for ClientNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::TaskStatusNotification(value) + } +} impl ::std::convert::From for ClientNotification { fn from(value: RootsListChangedNotification) -> Self { Self::RootsListChangedNotification(value) @@ -697,43 +977,55 @@ impl ::std::convert::From for ClientNotification { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/InitializeRequest" +/// "$ref": "#/$defs/InitializeRequest" +/// }, +/// { +/// "$ref": "#/$defs/PingRequest" +/// }, +/// { +/// "$ref": "#/$defs/ListResourcesRequest" +/// }, +/// { +/// "$ref": "#/$defs/ListResourceTemplatesRequest" +/// }, +/// { +/// "$ref": "#/$defs/ReadResourceRequest" /// }, /// { -/// "$ref": "#/definitions/PingRequest" +/// "$ref": "#/$defs/SubscribeRequest" /// }, /// { -/// "$ref": "#/definitions/ListResourcesRequest" +/// "$ref": "#/$defs/UnsubscribeRequest" /// }, /// { -/// "$ref": "#/definitions/ListResourceTemplatesRequest" +/// "$ref": "#/$defs/ListPromptsRequest" /// }, /// { -/// "$ref": "#/definitions/ReadResourceRequest" +/// "$ref": "#/$defs/GetPromptRequest" /// }, /// { -/// "$ref": "#/definitions/SubscribeRequest" +/// "$ref": "#/$defs/ListToolsRequest" /// }, /// { -/// "$ref": "#/definitions/UnsubscribeRequest" +/// "$ref": "#/$defs/CallToolRequest" /// }, /// { -/// "$ref": "#/definitions/ListPromptsRequest" +/// "$ref": "#/$defs/GetTaskRequest" /// }, /// { -/// "$ref": "#/definitions/GetPromptRequest" +/// "$ref": "#/$defs/GetTaskPayloadRequest" /// }, /// { -/// "$ref": "#/definitions/ListToolsRequest" +/// "$ref": "#/$defs/CancelTaskRequest" /// }, /// { -/// "$ref": "#/definitions/CallToolRequest" +/// "$ref": "#/$defs/ListTasksRequest" /// }, /// { -/// "$ref": "#/definitions/SetLevelRequest" +/// "$ref": "#/$defs/SetLevelRequest" /// }, /// { -/// "$ref": "#/definitions/CompleteRequest" +/// "$ref": "#/$defs/CompleteRequest" /// } /// ] ///} @@ -753,6 +1045,10 @@ pub enum ClientRequest { GetPromptRequest(GetPromptRequest), ListToolsRequest(ListToolsRequest), CallToolRequest(CallToolRequest), + GetTaskRequest(GetTaskRequest), + GetTaskPayloadRequest(GetTaskPayloadRequest), + CancelTaskRequest(CancelTaskRequest), + ListTasksRequest(ListTasksRequest), SetLevelRequest(SetLevelRequest), CompleteRequest(CompleteRequest), } @@ -811,6 +1107,26 @@ impl ::std::convert::From for ClientRequest { Self::CallToolRequest(value) } } +impl ::std::convert::From for ClientRequest { + fn from(value: GetTaskRequest) -> Self { + Self::GetTaskRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::GetTaskPayloadRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: CancelTaskRequest) -> Self { + Self::CancelTaskRequest(value) + } +} +impl ::std::convert::From for ClientRequest { + fn from(value: ListTasksRequest) -> Self { + Self::ListTasksRequest(value) + } +} impl ::std::convert::From for ClientRequest { fn from(value: SetLevelRequest) -> Self { Self::SetLevelRequest(value) @@ -829,16 +1145,30 @@ impl ::std::convert::From for ClientRequest { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/Result" +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "description": "The response to a tasks/get request.", +/// "$ref": "#/$defs/GetTaskResult" +/// }, +/// { +/// "$ref": "#/$defs/GetTaskPayloadResult" +/// }, +/// { +/// "description": "The response to a tasks/cancel request.", +/// "$ref": "#/$defs/CancelTaskResult" +/// }, +/// { +/// "$ref": "#/$defs/ListTasksResult" /// }, /// { -/// "$ref": "#/definitions/CreateMessageResult" +/// "$ref": "#/$defs/CreateMessageResult" /// }, /// { -/// "$ref": "#/definitions/ListRootsResult" +/// "$ref": "#/$defs/ListRootsResult" /// }, /// { -/// "$ref": "#/definitions/ElicitResult" +/// "$ref": "#/$defs/ElicitResult" /// } /// ] ///} @@ -847,11 +1177,35 @@ impl ::std::convert::From for ClientRequest { #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] #[serde(untagged)] pub enum ClientResult { + GetTaskResult(GetTaskResult), + GetTaskPayloadResult(GetTaskPayloadResult), + CancelTaskResult(CancelTaskResult), + ListTasksResult(ListTasksResult), CreateMessageResult(CreateMessageResult), ListRootsResult(ListRootsResult), ElicitResult(ElicitResult), Result(Result), } +impl ::std::convert::From for ClientResult { + fn from(value: GetTaskResult) -> Self { + Self::GetTaskResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: GetTaskPayloadResult) -> Self { + Self::GetTaskPayloadResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: CancelTaskResult) -> Self { + Self::CancelTaskResult(value) + } +} +impl ::std::convert::From for ClientResult { + fn from(value: ListTasksResult) -> Self { + Self::ListTasksResult(value) + } +} impl ::std::convert::From for ClientResult { fn from(value: CreateMessageResult) -> Self { Self::CreateMessageResult(value) @@ -872,79 +1226,196 @@ impl ::std::convert::From for ClientResult { Self::Result(value) } } -///A request from the client to the server, to ask for completion options. +///Present if the client supports listing roots. /// ///
JSON schema /// /// ```json ///{ -/// "description": "A request from the client to the server, to ask for completion options.", +/// "description": "Present if the client supports listing roots.", /// "type": "object", -/// "required": [ -/// "id", -/// "jsonrpc", -/// "method", -/// "params" -/// ], /// "properties": { -/// "id": { -/// "$ref": "#/definitions/RequestId" +/// "listChanged": { +/// "description": "Whether the client supports notifications for changes to the roots list.", +/// "type": "boolean" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientRoots { + ///Whether the client supports notifications for changes to the roots list. + #[serde(rename = "listChanged", default, skip_serializing_if = "::std::option::Option::is_none")] + pub list_changed: ::std::option::Option, +} +///Present if the client supports sampling from an LLM. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports sampling from an LLM.", +/// "type": "object", +/// "properties": { +/// "context": { +/// "description": "Whether the client supports context inclusion via includeContext parameter.\nIf not declared, servers SHOULD only use includeContext: \"none\" (or omit it).", +/// "type": "object", +/// "additionalProperties": true /// }, -/// "jsonrpc": { -/// "type": "string", -/// "const": "2.0" +/// "tools": { +/// "description": "Whether the client supports tool use via tools and toolChoice parameters.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientSampling { + /**Whether the client supports context inclusion via includeContext parameter. + If not declared, servers SHOULD only use includeContext: "none" (or omit it).*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub context: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Whether the client supports tool use via tools and toolChoice parameters. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tools: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Task support for elicitation-related requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTaskElicitation { + ///Whether the client supports task-augmented elicitation/create requests. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub create: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Specifies which request types can be augmented with tasks. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "elicitation": { +/// "description": "Task support for elicitation-related requests.", +/// "type": "object", +/// "properties": { +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } /// }, -/// "method": { -/// "type": "string", -/// "const": "completion/complete" +/// "sampling": { +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTaskRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub elicitation: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sampling: ::std::option::Option, +} +///Task support for sampling-related requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Task support for sampling-related requests.", +/// "type": "object", +/// "properties": { +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTaskSampling { + ///Whether the client supports task-augmented sampling/createMessage requests. + #[serde(rename = "createMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub create_message: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Present if the client supports task-augmented requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the client supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this client supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true /// }, -/// "params": { +/// "list": { +/// "description": "Whether this client supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", /// "type": "object", -/// "required": [ -/// "argument", -/// "ref" -/// ], /// "properties": { -/// "argument": { -/// "description": "The argument's information", +/// "elicitation": { +/// "description": "Task support for elicitation-related requests.", /// "type": "object", -/// "required": [ -/// "name", -/// "value" -/// ], /// "properties": { -/// "name": { -/// "description": "The name of the argument", -/// "type": "string" -/// }, -/// "value": { -/// "description": "The value of the argument to use for completion matching.", -/// "type": "string" +/// "create": { +/// "description": "Whether the client supports task-augmented elicitation/create requests.", +/// "type": "object", +/// "additionalProperties": true /// } /// } /// }, -/// "context": { -/// "description": "Additional, optional context for completions", +/// "sampling": { +/// "description": "Task support for sampling-related requests.", /// "type": "object", /// "properties": { -/// "arguments": { -/// "description": "Previously-resolved variables in a URI template or prompt.", +/// "createMessage": { +/// "description": "Whether the client supports task-augmented sampling/createMessage requests.", /// "type": "object", -/// "additionalProperties": { -/// "type": "string" -/// } +/// "additionalProperties": true /// } /// } -/// }, -/// "ref": { -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/PromptReference" -/// }, -/// { -/// "$ref": "#/definitions/ResourceTemplateReference" -/// } -/// ] /// } /// } /// } @@ -952,6 +1423,50 @@ impl ::std::convert::From for ClientResult { ///} /// ``` ///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ClientTasks { + ///Whether this client supports tasks/cancel. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cancel: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Whether this client supports tasks/list. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub list: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub requests: ::std::option::Option, +} +///A request from the client to the server, to ask for completion options. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request from the client to the server, to ask for completion options.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "completion/complete" +/// }, +/// "params": { +/// "$ref": "#/$defs/CompleteRequestParams" +/// } +/// } +///} +/// ``` +///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CompleteRequest { pub id: RequestId, @@ -976,75 +1491,15 @@ impl CompleteRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "completion/complete" + pub fn method_value() -> ::std::string::String { + "completion/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "completion/complete".to_string() } } -///CompleteRequestParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "required": [ -/// "argument", -/// "ref" -/// ], -/// "properties": { -/// "argument": { -/// "description": "The argument's information", -/// "type": "object", -/// "required": [ -/// "name", -/// "value" -/// ], -/// "properties": { -/// "name": { -/// "description": "The name of the argument", -/// "type": "string" -/// }, -/// "value": { -/// "description": "The value of the argument to use for completion matching.", -/// "type": "string" -/// } -/// } -/// }, -/// "context": { -/// "description": "Additional, optional context for completions", -/// "type": "object", -/// "properties": { -/// "arguments": { -/// "description": "Previously-resolved variables in a URI template or prompt.", -/// "type": "object", -/// "additionalProperties": { -/// "type": "string" -/// } -/// } -/// } -/// }, -/// "ref": { -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/PromptReference" -/// }, -/// { -/// "$ref": "#/definitions/ResourceTemplateReference" -/// } -/// ] -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct CompleteRequestParams { - pub argument: CompleteRequestParamsArgument, - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub context: ::std::option::Option, - #[serde(rename = "ref")] - pub ref_: CompleteRequestParamsRef, -} ///The argument's information /// ///
JSON schema @@ -1071,7 +1526,7 @@ pub struct CompleteRequestParams { /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct CompleteRequestParamsArgument { +pub struct CompleteRequestArgument { ///The name of the argument pub name: ::std::string::String, ///The value of the argument to use for completion matching. @@ -1098,40 +1553,145 @@ pub struct CompleteRequestParamsArgument { /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct CompleteRequestParamsContext { +pub struct CompleteRequestContext { ///Previously-resolved variables in a URI template or prompt. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub arguments: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>, } -///CompleteRequestParamsRef +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/PromptReference" -/// }, -/// { -/// "$ref": "#/definitions/ResourceTemplateReference" +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" /// } -/// ] +/// }, +/// "additionalProperties": {} ///} /// ``` ///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum CompleteRequestParamsRef { - PromptReference(PromptReference), - ResourceTemplateReference(ResourceTemplateReference), +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct CompleteRequestMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -impl ::std::convert::From for CompleteRequestParamsRef { - fn from(value: PromptReference) -> Self { - Self::PromptReference(value) - } +///Parameters for a completion/complete request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a completion/complete request.", +/// "type": "object", +/// "required": [ +/// "argument", +/// "ref" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "argument": { +/// "description": "The argument's information", +/// "type": "object", +/// "required": [ +/// "name", +/// "value" +/// ], +/// "properties": { +/// "name": { +/// "description": "The name of the argument", +/// "type": "string" +/// }, +/// "value": { +/// "description": "The value of the argument to use for completion matching.", +/// "type": "string" +/// } +/// } +/// }, +/// "context": { +/// "description": "Additional, optional context for completions", +/// "type": "object", +/// "properties": { +/// "arguments": { +/// "description": "Previously-resolved variables in a URI template or prompt.", +/// "type": "object", +/// "additionalProperties": { +/// "type": "string" +/// } +/// } +/// } +/// }, +/// "ref": { +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/PromptReference" +/// }, +/// { +/// "$ref": "#/$defs/ResourceTemplateReference" +/// } +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct CompleteRequestParams { + pub argument: CompleteRequestArgument, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub context: ::std::option::Option, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + #[serde(rename = "ref")] + pub ref_: CompleteRequestRef, +} +///CompleteRequestRef +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/PromptReference" +/// }, +/// { +/// "$ref": "#/$defs/ResourceTemplateReference" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum CompleteRequestRef { + PromptReference(PromptReference), + ResourceTemplateReference(ResourceTemplateReference), +} +impl ::std::convert::From for CompleteRequestRef { + fn from(value: PromptReference) -> Self { + Self::PromptReference(value) + } } -impl ::std::convert::From for CompleteRequestParamsRef { +impl ::std::convert::From for CompleteRequestRef { fn from(value: ResourceTemplateReference) -> Self { Self::ResourceTemplateReference(value) } @@ -1149,7 +1709,7 @@ impl ::std::convert::From for CompleteRequestParamsRe /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -1183,7 +1743,7 @@ impl ::std::convert::From for CompleteRequestParamsRe #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CompleteResult { pub completion: CompleteResultCompletion, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } @@ -1236,19 +1796,19 @@ pub struct CompleteResultCompletion { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextContent" +/// "$ref": "#/$defs/TextContent" /// }, /// { -/// "$ref": "#/definitions/ImageContent" +/// "$ref": "#/$defs/ImageContent" /// }, /// { -/// "$ref": "#/definitions/AudioContent" +/// "$ref": "#/$defs/AudioContent" /// }, /// { -/// "$ref": "#/definitions/ResourceLink" +/// "$ref": "#/$defs/ResourceLink" /// }, /// { -/// "$ref": "#/definitions/EmbeddedResource" +/// "$ref": "#/$defs/EmbeddedResource" /// } /// ] ///} @@ -1288,6 +1848,78 @@ impl ::std::convert::From for ContentBlock { Self::EmbeddedResource(value) } } +///CreateMessageContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// }, +/// { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum CreateMessageContent { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), + SamplingMessageContentBlock(::std::vec::Vec), +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ToolUseContent) -> Self { + Self::ToolUseContent(value) + } +} +impl ::std::convert::From for CreateMessageContent { + fn from(value: ToolResultContent) -> Self { + Self::ToolResultContent(value) + } +} +impl ::std::convert::From<::std::vec::Vec> for CreateMessageContent { + fn from(value: ::std::vec::Vec) -> Self { + Self::SamplingMessageContentBlock(value) + } +} ///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. /// ///
JSON schema @@ -1304,7 +1936,7 @@ impl ::std::convert::From for ContentBlock { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -1315,54 +1947,7 @@ impl ::std::convert::From for ContentBlock { /// "const": "sampling/createMessage" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "maxTokens", -/// "messages" -/// ], -/// "properties": { -/// "includeContext": { -/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", -/// "type": "string", -/// "enum": [ -/// "allServers", -/// "none", -/// "thisServer" -/// ] -/// }, -/// "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": { -/// "type": "array", -/// "items": { -/// "$ref": "#/definitions/SamplingMessage" -/// } -/// }, -/// "metadata": { -/// "description": "Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.", -/// "type": "object", -/// "additionalProperties": true -/// }, -/// "modelPreferences": { -/// "description": "The server's preferences for which model to select. The client MAY ignore these preferences.", -/// "$ref": "#/definitions/ModelPreferences" -/// }, -/// "stopSequences": { -/// "type": "array", -/// "items": { -/// "type": "string" -/// } -/// }, -/// "systemPrompt": { -/// "description": "An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.", -/// "type": "string" -/// }, -/// "temperature": { -/// "type": "number" -/// } -/// } +/// "$ref": "#/$defs/CreateMessageRequestParams" /// } /// } ///} @@ -1392,24 +1977,41 @@ impl CreateMessageRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "sampling/createMessage" + pub fn method_value() -> ::std::string::String { + "sampling/createMessage".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "sampling/createMessage".to_string() } } -///CreateMessageRequestParams +///Parameters for a sampling/createMessage request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a sampling/createMessage request.", /// "type": "object", /// "required": [ /// "maxTokens", /// "messages" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "includeContext": { -/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", +/// "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.", /// "type": "string", /// "enum": [ /// "allServers", @@ -1424,7 +2026,7 @@ impl CreateMessageRequest { /// "messages": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/SamplingMessage" +/// "$ref": "#/$defs/SamplingMessage" /// } /// }, /// "metadata": { @@ -1434,7 +2036,7 @@ impl CreateMessageRequest { /// }, /// "modelPreferences": { /// "description": "The server's preferences for which model to select. The client MAY ignore these preferences.", -/// "$ref": "#/definitions/ModelPreferences" +/// "$ref": "#/$defs/ModelPreferences" /// }, /// "stopSequences": { /// "type": "array", @@ -1446,8 +2048,23 @@ impl CreateMessageRequest { /// "description": "An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.", /// "type": "string" /// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// }, /// "temperature": { /// "type": "number" +/// }, +/// "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\" }.", +/// "$ref": "#/$defs/ToolChoice" +/// }, +/// "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.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Tool" +/// } /// } /// } ///} @@ -1455,14 +2072,19 @@ impl CreateMessageRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CreateMessageRequestParams { - ///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. + /**A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. + The client MAY ignore this request. + Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client + declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.*/ #[serde(rename = "includeContext", default, skip_serializing_if = "::std::option::Option::is_none")] - pub include_context: ::std::option::Option, + pub include_context: ::std::option::Option, /**The requested maximum number of tokens to sample (to prevent runaway completions). The client MAY choose to sample fewer tokens than the requested maximum.*/ #[serde(rename = "maxTokens")] pub max_tokens: i64, pub messages: ::std::vec::Vec, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, ///Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub metadata: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, @@ -1478,50 +2100,34 @@ pub struct CreateMessageRequestParams { ///An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. #[serde(rename = "systemPrompt", default, skip_serializing_if = "::std::option::Option::is_none")] pub system_prompt: ::std::option::Option<::std::string::String>, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub temperature: ::std::option::Option, + /**Controls how the model uses tools. + The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. + Default is { mode: "auto" }.*/ + #[serde(rename = "toolChoice", default, skip_serializing_if = "::std::option::Option::is_none")] + pub tool_choice: ::std::option::Option, + /**Tools that the model may use during generation. + The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.*/ + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub tools: ::std::vec::Vec, } -///A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.", -/// "type": "string", -/// "enum": [ -/// "allServers", -/// "none", -/// "thisServer" -/// ] -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub enum CreateMessageRequestParamsIncludeContext { - #[serde(rename = "allServers")] - AllServers, - #[serde(rename = "none")] - None, - #[serde(rename = "thisServer")] - ThisServer, -} -impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match *self { - Self::AllServers => write!(f, "allServers"), - Self::None => write!(f, "none"), - Self::ThisServer => write!(f, "thisServer"), - } - } -} -///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.*/ /// ///
JSON schema /// /// ```json ///{ -/// "description": "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.", +/// "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.", /// "type": "object", /// "required": [ /// "content", @@ -1530,20 +2136,32 @@ impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "content": { /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextContent" +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" /// }, /// { -/// "$ref": "#/definitions/ImageContent" +/// "$ref": "#/$defs/ToolResultContent" /// }, /// { -/// "$ref": "#/definitions/AudioContent" +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } /// } /// ] /// }, @@ -1552,10 +2170,10 @@ impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { /// "type": "string" /// }, /// "role": { -/// "$ref": "#/definitions/Role" +/// "$ref": "#/$defs/Role" /// }, /// "stopReason": { -/// "description": "The reason why sampling stopped, if known.", +/// "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" /// } /// } @@ -1564,58 +2182,53 @@ impl ::std::fmt::Display for CreateMessageRequestParamsIncludeContext { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct CreateMessageResult { - pub content: CreateMessageResultContent, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + pub content: CreateMessageContent, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The name of the model that generated the message. pub model: ::std::string::String, pub role: Role, - ///The reason why sampling stopped, if known. + /**The reason why sampling stopped, if known. + Standard values: + - "endTurn": Natural end of the assistant's turn + - "stopSequence": A stop sequence was encountered + - "maxTokens": Maximum token limit was reached + - "toolUse": The model wants to use one or more tools + This field is an open string to allow for provider-specific stop reasons.*/ #[serde(rename = "stopReason", default, skip_serializing_if = "::std::option::Option::is_none")] pub stop_reason: ::std::option::Option<::std::string::String>, } -///CreateMessageResultContent +///A response to a task-augmented request. /// ///
JSON schema /// /// ```json ///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextContent" -/// }, -/// { -/// "$ref": "#/definitions/ImageContent" +/// "description": "A response to a task-augmented request.", +/// "type": "object", +/// "required": [ +/// "task" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} /// }, -/// { -/// "$ref": "#/definitions/AudioContent" +/// "task": { +/// "$ref": "#/$defs/Task" /// } -/// ] +/// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum CreateMessageResultContent { - TextContent(TextContent), - ImageContent(ImageContent), - AudioContent(AudioContent), -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: TextContent) -> Self { - Self::TextContent(value) - } -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: ImageContent) -> Self { - Self::ImageContent(value) - } -} -impl ::std::convert::From for CreateMessageResultContent { - fn from(value: AudioContent) -> Self { - Self::AudioContent(value) - } +pub struct CreateTaskResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + pub task: Task, } ///An opaque token used to represent a cursor for pagination. /// @@ -1631,6 +2244,129 @@ impl ::std::convert::From for CreateMessageResultContent { #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct Cursor(pub ::std::string::String); +///ElicitCompleteParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "elicitationId" +/// ], +/// "properties": { +/// "elicitationId": { +/// "description": "The ID of the elicitation that completed.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitCompleteParams { + ///The ID of the elicitation that completed. + #[serde(rename = "elicitationId")] + pub elicitation_id: ::std::string::String, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ElicitFormMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +/**A restricted subset of JSON Schema. +Only top-level properties are allowed, without nesting.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", +/// "type": "object", +/// "required": [ +/// "properties", +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "$ref": "#/$defs/PrimitiveSchemaDefinition" +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitFormSchema { + pub properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub required: ::std::vec::Vec<::std::string::String>, + #[serde(rename = "$schema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub schema: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::elicit_form_schema_type_")] + type_: ::std::string::String, +} +impl ElicitFormSchema { + pub fn new( + properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>, + required: ::std::vec::Vec<::std::string::String>, + schema: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + properties, + required, + schema, + type_: "object".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "object".to_string() + } +} ///A request from the server to elicit additional information from the user via the client. /// ///
JSON schema @@ -1647,7 +2383,7 @@ pub struct Cursor(pub ::std::string::String); /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -1658,43 +2394,7 @@ pub struct Cursor(pub ::std::string::String); /// "const": "elicitation/create" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "message", -/// "requestedSchema" -/// ], -/// "properties": { -/// "message": { -/// "description": "The message to present to the user.", -/// "type": "string" -/// }, -/// "requestedSchema": { -/// "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", -/// "type": "object", -/// "required": [ -/// "properties", -/// "type" -/// ], -/// "properties": { -/// "properties": { -/// "type": "object", -/// "additionalProperties": { -/// "$ref": "#/definitions/PrimitiveSchemaDefinition" -/// } -/// }, -/// "required": { -/// "type": "array", -/// "items": { -/// "type": "string" -/// } -/// }, -/// "type": { -/// "type": "string", -/// "const": "object" -/// } -/// } -/// } -/// } +/// "$ref": "#/$defs/ElicitRequestParams" /// } /// } ///} @@ -1724,26 +2424,48 @@ impl ElicitRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "elicitation/create" + pub fn method_value() -> ::std::string::String { + "elicitation/create".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "elicitation/create".to_string() } } -///ElicitRequestParams +///The parameters for a request to elicit non-sensitive information from the user via a form in the client. /// ///
JSON schema /// /// ```json ///{ +/// "description": "The parameters for a request to elicit non-sensitive information from the user via a form in the client.", /// "type": "object", /// "required": [ /// "message", /// "requestedSchema" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "message": { -/// "description": "The message to present to the user.", +/// "description": "The message to present to the user describing what information is being requested.", /// "type": "string" /// }, +/// "mode": { +/// "description": "The elicitation mode.", +/// "type": "string", +/// "const": "form" +/// }, /// "requestedSchema": { /// "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", /// "type": "object", @@ -1752,10 +2474,13 @@ impl ElicitRequest { /// "type" /// ], /// "properties": { +/// "$schema": { +/// "type": "string" +/// }, /// "properties": { /// "type": "object", /// "additionalProperties": { -/// "$ref": "#/definitions/PrimitiveSchemaDefinition" +/// "$ref": "#/$defs/PrimitiveSchemaDefinition" /// } /// }, /// "required": { @@ -1769,76 +2494,201 @@ impl ElicitRequest { /// "const": "object" /// } /// } +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ElicitRequestParams { - ///The message to present to the user. +pub struct ElicitRequestFormParams { + ///The message to present to the user describing what information is being requested. pub message: ::std::string::String, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The elicitation mode. + #[serde( + default, + skip_serializing_if = "::std::option::Option::is_none", + deserialize_with = "validate::elicit_request_form_params_mode" + )] + mode: ::std::option::Option<::std::string::String>, #[serde(rename = "requestedSchema")] - pub requested_schema: ElicitRequestedSchema, + pub requested_schema: ElicitFormSchema, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, } -/**A restricted subset of JSON Schema. -Only top-level properties are allowed, without nesting.*/ +impl ElicitRequestFormParams { + pub fn new( + message: ::std::string::String, + requested_schema: ElicitFormSchema, + meta: ::std::option::Option, + task: ::std::option::Option, + ) -> Self { + Self { + message, + meta, + mode: Some("form".to_string()), + requested_schema, + task, + } + } + pub fn mode(&self) -> &::std::option::Option<::std::string::String> { + &self.mode + } + /// returns "form" + pub fn mode_value() -> ::std::string::String { + "form".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `mode_value()` instead.")] + pub fn mode_name() -> ::std::string::String { + "form".to_string() + } +} +///The parameters for a request to elicit additional information from the user via the client. /// ///
JSON schema /// /// ```json ///{ -/// "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", +/// "description": "The parameters for a request to elicit additional information from the user via the client.", +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// }, +/// { +/// "$ref": "#/$defs/ElicitRequestFormParams" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ElicitRequestParams { + UrlParams(ElicitRequestUrlParams), + FormParams(ElicitRequestFormParams), +} +impl ::std::convert::From for ElicitRequestParams { + fn from(value: ElicitRequestUrlParams) -> Self { + Self::UrlParams(value) + } +} +impl ::std::convert::From for ElicitRequestParams { + fn from(value: ElicitRequestFormParams) -> Self { + Self::FormParams(value) + } +} +///The parameters for a request to elicit information from the user via a URL in the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The parameters for a request to elicit information from the user via a URL in the client.", /// "type": "object", /// "required": [ -/// "properties", -/// "type" +/// "elicitationId", +/// "message", +/// "mode", +/// "url" /// ], /// "properties": { -/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", -/// "additionalProperties": { -/// "$ref": "#/definitions/PrimitiveSchemaDefinition" -/// } +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} /// }, -/// "required": { -/// "type": "array", -/// "items": { -/// "type": "string" -/// } +/// "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" /// }, -/// "type": { +/// "message": { +/// "description": "The message to present to the user explaining why the interaction is needed.", +/// "type": "string" +/// }, +/// "mode": { +/// "description": "The elicitation mode.", /// "type": "string", -/// "const": "object" +/// "const": "url" +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// }, +/// "url": { +/// "description": "The URL that the user should navigate to.", +/// "type": "string", +/// "format": "uri" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ElicitRequestedSchema { - pub properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>, - #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] - pub required: ::std::vec::Vec<::std::string::String>, - #[serde(rename = "type", deserialize_with = "validate::elicit_requested_schema_type_")] - type_: ::std::string::String, +pub struct ElicitRequestUrlParams { + /**The ID of the elicitation, which must be unique within the context of the server. + The client MUST treat this ID as an opaque value.*/ + #[serde(rename = "elicitationId")] + pub elicitation_id: ::std::string::String, + ///The message to present to the user explaining why the interaction is needed. + pub message: ::std::string::String, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The elicitation mode. + #[serde(deserialize_with = "validate::elicit_request_url_params_mode")] + mode: ::std::string::String, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, + ///The URL that the user should navigate to. + pub url: ::std::string::String, } -impl ElicitRequestedSchema { +impl ElicitRequestUrlParams { pub fn new( - properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>, - required: ::std::vec::Vec<::std::string::String>, + elicitation_id: ::std::string::String, + message: ::std::string::String, + url: ::std::string::String, + meta: ::std::option::Option, + task: ::std::option::Option, ) -> Self { Self { - properties, - required, - type_: "object".to_string(), + elicitation_id, + message, + meta, + mode: "url".to_string(), + task, + url, } } - pub fn type_(&self) -> &::std::string::String { - &self.type_ + pub fn mode(&self) -> &::std::string::String { + &self.mode } - pub fn type_name() -> ::std::string::String { - "object".to_string() + /// returns "url" + pub fn mode_value() -> ::std::string::String { + "url".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `mode_value()` instead.")] + pub fn mode_name() -> ::std::string::String { + "url".to_string() } } ///The client's response to an elicitation request. @@ -1854,7 +2704,7 @@ impl ElicitRequestedSchema { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -1868,13 +2718,23 @@ impl ElicitRequestedSchema { /// ] /// }, /// "content": { -/// "description": "The submitted form data, only present when action is \"accept\".\nContains values matching the requested schema.", +/// "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", /// "additionalProperties": { -/// "type": [ -/// "string", -/// "integer", -/// "boolean" +/// "anyOf": [ +/// { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// { +/// "type": [ +/// "string", +/// "integer", +/// "boolean" +/// ] +/// } /// ] /// } /// } @@ -1889,11 +2749,12 @@ pub struct ElicitResult { - "decline": User explicitly decline the action - "cancel": User dismissed without making an explicit choice*/ pub action: ElicitResultAction, - /**The submitted form data, only present when action is "accept". - Contains values matching the requested schema.*/ + /**The submitted form data, only present when action is "accept" and mode was "form". + Contains values matching the requested schema. + Omitted for out-of-band mode responses.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub content: ::std::option::Option<::std::collections::HashMap<::std::string::String, ElicitResultContentValue>>, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + pub content: ::std::option::Option<::std::collections::HashMap<::std::string::String, ElicitResultContent>>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } @@ -1934,39 +2795,174 @@ impl ::std::fmt::Display for ElicitResultAction { } } } -///ElicitResultContentValue +///ElicitResultContent /// ///
JSON schema /// /// ```json ///{ -/// "type": [ -/// "string", -/// "integer", -/// "boolean" +/// "anyOf": [ +/// { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// { +/// "type": [ +/// "string", +/// "integer", +/// "boolean" +/// ] +/// } /// ] ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] #[serde(untagged)] -pub enum ElicitResultContentValue { - Boolean(bool), - String(::std::string::String), - Integer(i64), +pub enum ElicitResultContent { + StringArray(::std::vec::Vec<::std::string::String>), + Primitive(ElicitResultContentPrimitive), } -impl ::std::convert::From for ElicitResultContentValue { - fn from(value: bool) -> Self { - Self::Boolean(value) +impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for ElicitResultContent { + fn from(value: ::std::vec::Vec<::std::string::String>) -> Self { + Self::StringArray(value) } } -impl ::std::convert::From for ElicitResultContentValue { - fn from(value: i64) -> Self { - Self::Integer(value) +impl ::std::convert::From for ElicitResultContent { + fn from(value: ElicitResultContentPrimitive) -> Self { + Self::Primitive(value) } } -/**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 +///ElicitResultContentPrimitive +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": [ +/// "string", +/// "integer", +/// "boolean" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ElicitResultContentPrimitive { + Boolean(bool), + String(::std::string::String), + Integer(i64), +} +impl ::std::convert::From for ElicitResultContentPrimitive { + fn from(value: bool) -> Self { + Self::Boolean(value) + } +} +impl ::std::convert::From for ElicitResultContentPrimitive { + fn from(value: i64) -> Self { + Self::Integer(value) + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ElicitUrlMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/elicitation/complete" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "elicitationId" +/// ], +/// "properties": { +/// "elicitationId": { +/// "description": "The ID of the elicitation that completed.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ElicitationCompleteNotification { + #[serde(deserialize_with = "validate::elicitation_complete_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::elicitation_complete_notification_method")] + method: ::std::string::String, + pub params: ElicitCompleteParams, +} +impl ElicitationCompleteNotification { + pub fn new(params: ElicitCompleteParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/elicitation/complete".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/elicitation/complete" + pub fn method_value() -> ::std::string::String { + "notifications/elicitation/complete".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/elicitation/complete".to_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.*/ /// ///
JSON schema @@ -1981,21 +2977,21 @@ of the LLM and/or the user.*/ /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "annotations": { /// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" +/// "$ref": "#/$defs/Annotations" /// }, /// "resource": { /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextResourceContents" +/// "$ref": "#/$defs/TextResourceContents" /// }, /// { -/// "$ref": "#/definitions/BlobResourceContents" +/// "$ref": "#/$defs/BlobResourceContents" /// } /// ] /// }, @@ -2012,7 +3008,7 @@ pub struct EmbeddedResource { ///Optional annotations for the client. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub annotations: ::std::option::Option, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, pub resource: EmbeddedResourceResource, @@ -2035,6 +3031,11 @@ impl EmbeddedResource { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "resource" + pub fn type_value() -> ::std::string::String { + "resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "resource".to_string() } @@ -2047,10 +3048,10 @@ impl EmbeddedResource { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextResourceContents" +/// "$ref": "#/$defs/TextResourceContents" /// }, /// { -/// "$ref": "#/definitions/BlobResourceContents" +/// "$ref": "#/$defs/BlobResourceContents" /// } /// ] ///} @@ -2078,7 +3079,7 @@ impl ::std::convert::From for EmbeddedResourceResource { /// /// ```json ///{ -/// "$ref": "#/definitions/Result" +/// "$ref": "#/$defs/Result" ///} /// ``` ///
@@ -2091,80 +3092,86 @@ pub struct EmptyResult(pub Result); /// /// ```json ///{ -/// "type": "object", -/// "required": [ -/// "enum", -/// "type" -/// ], -/// "properties": { -/// "default": { -/// "type": "string" -/// }, -/// "description": { -/// "type": "string" +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/UntitledSingleSelectEnumSchema" /// }, -/// "enum": { -/// "type": "array", -/// "items": { -/// "type": "string" -/// } +/// { +/// "$ref": "#/$defs/TitledSingleSelectEnumSchema" /// }, -/// "enumNames": { -/// "type": "array", -/// "items": { -/// "type": "string" -/// } +/// { +/// "$ref": "#/$defs/UntitledMultiSelectEnumSchema" /// }, -/// "title": { -/// "type": "string" +/// { +/// "$ref": "#/$defs/TitledMultiSelectEnumSchema" /// }, -/// "type": { -/// "type": "string", -/// "const": "string" +/// { +/// "$ref": "#/$defs/LegacyTitledEnumSchema" /// } -/// } +/// ] ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct EnumSchema { - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub default: ::std::option::Option<::std::string::String>, - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub description: ::std::option::Option<::std::string::String>, - #[serde(rename = "enum")] - pub enum_: ::std::vec::Vec<::std::string::String>, - #[serde(rename = "enumNames", default, skip_serializing_if = "::std::vec::Vec::is_empty")] - pub enum_names: ::std::vec::Vec<::std::string::String>, - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub title: ::std::option::Option<::std::string::String>, - #[serde(rename = "type", deserialize_with = "validate::enum_schema_type_")] - type_: ::std::string::String, +#[serde(untagged)] +pub enum EnumSchema { + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), + LegacyTitledEnumSchema(LegacyTitledEnumSchema), } -impl EnumSchema { - pub fn new( - enum_: ::std::vec::Vec<::std::string::String>, - enum_names: ::std::vec::Vec<::std::string::String>, - default: ::std::option::Option<::std::string::String>, - description: ::std::option::Option<::std::string::String>, - title: ::std::option::Option<::std::string::String>, - ) -> Self { - Self { - default, - description, - enum_, - enum_names, - title, - type_: "string".to_string(), - } +impl ::std::convert::From for EnumSchema { + fn from(value: UntitledSingleSelectEnumSchema) -> Self { + Self::UntitledSingleSelectEnumSchema(value) } - pub fn type_(&self) -> &::std::string::String { - &self.type_ +} +impl ::std::convert::From for EnumSchema { + fn from(value: TitledSingleSelectEnumSchema) -> Self { + Self::TitledSingleSelectEnumSchema(value) } - pub fn type_name() -> ::std::string::String { - "string".to_string() +} +impl ::std::convert::From for EnumSchema { + fn from(value: UntitledMultiSelectEnumSchema) -> Self { + Self::UntitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for EnumSchema { + fn from(value: TitledMultiSelectEnumSchema) -> Self { + Self::TitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for EnumSchema { + fn from(value: LegacyTitledEnumSchema) -> Self { + Self::LegacyTitledEnumSchema(value) } } +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct GetPromptMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} ///Used by the client to get a prompt provided by the server. /// ///
JSON schema @@ -2181,7 +3188,7 @@ impl EnumSchema { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -2192,23 +3199,7 @@ impl EnumSchema { /// "const": "prompts/get" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "name" -/// ], -/// "properties": { -/// "arguments": { -/// "description": "Arguments to use for templating the prompt.", -/// "type": "object", -/// "additionalProperties": { -/// "type": "string" -/// } -/// }, -/// "name": { -/// "description": "The name of the prompt or prompt template.", -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/GetPromptRequestParams" /// } /// } ///} @@ -2238,21 +3229,38 @@ impl GetPromptRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "prompts/get" + pub fn method_value() -> ::std::string::String { + "prompts/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "prompts/get".to_string() } } -///GetPromptRequestParams +///Parameters for a prompts/get request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a prompts/get request.", /// "type": "object", /// "required": [ /// "name" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "arguments": { /// "description": "Arguments to use for templating the prompt.", /// "type": "object", @@ -2273,6 +3281,8 @@ pub struct GetPromptRequestParams { ///Arguments to use for templating the prompt. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub arguments: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, ///The name of the prompt or prompt template. pub name: ::std::string::String, } @@ -2289,7 +3299,7 @@ pub struct GetPromptRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -2300,7 +3310,7 @@ pub struct GetPromptRequestParams { /// "messages": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/PromptMessage" +/// "$ref": "#/$defs/PromptMessage" /// } /// } /// } @@ -2313,59 +3323,326 @@ pub struct GetPromptResult { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, pub messages: ::std::vec::Vec, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///An optionally-sized icon that can be displayed in a user interface. +///GetTaskParams /// ///
JSON schema /// /// ```json ///{ -/// "description": "An optionally-sized icon that can be displayed in a user interface.", /// "type": "object", /// "required": [ -/// "src" +/// "taskId" /// ], /// "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\".", +/// "taskId": { +/// "description": "The task identifier to query.", /// "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.", -/// "type": "array", -/// "items": { -/// "type": "string" -/// } -/// }, -/// "src": { -/// "description": "A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a\ndata: 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.", -/// "type": "string", -/// "format": "uri" -/// }, -/// "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.", -/// "type": "string", -/// "enum": [ -/// "dark", -/// "light" -/// ] /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct Icon { - /**Optional MIME type override if the source MIME type is missing or generic. - For example: "image/png", "image/jpeg", or "image/svg+xml".*/ - #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] - pub mime_type: ::std::option::Option<::std::string::String>, - /**Optional array of strings that specify sizes at which the icon can be used. - Each string should be in WxH format (e.g., "48x48", "96x96") or "any" for scalable formats like SVG. - If not provided, the client should assume that the icon can be used at any size.*/ +pub struct GetTaskParams { + ///The task identifier to query. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///GetTaskPayloadParams +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to retrieve results for.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskPayloadParams { + ///The task identifier to retrieve results for. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, +} +///A request to retrieve the result of a completed task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to retrieve the result of a completed task.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tasks/result" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to retrieve results for.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskPayloadRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::get_task_payload_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::get_task_payload_request_method")] + method: ::std::string::String, + pub params: GetTaskPayloadParams, +} +impl GetTaskPayloadRequest { + pub fn new(id: RequestId, params: GetTaskPayloadParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/result".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/result" + pub fn method_value() -> ::std::string::String { + "tasks/result".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/result".to_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.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct GetTaskPayloadResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///A request to retrieve the state of a task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request to retrieve the state of a task.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tasks/get" +/// }, +/// "params": { +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier to query.", +/// "type": "string" +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::get_task_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::get_task_request_method")] + method: ::std::string::String, + pub params: GetTaskParams, +} +impl GetTaskRequest { + pub fn new(id: RequestId, params: GetTaskParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tasks/get".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tasks/get" + pub fn method_value() -> ::std::string::String { + "tasks/get".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tasks/get".to_string() + } +} +///The response to a tasks/get request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The response to a tasks/get request.", +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "$ref": "#/$defs/Task" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct GetTaskResult { + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + pub ttl: i64, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///An optionally-sized icon that can be displayed in a user interface. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An optionally-sized icon that can be displayed in a user interface.", +/// "type": "object", +/// "required": [ +/// "src" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "src": { +/// "description": "A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a\ndata: 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.", +/// "type": "string", +/// "format": "uri" +/// }, +/// "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.", +/// "type": "string", +/// "enum": [ +/// "dark", +/// "light" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct Icon { + /**Optional MIME type override if the source MIME type is missing or generic. + For example: "image/png", "image/jpeg", or "image/svg+xml".*/ + #[serde(rename = "mimeType", default, skip_serializing_if = "::std::option::Option::is_none")] + pub mime_type: ::std::option::Option<::std::string::String>, + /**Optional array of strings that specify sizes at which the icon can be used. + Each string should be in WxH format (e.g., "48x48", "96x96") or "any" for scalable formats like SVG. + If not provided, the client should assume that the icon can be used at any size.*/ #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] pub sizes: ::std::vec::Vec<::std::string::String>, /**A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a @@ -2428,7 +3705,7 @@ impl ::std::fmt::Display for IconTheme { /// "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)", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "$ref": "#/$defs/Icon" /// } /// } /// } @@ -2462,13 +3739,13 @@ pub struct Icons { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "annotations": { /// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" +/// "$ref": "#/$defs/Annotations" /// }, /// "data": { /// "description": "The base64-encoded image data.", @@ -2494,7 +3771,7 @@ pub struct ImageContent { pub annotations: ::std::option::Option, ///The base64-encoded image data. pub data: ::std::string::String, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of the image. Different providers may support different image types. @@ -2521,28 +3798,37 @@ impl ImageContent { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "image" + pub fn type_value() -> ::std::string::String { + "image".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "image".to_string() } } -///Describes the MCP implementation +///Describes the MCP implementation. /// ///
JSON schema /// /// ```json ///{ -/// "description": "Describes the MCP implementation", +/// "description": "Describes the MCP implementation.", /// "type": "object", /// "required": [ /// "name", /// "version" /// ], /// "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)", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "$ref": "#/$defs/Icon" /// } /// }, /// "name": { @@ -2567,6 +3853,12 @@ impl ImageContent { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct Implementation { + /**An optional human-readable description of what this implementation does. + This can be used by clients or servers to provide context about their purpose + and capabilities. For example, a server might describe the types of resources + or tools it provides, while a client might describe its intended use case.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, /**Optional set of sized icons that the client can display in a user interface. Clients that support rendering icons MUST support at least the following MIME types: - image/png - PNG images (safe, universal compatibility) @@ -2590,51 +3882,97 @@ pub struct Implementation { #[serde(rename = "websiteUrl", default, skip_serializing_if = "::std::option::Option::is_none")] pub website_url: ::std::option::Option<::std::string::String>, } -///This request is sent from the client to the server when it first connects, asking it to begin initialization. +/**A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. +The client MAY ignore this request. +Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client +declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.*/ /// ///
JSON schema /// /// ```json ///{ -/// "description": "This request is sent from the client to the server when it first connects, asking it to begin initialization.", -/// "type": "object", -/// "required": [ -/// "id", -/// "jsonrpc", -/// "method", -/// "params" -/// ], -/// "properties": { -/// "id": { -/// "$ref": "#/definitions/RequestId" -/// }, -/// "jsonrpc": { -/// "type": "string", -/// "const": "2.0" -/// }, -/// "method": { -/// "type": "string", -/// "const": "initialize" -/// }, -/// "params": { -/// "type": "object", -/// "required": [ -/// "capabilities", -/// "clientInfo", -/// "protocolVersion" -/// ], -/// "properties": { -/// "capabilities": { -/// "$ref": "#/definitions/ClientCapabilities" -/// }, -/// "clientInfo": { -/// "$ref": "#/definitions/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" -/// } -/// } +/// "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.", +/// "type": "string", +/// "enum": [ +/// "allServers", +/// "none", +/// "thisServer" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum IncludeContext { + #[serde(rename = "allServers")] + AllServers, + #[serde(rename = "none")] + None, + #[serde(rename = "thisServer")] + ThisServer, +} +impl ::std::fmt::Display for IncludeContext { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::AllServers => write!(f, "allServers"), + Self::None => write!(f, "none"), + Self::ThisServer => write!(f, "thisServer"), + } + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct InitializeMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///This request is sent from the client to the server when it first connects, asking it to begin initialization. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "This request is sent from the client to the server when it first connects, asking it to begin initialization.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "initialize" +/// }, +/// "params": { +/// "$ref": "#/$defs/InitializeRequestParams" /// } /// } ///} @@ -2664,16 +4002,22 @@ impl InitializeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "initialize" + pub fn method_value() -> ::std::string::String { + "initialize".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "initialize".to_string() } } -///InitializeRequestParams +///Parameters for an initialize request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for an initialize request.", /// "type": "object", /// "required": [ /// "capabilities", @@ -2681,11 +4025,22 @@ impl InitializeRequest { /// "protocolVersion" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "capabilities": { -/// "$ref": "#/definitions/ClientCapabilities" +/// "$ref": "#/$defs/ClientCapabilities" /// }, /// "clientInfo": { -/// "$ref": "#/definitions/Implementation" +/// "$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.", @@ -2700,6 +4055,8 @@ pub struct InitializeRequestParams { pub capabilities: ClientCapabilities, #[serde(rename = "clientInfo")] pub client_info: Implementation, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, ///The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. #[serde(rename = "protocolVersion")] pub protocol_version: ::std::string::String, @@ -2719,12 +4076,12 @@ pub struct InitializeRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "capabilities": { -/// "$ref": "#/definitions/ServerCapabilities" +/// "$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.", @@ -2735,7 +4092,7 @@ pub struct InitializeRequestParams { /// "type": "string" /// }, /// "serverInfo": { -/// "$ref": "#/definitions/Implementation" +/// "$ref": "#/$defs/Implementation" /// } /// } ///} @@ -2748,7 +4105,7 @@ pub struct InitializeResult { This 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.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub instructions: ::std::option::Option<::std::string::String>, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///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. @@ -2779,15 +4136,7 @@ pub struct InitializeResult { /// "const": "notifications/initialized" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} +/// "$ref": "#/$defs/NotificationParams" /// } /// } ///} @@ -2800,10 +4149,10 @@ pub struct InitializedNotification { #[serde(deserialize_with = "validate::initialized_notification_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl InitializedNotification { - pub fn new(params: ::std::option::Option) -> Self { + pub fn new(params: ::std::option::Option) -> Self { Self { jsonrpc: JSONRPC_VERSION.to_string(), method: "notifications/initialized".to_string(), @@ -2816,36 +4165,15 @@ impl InitializedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/initialized" + pub fn method_value() -> ::std::string::String { + "notifications/initialized".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/initialized".to_string() } } -///InitializedNotificationParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct InitializedNotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} ///A response to a request that indicates an error occurred. /// ///
JSON schema @@ -2856,15 +4184,14 @@ pub struct InitializedNotificationParams { /// "type": "object", /// "required": [ /// "error", -/// "id", /// "jsonrpc" /// ], /// "properties": { /// "error": { -/// "$ref": "#/definitions/Error" +/// "$ref": "#/$defs/Error" /// }, /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -2875,14 +4202,15 @@ pub struct InitializedNotificationParams { /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct JsonrpcError { +pub struct JsonrpcErrorResponse { pub error: RpcError, - pub id: RequestId, - #[serde(deserialize_with = "validate::jsonrpc_error_jsonrpc")] + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub id: ::std::option::Option, + #[serde(deserialize_with = "validate::jsonrpc_error_response_jsonrpc")] jsonrpc: ::std::string::String, } -impl JsonrpcError { - pub fn new(error: RpcError, id: RequestId) -> Self { +impl JsonrpcErrorResponse { + pub fn new(error: RpcError, id: ::std::option::Option) -> Self { Self { error, id, @@ -2902,16 +4230,16 @@ impl JsonrpcError { /// "description": "Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.", /// "anyOf": [ /// { -/// "$ref": "#/definitions/JSONRPCRequest" +/// "$ref": "#/$defs/JSONRPCRequest" /// }, /// { -/// "$ref": "#/definitions/JSONRPCNotification" +/// "$ref": "#/$defs/JSONRPCNotification" /// }, /// { -/// "$ref": "#/definitions/JSONRPCResponse" +/// "$ref": "#/$defs/JSONRPCResultResponse" /// }, /// { -/// "$ref": "#/definitions/JSONRPCError" +/// "$ref": "#/$defs/JSONRPCErrorResponse" /// } /// ] ///} @@ -2922,8 +4250,8 @@ impl JsonrpcError { pub enum JsonrpcMessage { Request(JsonrpcRequest), Notification(JsonrpcNotification), - Response(JsonrpcResponse), - Error(JsonrpcError), + ResultResponse(JsonrpcResultResponse), + ErrorResponse(JsonrpcErrorResponse), } impl ::std::convert::From for JsonrpcMessage { fn from(value: JsonrpcRequest) -> Self { @@ -2935,14 +4263,14 @@ impl ::std::convert::From for JsonrpcMessage { Self::Notification(value) } } -impl ::std::convert::From for JsonrpcMessage { - fn from(value: JsonrpcResponse) -> Self { - Self::Response(value) +impl ::std::convert::From for JsonrpcMessage { + fn from(value: JsonrpcResultResponse) -> Self { + Self::ResultResponse(value) } } -impl ::std::convert::From for JsonrpcMessage { - fn from(value: JsonrpcError) -> Self { - Self::Error(value) +impl ::std::convert::From for JsonrpcMessage { + fn from(value: JsonrpcErrorResponse) -> Self { + Self::ErrorResponse(value) } } ///A notification which does not expect a response. @@ -2967,13 +4295,6 @@ impl ::std::convert::From for JsonrpcMessage { /// }, /// "params": { /// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, /// "additionalProperties": {} /// } /// } @@ -2986,10 +4307,13 @@ pub struct JsonrpcNotification { jsonrpc: ::std::string::String, pub method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } impl JsonrpcNotification { - pub fn new(method: ::std::string::String, params: ::std::option::Option) -> Self { + pub fn new( + method: ::std::string::String, + params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { Self { jsonrpc: JSONRPC_VERSION.to_string(), method, @@ -3000,32 +4324,6 @@ impl JsonrpcNotification { &self.jsonrpc } } -///JsonrpcNotificationParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct JsonrpcNotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} ///A request that expects a response. /// ///
JSON schema @@ -3041,7 +4339,7 @@ pub struct JsonrpcNotificationParams { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -3052,19 +4350,6 @@ pub struct JsonrpcNotificationParams { /// }, /// "params": { /// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -/// } -/// }, /// "additionalProperties": {} /// } /// } @@ -3078,10 +4363,14 @@ pub struct JsonrpcRequest { jsonrpc: ::std::string::String, pub method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } impl JsonrpcRequest { - pub fn new(id: RequestId, method: ::std::string::String, params: ::std::option::Option) -> Self { + pub fn new( + id: RequestId, + method: ::std::string::String, + params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { Self { id, jsonrpc: JSONRPC_VERSION.to_string(), @@ -3093,62 +4382,39 @@ impl JsonrpcRequest { &self.jsonrpc } } -///JsonrpcRequestParams +///A response to a request, containing either the result or error. /// ///
JSON schema /// /// ```json ///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} +/// "description": "A response to a request, containing either the result or error.", +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/JSONRPCResultResponse" +/// }, +/// { +/// "$ref": "#/$defs/JSONRPCErrorResponse" /// } -/// }, -/// "additionalProperties": {} +/// ] ///} /// ``` ///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct JsonrpcRequestParams { - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum JsonrpcResponse { + ResultResponse(JsonrpcResultResponse), + ErrorResponse(JsonrpcErrorResponse), } -///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct JsonrpcRequestParamsMeta { - ///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. - #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] - pub progress_token: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +impl ::std::convert::From for JsonrpcResponse { + fn from(value: JsonrpcResultResponse) -> Self { + Self::ResultResponse(value) + } +} +impl ::std::convert::From for JsonrpcResponse { + fn from(value: JsonrpcErrorResponse) -> Self { + Self::ErrorResponse(value) + } } ///A successful (non-error) response to a request. /// @@ -3165,27 +4431,27 @@ pub struct JsonrpcRequestParamsMeta { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", /// "const": "2.0" /// }, /// "result": { -/// "$ref": "#/definitions/Result" +/// "$ref": "#/$defs/Result" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct JsonrpcResponse { +pub struct JsonrpcResultResponse { pub id: RequestId, - #[serde(deserialize_with = "validate::jsonrpc_response_jsonrpc")] + #[serde(deserialize_with = "validate::jsonrpc_result_response_jsonrpc")] jsonrpc: ::std::string::String, pub result: Result, } -impl JsonrpcResponse { +impl JsonrpcResultResponse { pub fn new(id: RequestId, result: Result) -> Self { Self { id, @@ -3197,95 +4463,161 @@ impl JsonrpcResponse { &self.jsonrpc } } -///Sent from the client to request a list of prompts and prompt templates the server has. +/**Use TitledSingleSelectEnumSchema instead. +This interface will be removed in a future version.*/ /// ///
JSON schema /// /// ```json ///{ -/// "description": "Sent from the client to request a list of prompts and prompt templates the server has.", +/// "description": "Use TitledSingleSelectEnumSchema instead.\nThis interface will be removed in a future version.", /// "type": "object", /// "required": [ -/// "id", -/// "jsonrpc", -/// "method" +/// "enum", +/// "type" /// ], /// "properties": { -/// "id": { -/// "$ref": "#/definitions/RequestId" +/// "default": { +/// "type": "string" /// }, -/// "jsonrpc": { -/// "type": "string", -/// "const": "2.0" +/// "description": { +/// "type": "string" /// }, -/// "method": { -/// "type": "string", -/// "const": "prompts/list" +/// "enum": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } /// }, -/// "params": { -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } +/// "enumNames": { +/// "description": "(Legacy) Display names for enum values.\nNon-standard according to JSON schema 2020-12.", +/// "type": "array", +/// "items": { +/// "type": "string" /// } +/// }, +/// "title": { +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ListPromptsRequest { - pub id: RequestId, - #[serde(deserialize_with = "validate::list_prompts_request_jsonrpc")] - jsonrpc: ::std::string::String, - #[serde(deserialize_with = "validate::list_prompts_request_method")] - method: ::std::string::String, +pub struct LegacyTitledEnumSchema { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, -} -impl ListPromptsRequest { - pub fn new(id: RequestId, params: ::std::option::Option) -> Self { - Self { - id, - jsonrpc: JSONRPC_VERSION.to_string(), - method: "prompts/list".to_string(), - params, + pub default: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(rename = "enum")] + pub enum_: ::std::vec::Vec<::std::string::String>, + /**(Legacy) Display names for enum values. + Non-standard according to JSON schema 2020-12.*/ + #[serde(rename = "enumNames", default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub enum_names: ::std::vec::Vec<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::legacy_titled_enum_schema_type_")] + type_: ::std::string::String, +} +impl LegacyTitledEnumSchema { + pub fn new( + enum_: ::std::vec::Vec<::std::string::String>, + enum_names: ::std::vec::Vec<::std::string::String>, + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + enum_, + enum_names, + title, + type_: "string".to_string(), } } - pub fn jsonrpc(&self) -> &::std::string::String { - &self.jsonrpc + pub fn type_(&self) -> &::std::string::String { + &self.type_ } - pub fn method(&self) -> &::std::string::String { - &self.method + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() } - pub fn method_name() -> ::std::string::String { - "prompts/list".to_string() + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() } } -///ListPromptsRequestParams +///Sent from the client to request a list of prompts and prompt templates the server has. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Sent from the client to request a list of prompts and prompt templates the server has.", /// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], /// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "prompts/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" /// } /// } ///} /// ``` ///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ListPromptsRequestParams { - /**An opaque token representing the current pagination position. - If provided, the server should return results starting after this cursor.*/ +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListPromptsRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_prompts_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_prompts_request_method")] + method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub cursor: ::std::option::Option<::std::string::String>, + pub params: ::std::option::Option, +} +impl ListPromptsRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "prompts/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "prompts/list" + pub fn method_value() -> ::std::string::String { + "prompts/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "prompts/list".to_string() + } } ///The server's response to a prompts/list request from the client. /// @@ -3300,7 +4632,7 @@ pub struct ListPromptsRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3311,7 +4643,7 @@ pub struct ListPromptsRequestParams { /// "prompts": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Prompt" +/// "$ref": "#/$defs/Prompt" /// } /// } /// } @@ -3320,7 +4652,7 @@ pub struct ListPromptsRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListPromptsResult { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3344,7 +4676,7 @@ pub struct ListPromptsResult { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -3355,13 +4687,7 @@ pub struct ListPromptsResult { /// "const": "resources/templates/list" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/PaginatedRequestParams" /// } /// } ///} @@ -3375,10 +4701,10 @@ pub struct ListResourceTemplatesRequest { #[serde(deserialize_with = "validate::list_resource_templates_request_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl ListResourceTemplatesRequest { - pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { Self { id, jsonrpc: JSONRPC_VERSION.to_string(), @@ -3392,33 +4718,15 @@ impl ListResourceTemplatesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/templates/list" + pub fn method_value() -> ::std::string::String { + "resources/templates/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/templates/list".to_string() } } -///ListResourceTemplatesRequestParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ListResourceTemplatesRequestParams { - /**An opaque token representing the current pagination position. - If provided, the server should return results starting after this cursor.*/ - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub cursor: ::std::option::Option<::std::string::String>, -} ///The server's response to a resources/templates/list request from the client. /// ///
JSON schema @@ -3432,7 +4740,7 @@ pub struct ListResourceTemplatesRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3443,7 +4751,7 @@ pub struct ListResourceTemplatesRequestParams { /// "resourceTemplates": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/ResourceTemplate" +/// "$ref": "#/$defs/ResourceTemplate" /// } /// } /// } @@ -3452,7 +4760,7 @@ pub struct ListResourceTemplatesRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListResourceTemplatesResult { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3477,7 +4785,7 @@ pub struct ListResourceTemplatesResult { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -3488,13 +4796,7 @@ pub struct ListResourceTemplatesResult { /// "const": "resources/list" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/PaginatedRequestParams" /// } /// } ///} @@ -3508,10 +4810,10 @@ pub struct ListResourcesRequest { #[serde(deserialize_with = "validate::list_resources_request_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl ListResourcesRequest { - pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { Self { id, jsonrpc: JSONRPC_VERSION.to_string(), @@ -3525,33 +4827,15 @@ impl ListResourcesRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/list" + pub fn method_value() -> ::std::string::String { + "resources/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/list".to_string() } } -///ListResourcesRequestParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ListResourcesRequestParams { - /**An opaque token representing the current pagination position. - If provided, the server should return results starting after this cursor.*/ - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub cursor: ::std::option::Option<::std::string::String>, -} ///The server's response to a resources/list request from the client. /// ///
JSON schema @@ -3565,7 +4849,7 @@ pub struct ListResourcesRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3576,7 +4860,7 @@ pub struct ListResourcesRequestParams { /// "resources": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Resource" +/// "$ref": "#/$defs/Resource" /// } /// } /// } @@ -3585,7 +4869,7 @@ pub struct ListResourcesRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListResourcesResult { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -3614,7 +4898,7 @@ structure or access specific locations that the client has permission to read fr /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -3625,21 +4909,7 @@ structure or access specific locations that the client has permission to read fr /// "const": "roots/list" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} +/// "$ref": "#/$defs/RequestParams" /// } /// } ///} @@ -3653,10 +4923,10 @@ pub struct ListRootsRequest { #[serde(deserialize_with = "validate::list_roots_request_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl ListRootsRequest { - pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { Self { id, jsonrpc: JSONRPC_VERSION.to_string(), @@ -3670,67 +4940,15 @@ impl ListRootsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "roots/list" + pub fn method_value() -> ::std::string::String { + "roots/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "roots/list".to_string() } } -///ListRootsRequestParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ListRootsRequestParams { - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} -///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ListRootsRequestParamsMeta { - ///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. - #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] - pub progress_token: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} /**The client's response to a roots/list request from the server. This result contains an array of Root objects, each representing a root directory or file that the server can operate on.*/ @@ -3746,14 +4964,14 @@ or file that the server can operate on.*/ /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "roots": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Root" +/// "$ref": "#/$defs/Root" /// } /// } /// } @@ -3762,18 +4980,18 @@ or file that the server can operate on.*/ ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ListRootsResult { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, pub roots: ::std::vec::Vec, } -///Sent from the client to request a list of tools the server has. +///A request to retrieve a list of tasks. /// ///
JSON schema /// /// ```json ///{ -/// "description": "Sent from the client to request a list of tools the server has.", +/// "description": "A request to retrieve a list of tasks.", /// "type": "object", /// "required": [ /// "id", @@ -3782,7 +5000,7 @@ pub struct ListRootsResult { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -3790,37 +5008,31 @@ pub struct ListRootsResult { /// }, /// "method": { /// "type": "string", -/// "const": "tools/list" +/// "const": "tasks/list" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/PaginatedRequestParams" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ListToolsRequest { +pub struct ListTasksRequest { pub id: RequestId, - #[serde(deserialize_with = "validate::list_tools_request_jsonrpc")] + #[serde(deserialize_with = "validate::list_tasks_request_jsonrpc")] jsonrpc: ::std::string::String, - #[serde(deserialize_with = "validate::list_tools_request_method")] + #[serde(deserialize_with = "validate::list_tasks_request_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } -impl ListToolsRequest { - pub fn new(id: RequestId, params: ::std::option::Option) -> Self { +impl ListTasksRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { Self { id, jsonrpc: JSONRPC_VERSION.to_string(), - method: "tools/list".to_string(), + method: "tasks/list".to_string(), params, } } @@ -3830,47 +5042,29 @@ impl ListToolsRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "tasks/list" + pub fn method_value() -> ::std::string::String { + "tasks/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { - "tools/list".to_string() + "tasks/list".to_string() } } -///ListToolsRequestParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ListToolsRequestParams { - /**An opaque token representing the current pagination position. - If provided, the server should return results starting after this cursor.*/ - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub cursor: ::std::option::Option<::std::string::String>, -} -///The server's response to a tools/list request from the client. +///The response to a tasks/list request. /// ///
JSON schema /// /// ```json ///{ -/// "description": "The server's response to a tools/list request from the client.", +/// "description": "The response to a tasks/list request.", /// "type": "object", /// "required": [ -/// "tools" +/// "tasks" /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -3878,10 +5072,10 @@ pub struct ListToolsRequestParams { /// "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", /// "type": "string" /// }, -/// "tools": { +/// "tasks": { /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Tool" +/// "$ref": "#/$defs/Task" /// } /// } /// } @@ -3889,18 +5083,126 @@ pub struct ListToolsRequestParams { /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ListToolsResult { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. +pub struct ListTasksResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. If present, there may be more results available.*/ #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] pub next_cursor: ::std::option::Option<::std::string::String>, - pub tools: ::std::vec::Vec, + pub tasks: ::std::vec::Vec, } -/**The severity of a log message. -These map to syslog message severities, as specified in RFC-5424: +///Sent from the client to request a list of tools the server has. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request a list of tools the server has.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "tools/list" +/// }, +/// "params": { +/// "$ref": "#/$defs/PaginatedRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListToolsRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::list_tools_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::list_tools_request_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ListToolsRequest { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "tools/list".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "tools/list" + pub fn method_value() -> ::std::string::String { + "tools/list".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "tools/list".to_string() + } +} +///The server's response to a tools/list request from the client. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The server's response to a tools/list request from the client.", +/// "type": "object", +/// "required": [ +/// "tools" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Tool" +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ListToolsResult { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An opaque token representing the pagination position after the last returned result. + If present, there may be more results available.*/ + #[serde(rename = "nextCursor", default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_cursor: ::std::option::Option<::std::string::String>, + pub tools: ::std::vec::Vec, +} +/**The severity of a log message. +These map to syslog message severities, as specified in RFC-5424: */ /// ///
JSON schema @@ -3978,24 +5280,7 @@ impl ::std::fmt::Display for LoggingLevel { /// "const": "notifications/message" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "data", -/// "level" -/// ], -/// "properties": { -/// "data": { -/// "description": "The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here." -/// }, -/// "level": { -/// "description": "The severity of this log message.", -/// "$ref": "#/definitions/LoggingLevel" -/// }, -/// "logger": { -/// "description": "An optional name of the logger issuing this message.", -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/LoggingMessageNotificationParams" /// } /// } ///} @@ -4023,28 +5308,39 @@ impl LoggingMessageNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/message" + pub fn method_value() -> ::std::string::String { + "notifications/message".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/message".to_string() } } -///LoggingMessageNotificationParams +///Parameters for a notifications/message notification. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a notifications/message notification.", /// "type": "object", /// "required": [ /// "data", /// "level" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, /// "data": { /// "description": "The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here." /// }, /// "level": { /// "description": "The severity of this log message.", -/// "$ref": "#/definitions/LoggingLevel" +/// "$ref": "#/$defs/LoggingLevel" /// }, /// "logger": { /// "description": "An optional name of the logger issuing this message.", @@ -4063,6 +5359,35 @@ pub struct LoggingMessageNotificationParams { ///An optional name of the logger issuing this message. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub logger: ::std::option::Option<::std::string::String>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct MessageMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } /**Hints to use for model selection. Keys not declared here are currently left unspecified by the spec and are up @@ -4122,7 +5447,7 @@ balance them against other considerations.*/ /// "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.", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/ModelHint" +/// "$ref": "#/$defs/ModelHint" /// } /// }, /// "intelligencePriority": { @@ -4161,6 +5486,39 @@ pub struct ModelPreferences { #[serde(rename = "speedPriority", default, skip_serializing_if = "::std::option::Option::is_none")] pub speed_priority: ::std::option::Option, } +///MultiSelectEnumSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/UntitledMultiSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/TitledMultiSelectEnumSchema" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum MultiSelectEnumSchema { + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), +} +impl ::std::convert::From for MultiSelectEnumSchema { + fn from(value: UntitledMultiSelectEnumSchema) -> Self { + Self::UntitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for MultiSelectEnumSchema { + fn from(value: TitledMultiSelectEnumSchema) -> Self { + Self::TitledMultiSelectEnumSchema(value) + } +} ///Notification /// ///
JSON schema @@ -4177,13 +5535,6 @@ pub struct ModelPreferences { /// }, /// "params": { /// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, /// "additionalProperties": {} /// } /// } @@ -4194,7 +5545,7 @@ pub struct ModelPreferences { pub struct Notification { pub method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } ///NotificationParams /// @@ -4205,22 +5556,19 @@ pub struct Notification { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } -/// }, -/// "additionalProperties": {} +/// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct NotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } ///NumberSchema /// @@ -4303,6 +5651,32 @@ impl ::std::fmt::Display for NumberSchemaType { } } } +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct PaginatedMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} ///PaginatedRequest /// ///
JSON schema @@ -4317,7 +5691,7 @@ impl ::std::fmt::Display for NumberSchemaType { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -4327,13 +5701,7 @@ impl ::std::fmt::Display for NumberSchemaType { /// "type": "string" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "cursor": { -/// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", -/// "type": "string" -/// } -/// } +/// "$ref": "#/$defs/PaginatedRequestParams" /// } /// } ///} @@ -4361,14 +5729,26 @@ impl PaginatedRequest { &self.jsonrpc } } -///PaginatedRequestParams +///Common parameters for paginated requests. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Common parameters for paginated requests.", /// "type": "object", /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "cursor": { /// "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", /// "type": "string" @@ -4383,6 +5763,8 @@ pub struct PaginatedRequestParams { If provided, the server should return results starting after this cursor.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub cursor: ::std::option::Option<::std::string::String>, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, } ///PaginatedResult /// @@ -4393,7 +5775,7 @@ pub struct PaginatedRequestParams { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4407,7 +5789,7 @@ pub struct PaginatedRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct PaginatedResult { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An opaque token representing the pagination position after the last returned result. @@ -4430,7 +5812,7 @@ pub struct PaginatedResult { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -4441,21 +5823,7 @@ pub struct PaginatedResult { /// "const": "ping" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} +/// "$ref": "#/$defs/RequestParams" /// } /// } ///} @@ -4469,10 +5837,10 @@ pub struct PingRequest { #[serde(deserialize_with = "validate::ping_request_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl PingRequest { - pub fn new(id: RequestId, params: ::std::option::Option) -> Self { + pub fn new(id: RequestId, params: ::std::option::Option) -> Self { Self { id, jsonrpc: JSONRPC_VERSION.to_string(), @@ -4486,89 +5854,49 @@ impl PingRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "ping" + pub fn method_value() -> ::std::string::String { + "ping".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "ping".to_string() } } -///PingRequestParams +/**Restricted schema definitions that only allow primitive types +without nested objects or arrays.*/ /// ///
JSON schema /// /// ```json ///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} +/// "description": "Restricted schema definitions that only allow primitive types\nwithout nested objects or arrays.", +/// "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" /// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct PingRequestParams { - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} -///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct PingRequestParamsMeta { - ///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. - #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] - pub progress_token: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} -/**Restricted schema definitions that only allow primitive types -without nested objects or arrays.*/ -/// -///
JSON schema -/// -/// ```json -///{ -/// "description": "Restricted schema definitions that only allow primitive types\nwithout nested objects or arrays.", -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/StringSchema" -/// }, -/// { -/// "$ref": "#/definitions/NumberSchema" -/// }, -/// { -/// "$ref": "#/definitions/BooleanSchema" -/// }, -/// { -/// "$ref": "#/definitions/EnumSchema" -/// } -/// ] +/// ] ///} /// ``` ///
@@ -4578,7 +5906,11 @@ pub enum PrimitiveSchemaDefinition { StringSchema(StringSchema), NumberSchema(NumberSchema), BooleanSchema(BooleanSchema), - EnumSchema(EnumSchema), + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), + UntitledMultiSelectEnumSchema(UntitledMultiSelectEnumSchema), + TitledMultiSelectEnumSchema(TitledMultiSelectEnumSchema), + LegacyTitledEnumSchema(LegacyTitledEnumSchema), } impl ::std::convert::From for PrimitiveSchemaDefinition { fn from(value: StringSchema) -> Self { @@ -4595,9 +5927,29 @@ impl ::std::convert::From for PrimitiveSchemaDefinition { Self::BooleanSchema(value) } } -impl ::std::convert::From for PrimitiveSchemaDefinition { - fn from(value: EnumSchema) -> Self { - Self::EnumSchema(value) +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: UntitledSingleSelectEnumSchema) -> Self { + Self::UntitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: TitledSingleSelectEnumSchema) -> Self { + Self::TitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: UntitledMultiSelectEnumSchema) -> Self { + Self::UntitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: TitledMultiSelectEnumSchema) -> Self { + Self::TitledMultiSelectEnumSchema(value) + } +} +impl ::std::convert::From for PrimitiveSchemaDefinition { + fn from(value: LegacyTitledEnumSchema) -> Self { + Self::LegacyTitledEnumSchema(value) } } ///An out-of-band notification used to inform the receiver of a progress update for a long-running request. @@ -4623,29 +5975,7 @@ impl ::std::convert::From for PrimitiveSchemaDefinition { /// "const": "notifications/progress" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "progress", -/// "progressToken" -/// ], -/// "properties": { -/// "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": { -/// "description": "The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.", -/// "$ref": "#/definitions/ProgressToken" -/// }, -/// "total": { -/// "description": "Total number of items to process (or total progress required), if known.", -/// "type": "number" -/// } -/// } +/// "$ref": "#/$defs/ProgressNotificationParams" /// } /// } ///} @@ -4673,22 +6003,33 @@ impl ProgressNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/progress" + pub fn method_value() -> ::std::string::String { + "notifications/progress".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/progress".to_string() } } -///ProgressNotificationParams +///Parameters for a notifications/progress notification. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a notifications/progress notification.", /// "type": "object", /// "required": [ /// "progress", /// "progressToken" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, /// "message": { /// "description": "An optional message describing the current progress.", /// "type": "string" @@ -4699,7 +6040,7 @@ impl ProgressNotification { /// }, /// "progressToken": { /// "description": "The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.", -/// "$ref": "#/definitions/ProgressToken" +/// "$ref": "#/$defs/ProgressToken" /// }, /// "total": { /// "description": "Total number of items to process (or total progress required), if known.", @@ -4714,6 +6055,9 @@ pub struct ProgressNotificationParams { ///An optional message describing the current progress. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub message: ::std::option::Option<::std::string::String>, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, pub progress: f64, ///The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. #[serde(rename = "progressToken")] @@ -4759,7 +6103,7 @@ impl ::std::convert::From for ProgressToken { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -4767,7 +6111,7 @@ impl ::std::convert::From for ProgressToken { /// "description": "A list of arguments to use for templating the prompt.", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/PromptArgument" +/// "$ref": "#/$defs/PromptArgument" /// } /// }, /// "description": { @@ -4778,7 +6122,7 @@ impl ::std::convert::From for ProgressToken { /// "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)", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "$ref": "#/$defs/Icon" /// } /// }, /// "name": { @@ -4810,7 +6154,7 @@ pub struct Prompt { - image/webp - WebP images (modern, efficient format)*/ #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] pub icons: ::std::vec::Vec, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). @@ -4895,15 +6239,7 @@ pub struct PromptArgument { /// "const": "notifications/prompts/list_changed" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} +/// "$ref": "#/$defs/NotificationParams" /// } /// } ///} @@ -4916,10 +6252,10 @@ pub struct PromptListChangedNotification { #[serde(deserialize_with = "validate::prompt_list_changed_notification_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl PromptListChangedNotification { - pub fn new(params: ::std::option::Option) -> Self { + pub fn new(params: ::std::option::Option) -> Self { Self { jsonrpc: JSONRPC_VERSION.to_string(), method: "notifications/prompts/list_changed".to_string(), @@ -4932,36 +6268,15 @@ impl PromptListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/prompts/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/prompts/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/prompts/list_changed".to_string() } } -///PromptListChangedNotificationParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct PromptListChangedNotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} /**Describes a message returned as part of a prompt. This is similar to SamplingMessage, but also supports the embedding of resources from the MCP server.*/ @@ -4978,10 +6293,10 @@ resources from the MCP server.*/ /// ], /// "properties": { /// "content": { -/// "$ref": "#/definitions/ContentBlock" +/// "$ref": "#/$defs/ContentBlock" /// }, /// "role": { -/// "$ref": "#/definitions/Role" +/// "$ref": "#/$defs/Role" /// } /// } ///} @@ -5046,10 +6361,74 @@ impl PromptReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/prompt" + pub fn type_value() -> ::std::string::String { + "ref/prompt".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/prompt".to_string() } } +///ReadResourceContent +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextResourceContents" +/// }, +/// { +/// "$ref": "#/$defs/BlobResourceContents" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum ReadResourceContent { + TextResourceContents(TextResourceContents), + BlobResourceContents(BlobResourceContents), +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: TextResourceContents) -> Self { + Self::TextResourceContents(value) + } +} +impl ::std::convert::From for ReadResourceContent { + fn from(value: BlobResourceContents) -> Self { + Self::BlobResourceContents(value) + } +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ReadResourceMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} ///Sent from the client to the server, to read a specific resource URI. /// ///
JSON schema @@ -5066,7 +6445,7 @@ impl PromptReference { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -5077,17 +6456,7 @@ impl PromptReference { /// "const": "resources/read" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "uri" -/// ], -/// "properties": { -/// "uri": { -/// "description": "The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.", -/// "type": "string", -/// "format": "uri" -/// } -/// } +/// "$ref": "#/$defs/ReadResourceRequestParams" /// } /// } ///} @@ -5117,23 +6486,40 @@ impl ReadResourceRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/read" + pub fn method_value() -> ::std::string::String { + "resources/read".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/read".to_string() } } -///ReadResourceRequestParams +///Parameters for a resources/read request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a resources/read request.", /// "type": "object", /// "required": [ /// "uri" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "uri": { -/// "description": "The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.", +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", /// "type": "string", /// "format": "uri" /// } @@ -5143,7 +6529,9 @@ impl ReadResourceRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ReadResourceRequestParams { - ///The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. pub uri: ::std::string::String, } ///The server's response to a resources/read request from the client. @@ -5159,7 +6547,7 @@ pub struct ReadResourceRequestParams { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -5168,10 +6556,10 @@ pub struct ReadResourceRequestParams { /// "items": { /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextResourceContents" +/// "$ref": "#/$defs/TextResourceContents" /// }, /// { -/// "$ref": "#/definitions/BlobResourceContents" +/// "$ref": "#/$defs/BlobResourceContents" /// } /// ] /// } @@ -5182,43 +6570,37 @@ pub struct ReadResourceRequestParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ReadResourceResult { - pub contents: ::std::vec::Vec, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + pub contents: ::std::vec::Vec, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///ReadResourceResultContentsItem +/**Metadata for associating messages with a task. +Include this in the _meta field under the key io.modelcontextprotocol/related-task.*/ /// ///
JSON schema /// /// ```json ///{ -/// "anyOf": [ -/// { -/// "$ref": "#/definitions/TextResourceContents" -/// }, -/// { -/// "$ref": "#/definitions/BlobResourceContents" +/// "description": "Metadata for associating messages with a task.\nInclude this in the _meta field under the key io.modelcontextprotocol/related-task.", +/// "type": "object", +/// "required": [ +/// "taskId" +/// ], +/// "properties": { +/// "taskId": { +/// "description": "The task identifier this message is associated with.", +/// "type": "string" /// } -/// ] +/// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ReadResourceResultContentsItem { - TextResourceContents(TextResourceContents), - BlobResourceContents(BlobResourceContents), -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: TextResourceContents) -> Self { - Self::TextResourceContents(value) - } -} -impl ::std::convert::From for ReadResourceResultContentsItem { - fn from(value: BlobResourceContents) -> Self { - Self::BlobResourceContents(value) - } +pub struct RelatedTaskMetadata { + ///The task identifier this message is associated with. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, } ///Request /// @@ -5236,19 +6618,6 @@ impl ::std::convert::From for ReadResourceResultContentsIt /// }, /// "params": { /// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "properties": { -/// "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.", -/// "$ref": "#/definitions/ProgressToken" -/// } -/// }, -/// "additionalProperties": {} -/// } -/// }, /// "additionalProperties": {} /// } /// } @@ -5259,7 +6628,7 @@ impl ::std::convert::From for ReadResourceResultContentsIt pub struct Request { pub method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } ///A uniquely identifying ID for a request in JSON-RPC. /// @@ -5286,27 +6655,27 @@ impl ::std::convert::From for RequestId { Self::Integer(value) } } -///RequestParams +///Common params for any request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Common params for any request.", /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "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.", -/// "$ref": "#/definitions/ProgressToken" +/// "$ref": "#/$defs/ProgressToken" /// } /// }, /// "additionalProperties": {} /// } -/// }, -/// "additionalProperties": {} +/// } ///} /// ``` ///
@@ -5314,21 +6683,19 @@ impl ::std::convert::From for RequestId { pub struct RequestParams { #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { /// "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.", -/// "$ref": "#/definitions/ProgressToken" +/// "$ref": "#/$defs/ProgressToken" /// } /// }, /// "additionalProperties": {} @@ -5357,13 +6724,13 @@ pub struct RequestParamsMeta { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "annotations": { /// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" +/// "$ref": "#/$defs/Annotations" /// }, /// "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.", @@ -5373,7 +6740,7 @@ pub struct RequestParamsMeta { /// "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)", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "$ref": "#/$defs/Icon" /// } /// }, /// "mimeType": { @@ -5419,7 +6786,7 @@ pub struct Resource { - image/webp - WebP images (modern, efficient format)*/ #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] pub icons: ::std::vec::Vec, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -5454,7 +6821,7 @@ pub struct Resource { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -5473,7 +6840,7 @@ pub struct Resource { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ResourceContents { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -5498,13 +6865,13 @@ Note: resource links returned by tools are not guaranteed to appear in the resul /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, /// "annotations": { /// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" +/// "$ref": "#/$defs/Annotations" /// }, /// "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.", @@ -5514,7 +6881,7 @@ Note: resource links returned by tools are not guaranteed to appear in the resul /// "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)", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "$ref": "#/$defs/Icon" /// } /// }, /// "mimeType": { @@ -5564,7 +6931,7 @@ pub struct ResourceLink { - image/webp - WebP images (modern, efficient format)*/ #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] pub icons: ::std::vec::Vec, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -5617,6 +6984,11 @@ impl ResourceLink { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "resource_link" + pub fn type_value() -> ::std::string::String { + "resource_link".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "resource_link".to_string() } @@ -5643,15 +7015,7 @@ impl ResourceLink { /// "const": "notifications/resources/list_changed" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} +/// "$ref": "#/$defs/NotificationParams" /// } /// } ///} @@ -5664,10 +7028,10 @@ pub struct ResourceListChangedNotification { #[serde(deserialize_with = "validate::resource_list_changed_notification_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl ResourceListChangedNotification { - pub fn new(params: ::std::option::Option) -> Self { + pub fn new(params: ::std::option::Option) -> Self { Self { jsonrpc: JSONRPC_VERSION.to_string(), method: "notifications/resources/list_changed".to_string(), @@ -5680,22 +7044,27 @@ impl ResourceListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/resources/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/list_changed".to_string() } } -///ResourceListChangedNotificationParams +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} +/// "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.", +/// "$ref": "#/$defs/ProgressToken" /// } /// }, /// "additionalProperties": {} @@ -5703,44 +7072,83 @@ impl ResourceListChangedNotification { /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ResourceListChangedNotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +pub struct ResourceMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, } -///A template description for resources available on the server. +///Common parameters when working with resources. /// ///
JSON schema /// /// ```json ///{ -/// "description": "A template description for resources available on the server.", +/// "description": "Common parameters when working with resources.", /// "type": "object", /// "required": [ -/// "name", -/// "uriTemplate" +/// "uri" /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, /// "additionalProperties": {} /// }, -/// "annotations": { -/// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" -/// }, -/// "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)", -/// "type": "array", +/// "uri": { +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", +/// "type": "string", +/// "format": "uri" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ResourceRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + pub uri: ::std::string::String, +} +///A template description for resources available on the server. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A template description for resources available on the server.", +/// "type": "object", +/// "required": [ +/// "name", +/// "uriTemplate" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "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)", +/// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "$ref": "#/$defs/Icon" /// } /// }, /// "mimeType": { @@ -5782,7 +7190,7 @@ pub struct ResourceTemplate { - image/webp - WebP images (modern, efficient format)*/ #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] pub icons: ::std::vec::Vec, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///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. @@ -5844,6 +7252,11 @@ impl ResourceTemplateReference { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "ref/resource" + pub fn type_value() -> ::std::string::String { + "ref/resource".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "ref/resource".to_string() } @@ -5871,17 +7284,7 @@ impl ResourceTemplateReference { /// "const": "notifications/resources/updated" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "uri" -/// ], -/// "properties": { -/// "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.", -/// "type": "string", -/// "format": "uri" -/// } -/// } +/// "$ref": "#/$defs/ResourceUpdatedNotificationParams" /// } /// } ///} @@ -5909,21 +7312,32 @@ impl ResourceUpdatedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/resources/updated" + pub fn method_value() -> ::std::string::String { + "notifications/resources/updated".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/resources/updated".to_string() } } -///ResourceUpdatedNotificationParams +///Parameters for a notifications/resources/updated notification. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a notifications/resources/updated notification.", /// "type": "object", /// "required": [ /// "uri" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, /// "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.", /// "type": "string", @@ -5935,6 +7349,9 @@ impl ResourceUpdatedNotification { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct ResourceUpdatedNotificationParams { + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. pub uri: ::std::string::String, } @@ -5947,7 +7364,7 @@ pub struct ResourceUpdatedNotificationParams { /// "type": "object", /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// } @@ -5958,7 +7375,7 @@ pub struct ResourceUpdatedNotificationParams { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] pub struct Result { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] @@ -6007,7 +7424,7 @@ impl ::std::fmt::Display for Role { /// ], /// "properties": { /// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "additionalProperties": {} /// }, @@ -6026,7 +7443,7 @@ impl ::std::fmt::Display for Role { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct Root { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, /**An optional name for the root. This can be used to provide a human-readable @@ -6063,15 +7480,7 @@ The server should then request an updated list of roots using the ListRootsReque /// "const": "notifications/roots/list_changed" /// }, /// "params": { -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} +/// "$ref": "#/$defs/NotificationParams" /// } /// } ///} @@ -6084,10 +7493,10 @@ pub struct RootsListChangedNotification { #[serde(deserialize_with = "validate::roots_list_changed_notification_method")] method: ::std::string::String, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub params: ::std::option::Option, } impl RootsListChangedNotification { - pub fn new(params: ::std::option::Option) -> Self { + pub fn new(params: ::std::option::Option) -> Self { Self { jsonrpc: JSONRPC_VERSION.to_string(), method: "notifications/roots/list_changed".to_string(), @@ -6100,36 +7509,15 @@ impl RootsListChangedNotification { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "notifications/roots/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/roots/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "notifications/roots/list_changed".to_string() } } -///RootsListChangedNotificationParams -/// -///
JSON schema -/// -/// ```json -///{ -/// "type": "object", -/// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// } -/// }, -/// "additionalProperties": {} -///} -/// ``` -///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct RootsListChangedNotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, -} ///RpcError /// ///
JSON schema @@ -6180,21 +7568,38 @@ pub struct RpcError { /// "role" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, /// "content": { /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextContent" +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" /// }, /// { -/// "$ref": "#/definitions/ImageContent" +/// "$ref": "#/$defs/ToolResultContent" /// }, /// { -/// "$ref": "#/definitions/AudioContent" +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } /// } /// ] /// }, /// "role": { -/// "$ref": "#/definitions/Role" +/// "$ref": "#/$defs/Role" /// } /// } ///} @@ -6203,6 +7608,9 @@ pub struct RpcError { #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct SamplingMessage { pub content: SamplingMessageContent, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, pub role: Role, } ///SamplingMessageContent @@ -6213,13 +7621,25 @@ pub struct SamplingMessage { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/TextContent" +/// "$ref": "#/$defs/TextContent" /// }, /// { -/// "$ref": "#/definitions/ImageContent" +/// "$ref": "#/$defs/ImageContent" /// }, /// { -/// "$ref": "#/definitions/AudioContent" +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// }, +/// { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/SamplingMessageContentBlock" +/// } /// } /// ] ///} @@ -6231,6 +7651,9 @@ pub enum SamplingMessageContent { TextContent(TextContent), ImageContent(ImageContent), AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), + SamplingMessageContentBlock(::std::vec::Vec), } impl ::std::convert::From for SamplingMessageContent { fn from(value: TextContent) -> Self { @@ -6247,6 +7670,81 @@ impl ::std::convert::From for SamplingMessageContent { Self::AudioContent(value) } } +impl ::std::convert::From for SamplingMessageContent { + fn from(value: ToolUseContent) -> Self { + Self::ToolUseContent(value) + } +} +impl ::std::convert::From for SamplingMessageContent { + fn from(value: ToolResultContent) -> Self { + Self::ToolResultContent(value) + } +} +impl ::std::convert::From<::std::vec::Vec> for SamplingMessageContent { + fn from(value: ::std::vec::Vec) -> Self { + Self::SamplingMessageContentBlock(value) + } +} +///SamplingMessageContentBlock +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/TextContent" +/// }, +/// { +/// "$ref": "#/$defs/ImageContent" +/// }, +/// { +/// "$ref": "#/$defs/AudioContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolUseContent" +/// }, +/// { +/// "$ref": "#/$defs/ToolResultContent" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum SamplingMessageContentBlock { + TextContent(TextContent), + ImageContent(ImageContent), + AudioContent(AudioContent), + ToolUseContent(ToolUseContent), + ToolResultContent(ToolResultContent), +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: TextContent) -> Self { + Self::TextContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: ImageContent) -> Self { + Self::ImageContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: AudioContent) -> Self { + Self::AudioContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: ToolUseContent) -> Self { + Self::ToolUseContent(value) + } +} +impl ::std::convert::From for SamplingMessageContentBlock { + fn from(value: ToolResultContent) -> Self { + Self::ToolResultContent(value) + } +} ///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. /// ///
JSON schema @@ -6298,6 +7796,39 @@ impl ::std::convert::From for SamplingMessageContent { /// } /// } /// }, +/// "tasks": { +/// "description": "Present if the server supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this server supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this server supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "tools": { +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } +/// }, /// "tools": { /// "description": "Present if the server offers any tools to call.", /// "type": "object", @@ -6330,6 +7861,8 @@ pub struct ServerCapabilities { #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub resources: ::std::option::Option, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tasks: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub tools: ::std::option::Option, } ///Present if the server offers any prompt templates. @@ -6416,25 +7949,31 @@ pub struct ServerCapabilitiesTools { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/CancelledNotification" +/// "$ref": "#/$defs/CancelledNotification" +/// }, +/// { +/// "$ref": "#/$defs/ProgressNotification" +/// }, +/// { +/// "$ref": "#/$defs/ResourceListChangedNotification" /// }, /// { -/// "$ref": "#/definitions/ProgressNotification" +/// "$ref": "#/$defs/ResourceUpdatedNotification" /// }, /// { -/// "$ref": "#/definitions/ResourceListChangedNotification" +/// "$ref": "#/$defs/PromptListChangedNotification" /// }, /// { -/// "$ref": "#/definitions/ResourceUpdatedNotification" +/// "$ref": "#/$defs/ToolListChangedNotification" /// }, /// { -/// "$ref": "#/definitions/PromptListChangedNotification" +/// "$ref": "#/$defs/TaskStatusNotification" /// }, /// { -/// "$ref": "#/definitions/ToolListChangedNotification" +/// "$ref": "#/$defs/LoggingMessageNotification" /// }, /// { -/// "$ref": "#/definitions/LoggingMessageNotification" +/// "$ref": "#/$defs/ElicitationCompleteNotification" /// } /// ] ///} @@ -6449,7 +7988,9 @@ pub enum ServerNotification { ResourceUpdatedNotification(ResourceUpdatedNotification), PromptListChangedNotification(PromptListChangedNotification), ToolListChangedNotification(ToolListChangedNotification), + TaskStatusNotification(TaskStatusNotification), LoggingMessageNotification(LoggingMessageNotification), + ElicitationCompleteNotification(ElicitationCompleteNotification), } impl ::std::convert::From for ServerNotification { fn from(value: CancelledNotification) -> Self { @@ -6481,11 +8022,21 @@ impl ::std::convert::From for ServerNotification { Self::ToolListChangedNotification(value) } } +impl ::std::convert::From for ServerNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::TaskStatusNotification(value) + } +} impl ::std::convert::From for ServerNotification { fn from(value: LoggingMessageNotification) -> Self { Self::LoggingMessageNotification(value) } } +impl ::std::convert::From for ServerNotification { + fn from(value: ElicitationCompleteNotification) -> Self { + Self::ElicitationCompleteNotification(value) + } +} ///ServerRequest /// ///
JSON schema @@ -6494,16 +8045,28 @@ impl ::std::convert::From for ServerNotification { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/PingRequest" +/// "$ref": "#/$defs/PingRequest" +/// }, +/// { +/// "$ref": "#/$defs/GetTaskRequest" +/// }, +/// { +/// "$ref": "#/$defs/GetTaskPayloadRequest" +/// }, +/// { +/// "$ref": "#/$defs/CancelTaskRequest" +/// }, +/// { +/// "$ref": "#/$defs/ListTasksRequest" /// }, /// { -/// "$ref": "#/definitions/CreateMessageRequest" +/// "$ref": "#/$defs/CreateMessageRequest" /// }, /// { -/// "$ref": "#/definitions/ListRootsRequest" +/// "$ref": "#/$defs/ListRootsRequest" /// }, /// { -/// "$ref": "#/definitions/ElicitRequest" +/// "$ref": "#/$defs/ElicitRequest" /// } /// ] ///} @@ -6514,6 +8077,10 @@ impl ::std::convert::From for ServerNotification { #[allow(clippy::large_enum_variant)] pub enum ServerRequest { PingRequest(PingRequest), + GetTaskRequest(GetTaskRequest), + GetTaskPayloadRequest(GetTaskPayloadRequest), + CancelTaskRequest(CancelTaskRequest), + ListTasksRequest(ListTasksRequest), CreateMessageRequest(CreateMessageRequest), ListRootsRequest(ListRootsRequest), ElicitRequest(ElicitRequest), @@ -6523,6 +8090,26 @@ impl ::std::convert::From for ServerRequest { Self::PingRequest(value) } } +impl ::std::convert::From for ServerRequest { + fn from(value: GetTaskRequest) -> Self { + Self::GetTaskRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::GetTaskPayloadRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: CancelTaskRequest) -> Self { + Self::CancelTaskRequest(value) + } +} +impl ::std::convert::From for ServerRequest { + fn from(value: ListTasksRequest) -> Self { + Self::ListTasksRequest(value) + } +} impl ::std::convert::From for ServerRequest { fn from(value: CreateMessageRequest) -> Self { Self::CreateMessageRequest(value) @@ -6546,34 +8133,48 @@ impl ::std::convert::From for ServerRequest { ///{ /// "anyOf": [ /// { -/// "$ref": "#/definitions/Result" +/// "$ref": "#/$defs/Result" +/// }, +/// { +/// "$ref": "#/$defs/InitializeResult" +/// }, +/// { +/// "$ref": "#/$defs/ListResourcesResult" +/// }, +/// { +/// "$ref": "#/$defs/ListResourceTemplatesResult" +/// }, +/// { +/// "$ref": "#/$defs/ReadResourceResult" /// }, /// { -/// "$ref": "#/definitions/InitializeResult" +/// "$ref": "#/$defs/ListPromptsResult" /// }, /// { -/// "$ref": "#/definitions/ListResourcesResult" +/// "$ref": "#/$defs/GetPromptResult" /// }, /// { -/// "$ref": "#/definitions/ListResourceTemplatesResult" +/// "$ref": "#/$defs/ListToolsResult" /// }, /// { -/// "$ref": "#/definitions/ReadResourceResult" +/// "$ref": "#/$defs/CallToolResult" /// }, /// { -/// "$ref": "#/definitions/ListPromptsResult" +/// "description": "The response to a tasks/get request.", +/// "$ref": "#/$defs/GetTaskResult" /// }, /// { -/// "$ref": "#/definitions/GetPromptResult" +/// "$ref": "#/$defs/GetTaskPayloadResult" /// }, /// { -/// "$ref": "#/definitions/ListToolsResult" +/// "description": "The response to a tasks/cancel request.", +/// "$ref": "#/$defs/CancelTaskResult" /// }, /// { -/// "$ref": "#/definitions/CallToolResult" +/// "$ref": "#/$defs/ListTasksResult" /// }, /// { -/// "$ref": "#/definitions/CompleteResult" +/// "$ref": "#/$defs/CompleteResult" /// } /// ] ///} @@ -6591,6 +8192,10 @@ pub enum ServerResult { GetPromptResult(GetPromptResult), ListToolsResult(ListToolsResult), CallToolResult(CallToolResult), + GetTaskResult(GetTaskResult), + GetTaskPayloadResult(GetTaskPayloadResult), + CancelTaskResult(CancelTaskResult), + ListTasksResult(ListTasksResult), CompleteResult(CompleteResult), Result(Result), } @@ -6634,6 +8239,26 @@ impl ::std::convert::From for ServerResult { Self::CallToolResult(value) } } +impl ::std::convert::From for ServerResult { + fn from(value: GetTaskResult) -> Self { + Self::GetTaskResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: GetTaskPayloadResult) -> Self { + Self::GetTaskPayloadResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: CancelTaskResult) -> Self { + Self::CancelTaskResult(value) + } +} +impl ::std::convert::From for ServerResult { + fn from(value: ListTasksResult) -> Self { + Self::ListTasksResult(value) + } +} impl ::std::convert::From for ServerResult { fn from(value: CompleteResult) -> Self { Self::CompleteResult(value) @@ -6644,41 +8269,23 @@ impl ::std::convert::From for ServerResult { Self::Result(value) } } -///A request from the client to the server, to enable or adjust logging. +///Specifies which request types can be augmented with tasks. /// ///
JSON schema /// /// ```json ///{ -/// "description": "A request from the client to the server, to enable or adjust logging.", +/// "description": "Specifies which request types can be augmented with tasks.", /// "type": "object", -/// "required": [ -/// "id", -/// "jsonrpc", -/// "method", -/// "params" -/// ], /// "properties": { -/// "id": { -/// "$ref": "#/definitions/RequestId" -/// }, -/// "jsonrpc": { -/// "type": "string", -/// "const": "2.0" -/// }, -/// "method": { -/// "type": "string", -/// "const": "logging/setLevel" -/// }, -/// "params": { +/// "tools": { +/// "description": "Task support for tool-related requests.", /// "type": "object", -/// "required": [ -/// "level" -/// ], /// "properties": { -/// "level": { -/// "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.", -/// "$ref": "#/definitions/LoggingLevel" +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true /// } /// } /// } @@ -6686,18 +8293,157 @@ impl ::std::convert::From for ServerResult { ///} /// ``` ///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct SetLevelRequest { - pub id: RequestId, - #[serde(deserialize_with = "validate::set_level_request_jsonrpc")] - jsonrpc: ::std::string::String, - #[serde(deserialize_with = "validate::set_level_request_method")] - method: ::std::string::String, - pub params: SetLevelRequestParams, +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerTaskRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub tools: ::std::option::Option, } -impl SetLevelRequest { - pub fn new(id: RequestId, params: SetLevelRequestParams) -> Self { - Self { +///Task support for tool-related requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerTaskTools { + ///Whether the server supports task-augmented tools/call requests. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub call: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Present if the server supports task-augmented requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Present if the server supports task-augmented requests.", +/// "type": "object", +/// "properties": { +/// "cancel": { +/// "description": "Whether this server supports tasks/cancel.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "list": { +/// "description": "Whether this server supports tasks/list.", +/// "type": "object", +/// "additionalProperties": true +/// }, +/// "requests": { +/// "description": "Specifies which request types can be augmented with tasks.", +/// "type": "object", +/// "properties": { +/// "tools": { +/// "description": "Task support for tool-related requests.", +/// "type": "object", +/// "properties": { +/// "call": { +/// "description": "Whether the server supports task-augmented tools/call requests.", +/// "type": "object", +/// "additionalProperties": true +/// } +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ServerTasks { + ///Whether this server supports tasks/cancel. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cancel: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Whether this server supports tasks/list. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub list: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub requests: ::std::option::Option, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct SetLevelMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///A request from the client to the server, to enable or adjust logging. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A request from the client to the server, to enable or adjust logging.", +/// "type": "object", +/// "required": [ +/// "id", +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "logging/setLevel" +/// }, +/// "params": { +/// "$ref": "#/$defs/SetLevelRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct SetLevelRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::set_level_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::set_level_request_method")] + method: ::std::string::String, + pub params: SetLevelRequestParams, +} +impl SetLevelRequest { + pub fn new(id: RequestId, params: SetLevelRequestParams) -> Self { + Self { id, jsonrpc: JSONRPC_VERSION.to_string(), method: "logging/setLevel".to_string(), @@ -6710,24 +8456,41 @@ impl SetLevelRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "logging/setLevel" + pub fn method_value() -> ::std::string::String { + "logging/setLevel".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "logging/setLevel".to_string() } } -///SetLevelRequestParams +///Parameters for a logging/setLevel request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a logging/setLevel request.", /// "type": "object", /// "required": [ /// "level" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "level": { /// "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.", -/// "$ref": "#/definitions/LoggingLevel" +/// "$ref": "#/$defs/LoggingLevel" /// } /// } ///} @@ -6737,6 +8500,41 @@ impl SetLevelRequest { pub struct SetLevelRequestParams { ///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. pub level: LoggingLevel, + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, +} +///SingleSelectEnumSchema +/// +///
JSON schema +/// +/// ```json +///{ +/// "anyOf": [ +/// { +/// "$ref": "#/$defs/UntitledSingleSelectEnumSchema" +/// }, +/// { +/// "$ref": "#/$defs/TitledSingleSelectEnumSchema" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +#[serde(untagged)] +pub enum SingleSelectEnumSchema { + UntitledSingleSelectEnumSchema(UntitledSingleSelectEnumSchema), + TitledSingleSelectEnumSchema(TitledSingleSelectEnumSchema), +} +impl ::std::convert::From for SingleSelectEnumSchema { + fn from(value: UntitledSingleSelectEnumSchema) -> Self { + Self::UntitledSingleSelectEnumSchema(value) + } +} +impl ::std::convert::From for SingleSelectEnumSchema { + fn from(value: TitledSingleSelectEnumSchema) -> Self { + Self::TitledSingleSelectEnumSchema(value) + } } ///StringSchema /// @@ -6820,6 +8618,11 @@ impl StringSchema { pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { "string".to_string() } @@ -6861,6 +8664,32 @@ impl ::std::fmt::Display for StringSchemaFormat { } } } +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct SubscribeMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} ///Sent from the client to request resources/updated notifications from the server whenever a particular resource changes. /// ///
JSON schema @@ -6877,7 +8706,7 @@ impl ::std::fmt::Display for StringSchemaFormat { /// ], /// "properties": { /// "id": { -/// "$ref": "#/definitions/RequestId" +/// "$ref": "#/$defs/RequestId" /// }, /// "jsonrpc": { /// "type": "string", @@ -6888,17 +8717,7 @@ impl ::std::fmt::Display for StringSchemaFormat { /// "const": "resources/subscribe" /// }, /// "params": { -/// "type": "object", -/// "required": [ -/// "uri" -/// ], -/// "properties": { -/// "uri": { -/// "description": "The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.", -/// "type": "string", -/// "format": "uri" -/// } -/// } +/// "$ref": "#/$defs/SubscribeRequestParams" /// } /// } ///} @@ -6928,23 +8747,40 @@ impl SubscribeRequest { pub fn method(&self) -> &::std::string::String { &self.method } + /// returns "resources/subscribe" + pub fn method_value() -> ::std::string::String { + "resources/subscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] pub fn method_name() -> ::std::string::String { "resources/subscribe".to_string() } } -///SubscribeRequestParams +///Parameters for a resources/subscribe request. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Parameters for a resources/subscribe request.", /// "type": "object", /// "required": [ /// "uri" /// ], /// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, /// "uri": { -/// "description": "The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.", +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", /// "type": "string", /// "format": "uri" /// } @@ -6954,91 +8790,408 @@ impl SubscribeRequest { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct SubscribeRequestParams { - ///The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. pub uri: ::std::string::String, } -///Text provided to or from an LLM. +///Data associated with a task. /// ///
JSON schema /// /// ```json ///{ -/// "description": "Text provided to or from an LLM.", +/// "description": "Data associated with a task.", /// "type": "object", /// "required": [ -/// "text", -/// "type" +/// "createdAt", +/// "lastUpdatedAt", +/// "status", +/// "taskId", +/// "ttl" /// ], /// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} +/// "createdAt": { +/// "description": "ISO 8601 timestamp when the task was created.", +/// "type": "string" /// }, -/// "annotations": { -/// "description": "Optional annotations for the client.", -/// "$ref": "#/definitions/Annotations" +/// "lastUpdatedAt": { +/// "description": "ISO 8601 timestamp when the task was last updated.", +/// "type": "string" /// }, -/// "text": { -/// "description": "The text content of the message.", +/// "pollInterval": { +/// "description": "Suggested polling interval in milliseconds.", +/// "type": "integer" +/// }, +/// "status": { +/// "$ref": "#/$defs/TaskStatus" +/// }, +/// "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" /// }, -/// "type": { -/// "type": "string", -/// "const": "text" +/// "taskId": { +/// "description": "The task identifier.", +/// "type": "string" +/// }, +/// "ttl": { +/// "description": "Actual retention duration from creation in milliseconds, null for unlimited.", +/// "type": "integer" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct TextContent { - ///Optional annotations for the client. - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub annotations: ::std::option::Option, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - ///The text content of the message. - pub text: ::std::string::String, - #[serde(rename = "type", deserialize_with = "validate::text_content_type_")] - type_: ::std::string::String, -} -impl TextContent { - pub fn new( - text: ::std::string::String, - annotations: ::std::option::Option, - meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - ) -> Self { - Self { - annotations, - meta, - text, - type_: "text".to_string(), - } - } - pub fn type_(&self) -> &::std::string::String { - &self.type_ - } - pub fn type_name() -> ::std::string::String { - "text".to_string() - } -} -///TextResourceContents -/// -///
JSON schema -/// -/// ```json -///{ +pub struct Task { + ///ISO 8601 timestamp when the task was created. + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + ///ISO 8601 timestamp when the task was last updated. + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///Suggested polling interval in milliseconds. + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + /**Optional human-readable message describing the current task state. + This can provide context for any status, including: + - Reasons for "cancelled" status + - Summaries for "completed" status + - Diagnostic information for "failed" status (e.g., error details, what went wrong)*/ + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + ///The task identifier. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + ///Actual retention duration from creation in milliseconds, null for unlimited. + pub ttl: i64, +} +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", -/// "required": [ -/// "text", -/// "uri" -/// ], /// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct TaskAugmentedMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Common params for any task-augmented request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Common params for any task-augmented request.", +/// "type": "object", +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +/// }, +/// "task": { +/// "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.", +/// "$ref": "#/$defs/TaskMetadata" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct TaskAugmentedRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + /**If specified, the caller is requesting task-augmented execution for this request. + The request will return a CreateTaskResult immediately, and the actual result can be + retrieved later via tasks/result. + Task augmentation is subject to capability negotiation - receivers MUST declare support + for task augmentation of specific request types in their capabilities.*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, +} +/**Metadata for augmenting a request with task execution. +Include this in the task field of the request parameters.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Metadata for augmenting a request with task execution.\nInclude this in the task field of the request parameters.", +/// "type": "object", +/// "properties": { +/// "ttl": { +/// "description": "Requested duration in milliseconds to retain task from creation.", +/// "type": "integer" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct TaskMetadata { + ///Requested duration in milliseconds to retain task from creation. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ttl: ::std::option::Option, +} +///The status of a task. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The status of a task.", +/// "type": "string", +/// "enum": [ +/// "cancelled", +/// "completed", +/// "failed", +/// "input_required", +/// "working" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum TaskStatus { + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "completed")] + Completed, + #[serde(rename = "failed")] + Failed, + #[serde(rename = "input_required")] + InputRequired, + #[serde(rename = "working")] + Working, +} +impl ::std::fmt::Display for TaskStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Cancelled => write!(f, "cancelled"), + Self::Completed => write!(f, "completed"), + Self::Failed => write!(f, "failed"), + Self::InputRequired => write!(f, "input_required"), + Self::Working => write!(f, "working"), + } + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method", +/// "params" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/tasks/status" +/// }, +/// "params": { +/// "$ref": "#/$defs/TaskStatusNotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TaskStatusNotification { + #[serde(deserialize_with = "validate::task_status_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::task_status_notification_method")] + method: ::std::string::String, + pub params: TaskStatusNotificationParams, +} +impl TaskStatusNotification { + pub fn new(params: TaskStatusNotificationParams) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/tasks/status".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/tasks/status" + pub fn method_value() -> ::std::string::String { + "notifications/tasks/status".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/tasks/status".to_string() + } +} +///Parameters for a notifications/tasks/status notification. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a notifications/tasks/status notification.", +/// "allOf": [ +/// { +/// "$ref": "#/$defs/NotificationParams" +/// }, +/// { +/// "$ref": "#/$defs/Task" +/// } +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TaskStatusNotificationParams { + ///ISO 8601 timestamp when the task was created. + #[serde(rename = "createdAt")] + pub created_at: ::std::string::String, + ///ISO 8601 timestamp when the task was last updated. + #[serde(rename = "lastUpdatedAt")] + pub last_updated_at: ::std::string::String, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///Suggested polling interval in milliseconds. + #[serde(rename = "pollInterval", default, skip_serializing_if = "::std::option::Option::is_none")] + pub poll_interval: ::std::option::Option, + pub status: TaskStatus, + /**Optional human-readable message describing the current task state. + This can provide context for any status, including: + - Reasons for "cancelled" status + - Summaries for "completed" status + - Diagnostic information for "failed" status (e.g., error details, what went wrong)*/ + #[serde(rename = "statusMessage", default, skip_serializing_if = "::std::option::Option::is_none")] + pub status_message: ::std::option::Option<::std::string::String>, + ///The task identifier. + #[serde(rename = "taskId")] + pub task_id: ::std::string::String, + ///Actual retention duration from creation in milliseconds, null for unlimited. + pub ttl: i64, +} +///Text provided to or from an LLM. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Text provided to or from an LLM.", +/// "type": "object", +/// "required": [ +/// "text", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional annotations for the client.", +/// "$ref": "#/$defs/Annotations" +/// }, +/// "text": { +/// "description": "The text content of the message.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "text" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TextContent { + ///Optional annotations for the client. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub annotations: ::std::option::Option, + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The text content of the message. + pub text: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::text_content_type_")] + type_: ::std::string::String, +} +impl TextContent { + pub fn new( + text: ::std::string::String, + annotations: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + annotations, + meta, + text, + type_: "text".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "text" + pub fn type_value() -> ::std::string::String { + "text".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "text".to_string() + } +} +///TextResourceContents +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "text", +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", /// "additionalProperties": {} /// }, /// "mimeType": { @@ -7060,7 +9213,7 @@ impl TextContent { ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] pub struct TextResourceContents { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///The MIME type of this resource, if known. @@ -7071,59 +9224,397 @@ pub struct TextResourceContents { ///The URI of this resource. pub uri: ::std::string::String, } -///Definition for a tool the client can call. +///Schema for multiple-selection enumeration with display titles for each option. /// ///
JSON schema /// /// ```json ///{ -/// "description": "Definition for a tool the client can call.", +/// "description": "Schema for multiple-selection enumeration with display titles for each option.", /// "type": "object", /// "required": [ -/// "inputSchema", -/// "name" +/// "items", +/// "type" /// ], /// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} -/// }, -/// "annotations": { -/// "description": "Optional additional tool information.\n\nDisplay name precedence order is: title, annotations.title, then name.", -/// "$ref": "#/definitions/ToolAnnotations" -/// }, -/// "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" -/// }, -/// "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)", +/// "default": { +/// "description": "Optional default value.", /// "type": "array", /// "items": { -/// "$ref": "#/definitions/Icon" +/// "type": "string" /// } /// }, -/// "inputSchema": { -/// "description": "A JSON Schema object defining the expected parameters for the tool.", +/// "description": { +/// "description": "Optional description for the enum field.", +/// "type": "string" +/// }, +/// "items": { +/// "description": "Schema for array items with enum options and display labels.", /// "type": "object", /// "required": [ -/// "type" +/// "anyOf" /// ], /// "properties": { -/// "properties": { -/// "type": "object", -/// "additionalProperties": { -/// "type": "object", -/// "additionalProperties": true -/// } -/// }, -/// "required": { +/// "anyOf": { +/// "description": "Array of enum options with values and display labels.", /// "type": "array", /// "items": { -/// "type": "string" +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The constant enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display title for this option.", +/// "type": "string" +/// } +/// } /// } -/// }, +/// } +/// } +/// }, +/// "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": { +/// "type": "string", +/// "const": "array" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledMultiSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub default: ::std::vec::Vec<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub items: TitledMultiSelectEnumSchemaItems, + ///Maximum number of items to select. + #[serde(rename = "maxItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub max_items: ::std::option::Option, + ///Minimum number of items to select. + #[serde(rename = "minItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub min_items: ::std::option::Option, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::titled_multi_select_enum_schema_type_")] + type_: ::std::string::String, +} +impl TitledMultiSelectEnumSchema { + pub fn new( + default: ::std::vec::Vec<::std::string::String>, + items: TitledMultiSelectEnumSchemaItems, + description: ::std::option::Option<::std::string::String>, + max_items: ::std::option::Option, + min_items: ::std::option::Option, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + items, + max_items, + min_items, + title, + type_: "array".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "array" + pub fn type_value() -> ::std::string::String { + "array".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "array".to_string() + } +} +///Schema for array items with enum options and display labels. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for array items with enum options and display labels.", +/// "type": "object", +/// "required": [ +/// "anyOf" +/// ], +/// "properties": { +/// "anyOf": { +/// "description": "Array of enum options with values and display labels.", +/// "type": "array", +/// "items": { +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The constant enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display title for this option.", +/// "type": "string" +/// } +/// } +/// } +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledMultiSelectEnumSchemaItems { + ///Array of enum options with values and display labels. + #[serde(rename = "anyOf")] + pub any_of: ::std::vec::Vec, +} +///TitledMultiSelectEnumSchemaItemsAnyOfItem +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The constant enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display title for this option.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledMultiSelectEnumSchemaItemsAnyOfItem { + ///The constant enum value. + #[serde(rename = "const")] + pub const_: ::std::string::String, + ///Display title for this option. + pub title: ::std::string::String, +} +///Schema for single-selection enumeration with display titles for each option. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for single-selection enumeration with display titles for each option.", +/// "type": "object", +/// "required": [ +/// "oneOf", +/// "type" +/// ], +/// "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.", +/// "type": "array", +/// "items": { +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display label for this option.", +/// "type": "string" +/// } +/// } +/// } +/// }, +/// "title": { +/// "description": "Optional title for the enum field.", +/// "type": "string" +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledSingleSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub default: ::std::option::Option<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + ///Array of enum options with values and display labels. + #[serde(rename = "oneOf")] + pub one_of: ::std::vec::Vec, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::titled_single_select_enum_schema_type_")] + type_: ::std::string::String, +} +impl TitledSingleSelectEnumSchema { + pub fn new( + one_of: ::std::vec::Vec, + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + default, + description, + one_of, + title, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///TitledSingleSelectEnumSchemaOneOfItem +/// +///
JSON schema +/// +/// ```json +///{ +/// "type": "object", +/// "required": [ +/// "const", +/// "title" +/// ], +/// "properties": { +/// "const": { +/// "description": "The enum value.", +/// "type": "string" +/// }, +/// "title": { +/// "description": "Display label for this option.", +/// "type": "string" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct TitledSingleSelectEnumSchemaOneOfItem { + ///The enum value. + #[serde(rename = "const")] + pub const_: ::std::string::String, + ///Display label for this option. + pub title: ::std::string::String, +} +///Definition for a tool the client can call. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Definition for a tool the client can call.", +/// "type": "object", +/// "required": [ +/// "inputSchema", +/// "name" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "annotations": { +/// "description": "Optional additional tool information.\n\nDisplay name precedence order is: title, annotations.title, then name.", +/// "$ref": "#/$defs/ToolAnnotations" +/// }, +/// "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": { +/// "description": "Execution-related properties for this tool.", +/// "$ref": "#/$defs/ToolExecution" +/// }, +/// "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)", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/Icon" +/// } +/// }, +/// "inputSchema": { +/// "description": "A JSON Schema object defining the expected parameters for the tool.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, /// "type": { /// "type": "string", /// "const": "object" @@ -7135,12 +9626,15 @@ pub struct TextResourceContents { /// "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.", +/// "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.", /// "type": "object", /// "required": [ /// "type" /// ], /// "properties": { +/// "$schema": { +/// "type": "string" +/// }, /// "properties": { /// "type": "object", /// "additionalProperties": { @@ -7178,6 +9672,9 @@ pub struct Tool { This 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.*/ #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub description: ::std::option::Option<::std::string::String>, + ///Execution-related properties for this tool. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub execution: ::std::option::Option, /**Optional set of sized icons that the client can display in a user interface. Clients that support rendering icons MUST support at least the following MIME types: - image/png - PNG images (safe, universal compatibility) @@ -7189,7 +9686,7 @@ pub struct Tool { pub icons: ::std::vec::Vec, #[serde(rename = "inputSchema")] pub input_schema: ToolInputSchema, - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. + ///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ///Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). @@ -7265,308 +9762,1027 @@ pub struct ToolAnnotations { pub open_world_hint: ::std::option::Option, /**If true, the tool does not modify its environment. Default: false*/ - #[serde(rename = "readOnlyHint", default, skip_serializing_if = "::std::option::Option::is_none")] - pub read_only_hint: ::std::option::Option, - ///A human-readable title for the tool. - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "readOnlyHint", default, skip_serializing_if = "::std::option::Option::is_none")] + pub read_only_hint: ::std::option::Option, + ///A human-readable title for the tool. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, +} +///Controls tool selection behavior for sampling requests. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Controls tool selection behavior for sampling requests.", +/// "type": "object", +/// "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", +/// "type": "string", +/// "enum": [ +/// "auto", +/// "none", +/// "required" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ToolChoice { + /**Controls the tool use ability of the model: + - "auto": Model decides whether to use tools (default) + - "required": Model MUST use at least one tool before completing + - "none": Model MUST NOT use any tools*/ + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub mode: ::std::option::Option, +} +/**Controls the tool use ability of the model: +- "auto": Model decides whether to use tools (default) +- "required": Model MUST use at least one tool before completing +- "none": Model MUST NOT use any tools*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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", +/// "type": "string", +/// "enum": [ +/// "auto", +/// "none", +/// "required" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum ToolChoiceMode { + #[serde(rename = "auto")] + Auto, + #[serde(rename = "none")] + None, + #[serde(rename = "required")] + Required, +} +impl ::std::fmt::Display for ToolChoiceMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Auto => write!(f, "auto"), + Self::None => write!(f, "none"), + Self::Required => write!(f, "required"), + } + } +} +///Execution-related properties for a tool. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Execution-related properties for a tool.", +/// "type": "object", +/// "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\"", +/// "type": "string", +/// "enum": [ +/// "forbidden", +/// "optional", +/// "required" +/// ] +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct ToolExecution { + /**Indicates whether this tool supports task-augmented execution. + This allows clients to handle long-running operations through polling + the task system. + - "forbidden": Tool does not support task-augmented execution (default when absent) + - "optional": Tool may support task-augmented execution + - "required": Tool requires task-augmented execution + "*/ + #[serde(rename = "taskSupport", default, skip_serializing_if = "::std::option::Option::is_none")] + pub task_support: ::std::option::Option, +} +/**Indicates whether this tool supports task-augmented execution. +This allows clients to handle long-running operations through polling +the task system. +- "forbidden": Tool does not support task-augmented execution (default when absent) +- "optional": Tool may support task-augmented execution +- "required": Tool requires task-augmented execution + "*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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\"", +/// "type": "string", +/// "enum": [ +/// "forbidden", +/// "optional", +/// "required" +/// ] +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub enum ToolExecutionTaskSupport { + #[serde(rename = "forbidden")] + Forbidden, + #[serde(rename = "optional")] + Optional, + #[serde(rename = "required")] + Required, +} +impl ::std::fmt::Display for ToolExecutionTaskSupport { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Forbidden => write!(f, "forbidden"), + Self::Optional => write!(f, "optional"), + Self::Required => write!(f, "required"), + } + } +} +///A JSON Schema object defining the expected parameters for the tool. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "A JSON Schema object defining the expected parameters for the tool.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolInputSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub properties: ::std::option::Option< + ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, + >, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub required: ::std::vec::Vec<::std::string::String>, + #[serde(rename = "$schema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub schema: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::tool_input_schema_type_")] + type_: ::std::string::String, +} +impl ToolInputSchema { + pub fn new( + required: ::std::vec::Vec<::std::string::String>, + properties: ::std::option::Option< + ::std::collections::HashMap< + ::std::string::String, + ::serde_json::Map<::std::string::String, ::serde_json::Value>, + >, + >, + schema: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + properties, + required, + schema, + type_: "object".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "object".to_string() + } +} +///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. +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "jsonrpc", +/// "method" +/// ], +/// "properties": { +/// "jsonrpc": { +/// "type": "string", +/// "const": "2.0" +/// }, +/// "method": { +/// "type": "string", +/// "const": "notifications/tools/list_changed" +/// }, +/// "params": { +/// "$ref": "#/$defs/NotificationParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolListChangedNotification { + #[serde(deserialize_with = "validate::tool_list_changed_notification_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::tool_list_changed_notification_method")] + method: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub params: ::std::option::Option, +} +impl ToolListChangedNotification { + pub fn new(params: ::std::option::Option) -> Self { + Self { + jsonrpc: JSONRPC_VERSION.to_string(), + method: "notifications/tools/list_changed".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "notifications/tools/list_changed" + pub fn method_value() -> ::std::string::String { + "notifications/tools/list_changed".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "notifications/tools/list_changed".to_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.*/ +/// +///
JSON schema +/// +/// ```json +///{ +/// "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.", +/// "type": "object", +/// "required": [ +/// "type" +/// ], +/// "properties": { +/// "$schema": { +/// "type": "string" +/// }, +/// "properties": { +/// "type": "object", +/// "additionalProperties": { +/// "type": "object", +/// "additionalProperties": true +/// } +/// }, +/// "required": { +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "object" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolOutputSchema { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub properties: ::std::option::Option< + ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, + >, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub required: ::std::vec::Vec<::std::string::String>, + #[serde(rename = "$schema", default, skip_serializing_if = "::std::option::Option::is_none")] + pub schema: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::tool_output_schema_type_")] + type_: ::std::string::String, +} +impl ToolOutputSchema { + pub fn new( + required: ::std::vec::Vec<::std::string::String>, + properties: ::std::option::Option< + ::std::collections::HashMap< + ::std::string::String, + ::serde_json::Map<::std::string::String, ::serde_json::Value>, + >, + >, + schema: ::std::option::Option<::std::string::String>, + ) -> Self { + Self { + properties, + required, + schema, + type_: "object".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "object" + pub fn type_value() -> ::std::string::String { + "object".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "object".to_string() + } +} +///The result of a tool use, provided by the user back to the assistant. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "The result of a tool use, provided by the user back to the assistant.", +/// "type": "object", +/// "required": [ +/// "content", +/// "toolUseId", +/// "type" +/// ], +/// "properties": { +/// "_meta": { +/// "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](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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.", +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ContentBlock" +/// } +/// }, +/// "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": { +/// "description": "An optional structured result object.\n\nIf the tool defined an outputSchema, this SHOULD conform to that schema.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "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": { +/// "type": "string", +/// "const": "tool_result" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct ToolResultContent { + /**The unstructured result content of the tool use. + This has the same format as CallToolResult.content and can include text, images, + audio, resource links, and embedded resources.*/ + pub content: ::std::vec::Vec, + /**Whether the tool use resulted in an error. + If true, the content typically describes the error that occurred. + Default: false*/ + #[serde(rename = "isError", default, skip_serializing_if = "::std::option::Option::is_none")] + pub is_error: ::std::option::Option, + /**Optional metadata about the tool result. Clients SHOULD preserve this field when + including tool results in subsequent sampling requests to enable caching optimizations. + See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.*/ + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**An optional structured result object. + If the tool defined an outputSchema, this SHOULD conform to that schema.*/ + #[serde( + rename = "structuredContent", + default, + skip_serializing_if = "::std::option::Option::is_none" + )] + pub structured_content: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + /**The ID of the tool use this result corresponds to. + This MUST match the ID from a previous ToolUseContent.*/ + #[serde(rename = "toolUseId")] + pub tool_use_id: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::tool_result_content_type_")] + type_: ::std::string::String, } -///A JSON Schema object defining the expected parameters for the tool. +impl ToolResultContent { + pub fn new( + content: ::std::vec::Vec, + tool_use_id: ::std::string::String, + is_error: ::std::option::Option, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + structured_content: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ) -> Self { + Self { + content, + is_error, + meta, + structured_content, + tool_use_id, + type_: "tool_result".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "tool_result" + pub fn type_value() -> ::std::string::String { + "tool_result".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "tool_result".to_string() + } +} +///A request from the assistant to call a tool. /// ///
JSON schema /// /// ```json ///{ -/// "description": "A JSON Schema object defining the expected parameters for the tool.", +/// "description": "A request from the assistant to call a tool.", /// "type": "object", /// "required": [ +/// "id", +/// "input", +/// "name", /// "type" /// ], /// "properties": { -/// "properties": { +/// "_meta": { +/// "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](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", -/// "additionalProperties": { -/// "type": "object", -/// "additionalProperties": true -/// } +/// "additionalProperties": {} /// }, -/// "required": { -/// "type": "array", -/// "items": { -/// "type": "string" -/// } +/// "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": { +/// "description": "The arguments to pass to the tool, conforming to the tool's input schema.", +/// "type": "object", +/// "additionalProperties": {} +/// }, +/// "name": { +/// "description": "The name of the tool to call.", +/// "type": "string" /// }, /// "type": { /// "type": "string", -/// "const": "object" +/// "const": "tool_use" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ToolInputSchema { - #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub properties: ::std::option::Option< - ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, - >, - #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] - pub required: ::std::vec::Vec<::std::string::String>, - #[serde(rename = "type", deserialize_with = "validate::tool_input_schema_type_")] +pub struct ToolUseContent { + /**A unique identifier for this tool use. + This ID is used to match tool results to their corresponding tool uses.*/ + pub id: ::std::string::String, + ///The arguments to pass to the tool, conforming to the tool's input schema. + pub input: ::serde_json::Map<::std::string::String, ::serde_json::Value>, + /**Optional metadata about the tool use. Clients SHOULD preserve this field when + including tool uses in subsequent sampling requests to enable caching optimizations. + See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.*/ + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, + ///The name of the tool to call. + pub name: ::std::string::String, + #[serde(rename = "type", deserialize_with = "validate::tool_use_content_type_")] type_: ::std::string::String, } -impl ToolInputSchema { +impl ToolUseContent { pub fn new( - required: ::std::vec::Vec<::std::string::String>, - properties: ::std::option::Option< - ::std::collections::HashMap< - ::std::string::String, - ::serde_json::Map<::std::string::String, ::serde_json::Value>, - >, - >, + id: ::std::string::String, + input: ::serde_json::Map<::std::string::String, ::serde_json::Value>, + name: ::std::string::String, + meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, ) -> Self { Self { - properties, - required, - type_: "object".to_string(), + id, + input, + meta, + name, + type_: "tool_use".to_string(), } } pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "tool_use" + pub fn type_value() -> ::std::string::String { + "tool_use".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { - "object".to_string() + "tool_use".to_string() } } -///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. +///See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage. /// ///
JSON schema /// /// ```json ///{ -/// "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.", +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", +/// "type": "object", +/// "properties": { +/// "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.", +/// "$ref": "#/$defs/ProgressToken" +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] +pub struct UnsubscribeMeta { + ///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. + #[serde(rename = "progressToken", default, skip_serializing_if = "::std::option::Option::is_none")] + pub progress_token: ::std::option::Option, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.", /// "type": "object", /// "required": [ +/// "id", /// "jsonrpc", -/// "method" +/// "method", +/// "params" /// ], /// "properties": { +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, /// "jsonrpc": { /// "type": "string", /// "const": "2.0" /// }, /// "method": { /// "type": "string", -/// "const": "notifications/tools/list_changed" +/// "const": "resources/unsubscribe" /// }, /// "params": { +/// "$ref": "#/$defs/UnsubscribeRequestParams" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UnsubscribeRequest { + pub id: RequestId, + #[serde(deserialize_with = "validate::unsubscribe_request_jsonrpc")] + jsonrpc: ::std::string::String, + #[serde(deserialize_with = "validate::unsubscribe_request_method")] + method: ::std::string::String, + pub params: UnsubscribeRequestParams, +} +impl UnsubscribeRequest { + pub fn new(id: RequestId, params: UnsubscribeRequestParams) -> Self { + Self { + id, + jsonrpc: JSONRPC_VERSION.to_string(), + method: "resources/unsubscribe".to_string(), + params, + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } + pub fn method(&self) -> &::std::string::String { + &self.method + } + /// returns "resources/unsubscribe" + pub fn method_value() -> ::std::string::String { + "resources/unsubscribe".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `method_value()` instead.")] + pub fn method_name() -> ::std::string::String { + "resources/unsubscribe".to_string() + } +} +///Parameters for a resources/unsubscribe request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Parameters for a resources/unsubscribe request.", +/// "type": "object", +/// "required": [ +/// "uri" +/// ], +/// "properties": { +/// "_meta": { +/// "description": "See [General fields: _meta](https://modelcontextprotocol.io/specification/draft/basic/index#meta) for notes on _meta usage.", /// "type": "object", /// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} +/// "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.", +/// "$ref": "#/$defs/ProgressToken" /// } /// }, /// "additionalProperties": {} +/// }, +/// "uri": { +/// "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", +/// "type": "string", +/// "format": "uri" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ToolListChangedNotification { - #[serde(deserialize_with = "validate::tool_list_changed_notification_jsonrpc")] - jsonrpc: ::std::string::String, - #[serde(deserialize_with = "validate::tool_list_changed_notification_method")] - method: ::std::string::String, +pub struct UnsubscribeRequestParams { + #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] + pub meta: ::std::option::Option, + ///The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + pub uri: ::std::string::String, +} +///Schema for multiple-selection enumeration without display titles for options. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "Schema for multiple-selection enumeration without display titles for options.", +/// "type": "object", +/// "required": [ +/// "items", +/// "type" +/// ], +/// "properties": { +/// "default": { +/// "description": "Optional default value.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "description": { +/// "description": "Optional description for the enum field.", +/// "type": "string" +/// }, +/// "items": { +/// "description": "Schema for the array items.", +/// "type": "object", +/// "required": [ +/// "enum", +/// "type" +/// ], +/// "properties": { +/// "enum": { +/// "description": "Array of enum values to choose from.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" +/// } +/// } +/// }, +/// "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": { +/// "type": "string", +/// "const": "array" +/// } +/// } +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UntitledMultiSelectEnumSchema { + ///Optional default value. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub default: ::std::vec::Vec<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub items: UntitledMultiSelectEnumSchemaItems, + ///Maximum number of items to select. + #[serde(rename = "maxItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub max_items: ::std::option::Option, + ///Minimum number of items to select. + #[serde(rename = "minItems", default, skip_serializing_if = "::std::option::Option::is_none")] + pub min_items: ::std::option::Option, + ///Optional title for the enum field. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub params: ::std::option::Option, + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::untitled_multi_select_enum_schema_type_")] + type_: ::std::string::String, } -impl ToolListChangedNotification { - pub fn new(params: ::std::option::Option) -> Self { +impl UntitledMultiSelectEnumSchema { + pub fn new( + default: ::std::vec::Vec<::std::string::String>, + items: UntitledMultiSelectEnumSchemaItems, + description: ::std::option::Option<::std::string::String>, + max_items: ::std::option::Option, + min_items: ::std::option::Option, + title: ::std::option::Option<::std::string::String>, + ) -> Self { Self { - jsonrpc: JSONRPC_VERSION.to_string(), - method: "notifications/tools/list_changed".to_string(), - params, + default, + description, + items, + max_items, + min_items, + title, + type_: "array".to_string(), } } - pub fn jsonrpc(&self) -> &::std::string::String { - &self.jsonrpc + pub fn type_(&self) -> &::std::string::String { + &self.type_ } - pub fn method(&self) -> &::std::string::String { - &self.method + /// returns "array" + pub fn type_value() -> ::std::string::String { + "array".to_string() } - pub fn method_name() -> ::std::string::String { - "notifications/tools/list_changed".to_string() + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "array".to_string() } } -///ToolListChangedNotificationParams +///Schema for the array items. /// ///
JSON schema /// /// ```json ///{ +/// "description": "Schema for the array items.", /// "type": "object", +/// "required": [ +/// "enum", +/// "type" +/// ], /// "properties": { -/// "_meta": { -/// "description": "See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage.", -/// "type": "object", -/// "additionalProperties": {} +/// "enum": { +/// "description": "Array of enum values to choose from.", +/// "type": "array", +/// "items": { +/// "type": "string" +/// } +/// }, +/// "type": { +/// "type": "string", +/// "const": "string" /// } -/// }, -/// "additionalProperties": {} +/// } ///} /// ``` ///
-#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)] -pub struct ToolListChangedNotificationParams { - ///See [General fields: _meta](/specification/draft/basic/index#meta) for notes on _meta usage. - #[serde(rename = "_meta", default, skip_serializing_if = "::std::option::Option::is_none")] - pub meta: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, - #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] - pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UntitledMultiSelectEnumSchemaItems { + ///Array of enum values to choose from. + #[serde(rename = "enum")] + pub enum_: ::std::vec::Vec<::std::string::String>, + #[serde( + rename = "type", + deserialize_with = "validate::untitled_multi_select_enum_schema_items_type_" + )] + type_: ::std::string::String, } -/**An optional JSON Schema object defining the structure of the tool's output returned in -the structuredContent field of a CallToolResult.*/ +impl UntitledMultiSelectEnumSchemaItems { + pub fn new(enum_: ::std::vec::Vec<::std::string::String>) -> Self { + Self { + enum_, + type_: "string".to_string(), + } + } + pub fn type_(&self) -> &::std::string::String { + &self.type_ + } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] + pub fn type_name() -> ::std::string::String { + "string".to_string() + } +} +///Schema for single-selection enumeration without display titles for options. /// ///
JSON schema /// /// ```json ///{ -/// "description": "An optional JSON Schema object defining the structure of the tool's output returned in\nthe structuredContent field of a CallToolResult.", +/// "description": "Schema for single-selection enumeration without display titles for options.", /// "type": "object", /// "required": [ +/// "enum", /// "type" /// ], /// "properties": { -/// "properties": { -/// "type": "object", -/// "additionalProperties": { -/// "type": "object", -/// "additionalProperties": true -/// } +/// "default": { +/// "description": "Optional default value.", +/// "type": "string" /// }, -/// "required": { +/// "description": { +/// "description": "Optional description for the enum field.", +/// "type": "string" +/// }, +/// "enum": { +/// "description": "Array of enum values to choose from.", /// "type": "array", /// "items": { /// "type": "string" /// } /// }, +/// "title": { +/// "description": "Optional title for the enum field.", +/// "type": "string" +/// }, /// "type": { /// "type": "string", -/// "const": "object" +/// "const": "string" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct ToolOutputSchema { +pub struct UntitledSingleSelectEnumSchema { + ///Optional default value. #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub properties: ::std::option::Option< - ::std::collections::HashMap<::std::string::String, ::serde_json::Map<::std::string::String, ::serde_json::Value>>, - >, - #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] - pub required: ::std::vec::Vec<::std::string::String>, - #[serde(rename = "type", deserialize_with = "validate::tool_output_schema_type_")] + pub default: ::std::option::Option<::std::string::String>, + ///Optional description for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + ///Array of enum values to choose from. + #[serde(rename = "enum")] + pub enum_: ::std::vec::Vec<::std::string::String>, + ///Optional title for the enum field. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub title: ::std::option::Option<::std::string::String>, + #[serde(rename = "type", deserialize_with = "validate::untitled_single_select_enum_schema_type_")] type_: ::std::string::String, } -impl ToolOutputSchema { +impl UntitledSingleSelectEnumSchema { pub fn new( - required: ::std::vec::Vec<::std::string::String>, - properties: ::std::option::Option< - ::std::collections::HashMap< - ::std::string::String, - ::serde_json::Map<::std::string::String, ::serde_json::Value>, - >, - >, + enum_: ::std::vec::Vec<::std::string::String>, + default: ::std::option::Option<::std::string::String>, + description: ::std::option::Option<::std::string::String>, + title: ::std::option::Option<::std::string::String>, ) -> Self { Self { - properties, - required, - type_: "object".to_string(), + default, + description, + enum_, + title, + type_: "string".to_string(), } } pub fn type_(&self) -> &::std::string::String { &self.type_ } + /// returns "string" + pub fn type_value() -> ::std::string::String { + "string".to_string() + } + #[deprecated(since = "0.8.0", note = "Use `type_value()` instead.")] pub fn type_name() -> ::std::string::String { - "object".to_string() + "string".to_string() } } -///Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request. +///UrlElicitError /// ///
JSON schema /// /// ```json ///{ -/// "description": "Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.", -/// "type": "object", -/// "required": [ -/// "id", -/// "jsonrpc", -/// "method", -/// "params" -/// ], -/// "properties": { -/// "id": { -/// "$ref": "#/definitions/RequestId" -/// }, -/// "jsonrpc": { -/// "type": "string", -/// "const": "2.0" -/// }, -/// "method": { -/// "type": "string", -/// "const": "resources/unsubscribe" +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Error" /// }, -/// "params": { +/// { /// "type": "object", /// "required": [ -/// "uri" +/// "code", +/// "data" /// ], /// "properties": { -/// "uri": { -/// "description": "The URI of the resource to unsubscribe from.", -/// "type": "string", -/// "format": "uri" +/// "code": { +/// "type": "integer" +/// }, +/// "data": { +/// "type": "object", +/// "required": [ +/// "elicitations" +/// ], +/// "properties": { +/// "elicitations": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// } +/// } +/// }, +/// "additionalProperties": {} /// } /// } /// } -/// } +/// ] ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct UnsubscribeRequest { - pub id: RequestId, - #[serde(deserialize_with = "validate::unsubscribe_request_jsonrpc")] - jsonrpc: ::std::string::String, - #[serde(deserialize_with = "validate::unsubscribe_request_method")] - method: ::std::string::String, - pub params: UnsubscribeRequestParams, +pub struct UrlElicitError { + #[serde(deserialize_with = "validate::url_elicit_error_code")] + code: i64, + pub data: UrlElicitErrorData, + ///A short description of the error. The message SHOULD be limited to a concise single sentence. + pub message: ::std::string::String, } -impl UnsubscribeRequest { - pub fn new(id: RequestId, params: UnsubscribeRequestParams) -> Self { +impl UrlElicitError { + pub fn new(data: UrlElicitErrorData, message: ::std::string::String) -> Self { Self { - id, - jsonrpc: JSONRPC_VERSION.to_string(), - method: "resources/unsubscribe".to_string(), - params, + code: -32042i64, + data, + message, } } - pub fn jsonrpc(&self) -> &::std::string::String { - &self.jsonrpc + pub fn code(&self) -> &i64 { + &self.code } - pub fn method(&self) -> &::std::string::String { - &self.method + /// returns -32042i64 + pub fn code_value() -> i64 { + -32042i64 } - pub fn method_name() -> ::std::string::String { - "resources/unsubscribe".to_string() + #[deprecated(since = "0.8.0", note = "Use `code_value()` instead.")] + pub fn code_name() -> i64 { + -32042i64 } } -///UnsubscribeRequestParams +///UrlElicitErrorData /// ///
JSON schema /// @@ -7574,22 +10790,103 @@ impl UnsubscribeRequest { ///{ /// "type": "object", /// "required": [ -/// "uri" +/// "elicitations" /// ], /// "properties": { -/// "uri": { -/// "description": "The URI of the resource to unsubscribe from.", +/// "elicitations": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// } +/// } +/// }, +/// "additionalProperties": {} +///} +/// ``` +///
+#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] +pub struct UrlElicitErrorData { + pub elicitations: ::std::vec::Vec, + #[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")] + pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>, +} +///An error response that indicates that the server requires the client to provide additional information via an elicitation request. +/// +///
JSON schema +/// +/// ```json +///{ +/// "description": "An error response that indicates that the server requires the client to provide additional information via an elicitation request.", +/// "type": "object", +/// "required": [ +/// "error", +/// "jsonrpc" +/// ], +/// "properties": { +/// "error": { +/// "allOf": [ +/// { +/// "$ref": "#/$defs/Error" +/// }, +/// { +/// "type": "object", +/// "required": [ +/// "code", +/// "data" +/// ], +/// "properties": { +/// "code": { +/// "type": "integer" +/// }, +/// "data": { +/// "type": "object", +/// "required": [ +/// "elicitations" +/// ], +/// "properties": { +/// "elicitations": { +/// "type": "array", +/// "items": { +/// "$ref": "#/$defs/ElicitRequestURLParams" +/// } +/// } +/// }, +/// "additionalProperties": {} +/// } +/// } +/// } +/// ] +/// }, +/// "id": { +/// "$ref": "#/$defs/RequestId" +/// }, +/// "jsonrpc": { /// "type": "string", -/// "format": "uri" +/// "const": "2.0" /// } /// } ///} /// ``` ///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)] -pub struct UnsubscribeRequestParams { - ///The URI of the resource to unsubscribe from. - pub uri: ::std::string::String, +pub struct UrlElicitationRequiredError { + pub error: UrlElicitError, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub id: ::std::option::Option, + #[serde(deserialize_with = "validate::url_elicitation_required_error_jsonrpc")] + jsonrpc: ::std::string::String, +} +impl UrlElicitationRequiredError { + pub fn new(error: UrlElicitError, id: ::std::option::Option) -> Self { + Self { + error, + id, + jsonrpc: JSONRPC_VERSION.to_string(), + } + } + pub fn jsonrpc(&self) -> &::std::string::String { + &self.jsonrpc + } } /// Implementing the Deserialize trait /// This allows enum to be deserialized into correct type based on the value of the "method" @@ -7647,6 +10944,22 @@ impl<'de> serde::Deserialize<'de> for ClientRequest { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ClientRequest::CallToolRequest(req)) } + "tasks/get" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::GetTaskRequest(req)) + } + "tasks/result" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::GetTaskPayloadRequest(req)) + } + "tasks/cancel" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::CancelTaskRequest(req)) + } + "tasks/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientRequest::ListTasksRequest(req)) + } "logging/setLevel" => { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ClientRequest::SetLevelRequest(req)) @@ -7676,6 +10989,10 @@ impl ClientRequest { ClientRequest::GetPromptRequest(request) => request.method(), ClientRequest::ListToolsRequest(request) => request.method(), ClientRequest::CallToolRequest(request) => request.method(), + ClientRequest::GetTaskRequest(request) => request.method(), + ClientRequest::GetTaskPayloadRequest(request) => request.method(), + ClientRequest::CancelTaskRequest(request) => request.method(), + ClientRequest::ListTasksRequest(request) => request.method(), ClientRequest::SetLevelRequest(request) => request.method(), ClientRequest::CompleteRequest(request) => request.method(), } @@ -7704,6 +11021,10 @@ impl<'de> serde::Deserialize<'de> for ClientNotification { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ClientNotification::ProgressNotification(req)) } + "notifications/tasks/status" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ClientNotification::TaskStatusNotification(req)) + } "notifications/roots/list_changed" => { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; @@ -7722,6 +11043,7 @@ impl ClientNotification { ClientNotification::CancelledNotification(request) => request.method(), ClientNotification::InitializedNotification(request) => request.method(), ClientNotification::ProgressNotification(request) => request.method(), + ClientNotification::TaskStatusNotification(request) => request.method(), ClientNotification::RootsListChangedNotification(request) => request.method(), } } @@ -7741,6 +11063,22 @@ impl<'de> serde::Deserialize<'de> for ServerRequest { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ServerRequest::PingRequest(req)) } + "tasks/get" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::GetTaskRequest(req)) + } + "tasks/result" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::GetTaskPayloadRequest(req)) + } + "tasks/cancel" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::CancelTaskRequest(req)) + } + "tasks/list" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerRequest::ListTasksRequest(req)) + } "sampling/createMessage" => { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ServerRequest::CreateMessageRequest(req)) @@ -7764,6 +11102,10 @@ impl ServerRequest { pub fn method(&self) -> &str { match self { ServerRequest::PingRequest(request) => request.method(), + ServerRequest::GetTaskRequest(request) => request.method(), + ServerRequest::GetTaskPayloadRequest(request) => request.method(), + ServerRequest::CancelTaskRequest(request) => request.method(), + ServerRequest::ListTasksRequest(request) => request.method(), ServerRequest::CreateMessageRequest(request) => request.method(), ServerRequest::ListRootsRequest(request) => request.method(), ServerRequest::ElicitRequest(request) => request.method(), @@ -7809,11 +11151,20 @@ impl<'de> serde::Deserialize<'de> for ServerNotification { serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ServerNotification::ToolListChangedNotification(req)) } + "notifications/tasks/status" => { + let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; + Ok(ServerNotification::TaskStatusNotification(req)) + } "notifications/message" => { let req = serde_json::from_value::(value).map_err(serde::de::Error::custom)?; Ok(ServerNotification::LoggingMessageNotification(req)) } + "notifications/elicitation/complete" => { + let req = serde_json::from_value::(value) + .map_err(serde::de::Error::custom)?; + Ok(ServerNotification::ElicitationCompleteNotification(req)) + } _ => Err(serde::de::Error::unknown_variant("method", &[""])), } } else { @@ -7830,11 +11181,29 @@ impl ServerNotification { ServerNotification::ResourceUpdatedNotification(request) => request.method(), ServerNotification::PromptListChangedNotification(request) => request.method(), ServerNotification::ToolListChangedNotification(request) => request.method(), + ServerNotification::TaskStatusNotification(request) => request.method(), ServerNotification::LoggingMessageNotification(request) => request.method(), + ServerNotification::ElicitationCompleteNotification(request) => request.method(), } } } -#[deprecated(since = "0.3.0", note = "Use `RpcError` instead.")] -pub type JsonrpcErrorError = RpcError; -#[deprecated(since = "0.7.0", note = "Use `ElicitRequestedSchema` instead.")] -pub type ElicitRequestParamsRequestedSchema = ElicitRequestedSchema; +/// Deprecating the old auto-generated verbose names. +/// These were renamed to clearer, shorter names in v0.8.0. +/// The old names are deprecated but kept for backward-compatibility for a smooth migration period. +/// +#[deprecated(since = "0.8.0", note = "Use `IncludeContext` instead.")] +pub type CreateMessageRequestParamsIncludeContext = IncludeContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestContext` instead.")] +pub type CompleteRequestParamsContext = CompleteRequestContext; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestArgument` instead.")] +pub type CompleteRequestParamsArgument = CompleteRequestArgument; +#[deprecated(since = "0.8.0", note = "Use `CompleteRequestRef` instead.")] +pub type CompleteRequestParamsRef = CompleteRequestRef; +#[deprecated(since = "0.8.0", note = "Use `CreateMessageContent` instead.")] +pub type CreateMessageResultContent = CreateMessageContent; +#[deprecated(since = "0.8.0", note = "Use `ElicitResultContent` instead.")] +pub type ElicitResultContentValue = ElicitResultContent; +#[deprecated(since = "0.8.0", note = "Use `ClientRoots` instead.")] +pub type ClientCapabilitiesRoots = ClientRoots; +#[deprecated(since = "0.8.0", note = "Use `ReadResourceContent` instead.")] +pub type ReadResourceResultContentsItem = ReadResourceContent; diff --git a/src/generated_schema/draft/schema_utils.rs b/src/generated_schema/draft/schema_utils.rs index 08ce1bf..d30a976 100644 --- a/src/generated_schema/draft/schema_utils.rs +++ b/src/generated_schema/draft/schema_utils.rs @@ -144,7 +144,7 @@ pub enum ClientMessage { Request(ClientJsonrpcRequest), Notification(ClientJsonrpcNotification), Response(ClientJsonrpcResponse), - Error(JsonrpcError), + Error(JsonrpcErrorResponse), } impl ClientMessage { @@ -211,16 +211,16 @@ impl ClientMessage { } } - /// Converts the current message into a `JsonrpcError` if it's of the correct type. + /// Converts the current message into a `JsonrpcErrorResponse` if it's of the correct type. /// /// This function checks if the current message is of type `Error`. If so, it returns the - /// `JsonrpcError` wrapped in a `Result::Ok`. If the message is not a `Error`, + /// `JsonrpcErrorResponse` wrapped in a `Result::Ok`. If the message is not a `Error`, /// it returns an error with a descriptive message indicating the mismatch in expected message types. /// /// # Returns - /// - `Ok(JsonrpcError)` if the message is a valid `Error`. + /// - `Ok(JsonrpcErrorResponse)` if the message is a valid `Error`. /// - `Err(RpcError)` if the message type is invalid - pub fn as_error(self) -> std::result::Result { + pub fn as_error(self) -> std::result::Result { if let Self::Error(error) = self { Ok(error) } else { @@ -272,7 +272,7 @@ impl RpcMessage for ClientMessage { // If the message is a response, return the associated request ID ClientMessage::Response(client_jsonrpc_response) => Some(&client_jsonrpc_response.id), // If the message is an error, return the associated request ID - ClientMessage::Error(jsonrpc_error) => Some(&jsonrpc_error.id), + ClientMessage::Error(jsonrpc_error) => jsonrpc_error.id.as_ref(), } } @@ -690,7 +690,7 @@ pub enum ServerMessage { Request(ServerJsonrpcRequest), Notification(ServerJsonrpcNotification), Response(ServerJsonrpcResponse), - Error(JsonrpcError), + Error(JsonrpcErrorResponse), } impl ServerMessage { @@ -757,16 +757,16 @@ impl ServerMessage { } } - /// Converts the current message into a `JsonrpcError` if it's of the correct type. + /// Converts the current message into a `JsonrpcErrorResponse` if it's of the correct type. /// /// This function checks if the current message is of type `Error`. If so, it returns the - /// `JsonrpcError` wrapped in a `Result::Ok`. If the message is not a `Error`, + /// `JsonrpcErrorResponse` wrapped in a `Result::Ok`. If the message is not a `Error`, /// it returns an error with a descriptive message indicating the mismatch in expected message types. /// /// # Returns - /// - `Ok(JsonrpcError)` if the message is a valid `Error`. + /// - `Ok(JsonrpcErrorResponse)` if the message is a valid `Error`. /// - `Err(RpcError)` if the message type is invalid - pub fn as_error(self) -> std::result::Result { + pub fn as_error(self) -> std::result::Result { if let Self::Error(error) = self { Ok(error) } else { @@ -808,7 +808,7 @@ impl RpcMessage for ServerMessage { // If the message is a response, return the associated request ID ServerMessage::Response(server_jsonrpc_response) => Some(&server_jsonrpc_response.id), // If the message is an error, return the associated request ID - ServerMessage::Error(jsonrpc_error) => Some(&jsonrpc_error.id), + ServerMessage::Error(jsonrpc_error) => jsonrpc_error.id.as_ref(), } } @@ -1180,11 +1180,11 @@ impl<'de> serde::Deserialize<'de> for ResultFromServer { } //***************************// -//** impl for JsonrpcError **// +//** impl for JsonrpcErrorResponse **// //***************************// /// Formats the ServerJsonrpcResponse as a JSON string. -impl Display for JsonrpcError { +impl Display for JsonrpcErrorResponse { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, @@ -1194,7 +1194,7 @@ impl Display for JsonrpcError { } } -impl FromStr for JsonrpcError { +impl FromStr for JsonrpcErrorResponse { type Err = RpcError; fn from_str(s: &str) -> std::result::Result { @@ -1300,9 +1300,7 @@ impl FromMessage for ServerMessage { ))) } MessageFromServer::Error(jsonrpc_error_error) => { - let request_id = - request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; - Ok(ServerMessage::Error(JsonrpcError::new(jsonrpc_error_error, request_id))) + Ok(ServerMessage::Error(JsonrpcErrorResponse::new(jsonrpc_error_error, request_id))) } } } @@ -1418,9 +1416,7 @@ impl FromMessage for ClientMessage { ))) } MessageFromClient::Error(jsonrpc_error_error) => { - let request_id = - request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; - Ok(ClientMessage::Error(JsonrpcError::new(jsonrpc_error_error, request_id))) + Ok(ClientMessage::Error(JsonrpcErrorResponse::new(jsonrpc_error_error, request_id))) } } } @@ -1495,7 +1491,7 @@ impl CallToolError { /// # Examples /// /// ``` - /// let err = CallToolError::from_message("Something went wrong"); + /// let err = rust_mcp_schema::schema_utils::CallToolError::from_message("Something went wrong"); /// println!("{:?}", err); /// ``` /// @@ -1822,10 +1818,76 @@ impl FromStr for StringSchemaFormat { } } + +// Helper: handle all single-select enum variants +fn try_from_enum_schema(map: &serde_json::Map) -> result::Result { + // All enum schemas should have type: "string" (or missing, but usually present) + let has_one_of = map.contains_key("oneOf"); + let has_enum = map.contains_key("enum"); + let has_enum_names = map.contains_key("enumNames"); + + if has_one_of { + let schema: TitledSingleSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse TitledSingleSelectEnumSchema: {e}")) + })?; + + Ok(PrimitiveSchemaDefinition::TitledSingleSelectEnumSchema(schema)) + } else if has_enum && has_enum_names { + let schema: LegacyTitledEnumSchema = serde_json::from_value(Value::Object(map.clone())) + .map_err(|e| RpcError::parse_error().with_message(format!("Failed to parse LegacyTitledEnumSchema: {e}")))?; + Ok(PrimitiveSchemaDefinition::LegacyTitledEnumSchema(schema)) + } else if has_enum { + let schema: UntitledSingleSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse UntitledSingleSelectEnumSchema: {e}")) + })?; + Ok(PrimitiveSchemaDefinition::UntitledSingleSelectEnumSchema(schema)) + } else { + Err(RpcError::parse_error().with_message("Invalid enum schema: missing 'enum' or 'oneOf'".to_string())) + } +} + +// Helper: handle multi-select (array) enum schemas +fn try_from_multi_select_schema( + map: &serde_json::Map, +) -> result::Result { + let items = map + .get("items") + .ok_or(RpcError::parse_error().with_message("Array schema missing 'items' field".to_string()))?; + + let items_obj = items + .as_object() + .ok_or(RpcError::parse_error().with_message("Field 'items' must be an object".to_string()))?; + + if items_obj.contains_key("anyOf") { + let schema: TitledMultiSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse TitledMultiSelectEnumSchema: {e}")) + })?; + Ok(PrimitiveSchemaDefinition::TitledMultiSelectEnumSchema(schema)) + } else if items_obj.contains_key("enum") { + let schema: UntitledMultiSelectEnumSchema = serde_json::from_value(Value::Object(map.clone())).map_err(|e| { + RpcError::parse_error().with_message(format!("Failed to parse UntitledMultiSelectEnumSchema: {e}")) + })?; + Ok(PrimitiveSchemaDefinition::UntitledMultiSelectEnumSchema(schema)) + } else { + Err(RpcError::parse_error() + .with_message("Array schema 'items' must contain 'enum' or 'oneOf' to be a multi-select enum".to_string())) + } +} + impl TryFrom<&serde_json::Map> for PrimitiveSchemaDefinition { type Error = RpcError; fn try_from(value: &serde_json::Map) -> result::Result { + // 1. First: detect enum schemas (they look like strings but have enum/oneOf) + if value.contains_key("enum") || value.contains_key("oneOf") { + return try_from_enum_schema(value); + } + + // 2. Then: detect multi-select array schemas (type: "array" + items with enum/oneOf) + if value.get("type").and_then(|v| v.as_str()) == Some("array") { + return try_from_multi_select_schema(value); + } + let input_type = value .get("type") .and_then(|v| v.as_str()) @@ -1877,38 +1939,8 @@ impl TryFrom<&serde_json::Map> for PrimitiveSchemaDefinition { let default = value.get("default").and_then(|v| v.as_bool().map(|s| s.to_owned())); PrimitiveSchemaDefinition::BooleanSchema(BooleanSchema::new(default, description, title)) } - - "enum" => { - let mut enum_values: ::std::vec::Vec<::std::string::String> = vec![]; - let mut enum_names: ::std::vec::Vec<::std::string::String> = vec![]; - let default = value.get("default").and_then(|v| v.as_str().map(|s| s.to_string())); - - let values = value.get("oneOf").and_then(|v| v.as_array()).ok_or_else(|| { - RpcError::parse_error() - .with_message("Unsupported enum type, only simple enums are supported!".to_string()) - })?; - - for v in values { - let title = v.get("title").and_then(|v| v.as_str().map(|s| s.to_string())); - let enum_value = v.get("enum").and_then(|v| v.as_array()).ok_or_else(|| { - RpcError::parse_error() - .with_message("Unsupported enum type. only simple enums are supported!".to_string()) - })?; - let enum_value = enum_value - .first() - .and_then(|s| s.as_str().map(|s| s.to_string())) - .ok_or_else(|| { - RpcError::parse_error() - .with_message("Unsupported enum value, only simple enums are supported!".to_string()) - })?; - - enum_values.push(enum_value.to_owned()); - enum_names.push(title.unwrap_or(enum_value)); - } - PrimitiveSchemaDefinition::EnumSchema(EnumSchema::new(enum_values, enum_names, default, description, title)) - } other => { - panic!("'{other}' type is not currently supported"); + return Err(RpcError::parse_error().with_message(format!("'{other}' type is not currently supported"))); } }; @@ -1961,6 +1993,10 @@ impl ::serde::Serialize for ClientJsonrpcRequest { } } CallToolRequest(msg) => state.serialize_field("params", &msg.params)?, + GetTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + GetTaskPayloadRequest(msg) => state.serialize_field("params", &msg.params)?, + CancelTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + ListTasksRequest(msg) => state.serialize_field("params", &msg.params)?, SetLevelRequest(msg) => state.serialize_field("params", &msg.params)?, CompleteRequest(msg) => state.serialize_field("params", &msg.params)?, }, @@ -2039,6 +2075,10 @@ impl ::serde::Serialize for ServerJsonrpcRequest { state.serialize_field("params", params)? } } + GetTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + GetTaskPayloadRequest(msg) => state.serialize_field("params", &msg.params)?, + CancelTaskRequest(msg) => state.serialize_field("params", &msg.params)?, + ListTasksRequest(msg) => state.serialize_field("params", &msg.params)?, CreateMessageRequest(msg) => state.serialize_field("params", &msg.params)?, ListRootsRequest(msg) => { if let Some(params) = &msg.params { @@ -2123,6 +2163,7 @@ impl ::serde::Serialize for ClientJsonrpcNotification { } } ProgressNotification(msg) => state.serialize_field("params", &msg.params)?, + TaskStatusNotification(msg) => state.serialize_field("params", &msg.params)?, RootsListChangedNotification(msg) => { if let Some(params) = &msg.params { state.serialize_field("params", params)? @@ -2213,7 +2254,9 @@ impl ::serde::Serialize for ServerJsonrpcNotification { state.serialize_field("params", params)? } } + TaskStatusNotification(msg) => state.serialize_field("params", &msg.params)?, LoggingMessageNotification(msg) => state.serialize_field("params", &msg.params)?, + ElicitationCompleteNotification(msg) => state.serialize_field("params", &msg.params)?, }, NotificationFromServer::CustomNotification(value) => state.serialize_field("params", value)?, } @@ -2429,6 +2472,26 @@ impl From for RequestFromClient { Self::ClientRequest(value.into()) } } +impl From for RequestFromClient { + fn from(value: GetTaskRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: CancelTaskRequest) -> Self { + Self::ClientRequest(value.into()) + } +} +impl From for RequestFromClient { + fn from(value: ListTasksRequest) -> Self { + Self::ClientRequest(value.into()) + } +} impl From for RequestFromClient { fn from(value: SetLevelRequest) -> Self { Self::ClientRequest(value.into()) @@ -2494,6 +2557,26 @@ impl From for MessageFromClient { MessageFromClient::RequestFromClient(value.into()) } } +impl From for MessageFromClient { + fn from(value: GetTaskRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetTaskPayloadRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CancelTaskRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListTasksRequest) -> Self { + MessageFromClient::RequestFromClient(value.into()) + } +} impl From for MessageFromClient { fn from(value: SetLevelRequest) -> Self { MessageFromClient::RequestFromClient(value.into()) @@ -2519,6 +2602,11 @@ impl From for NotificationFromClient { Self::ClientNotification(value.into()) } } +impl From for NotificationFromClient { + fn from(value: TaskStatusNotification) -> Self { + Self::ClientNotification(value.into()) + } +} impl From for NotificationFromClient { fn from(value: RootsListChangedNotification) -> Self { Self::ClientNotification(value.into()) @@ -2539,6 +2627,11 @@ impl From for ClientJsonrpcNotification { Self::new(value.into()) } } +impl From for ClientJsonrpcNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::new(value.into()) + } +} impl From for ClientJsonrpcNotification { fn from(value: RootsListChangedNotification) -> Self { Self::new(value.into()) @@ -2559,6 +2652,11 @@ impl From for MessageFromClient { MessageFromClient::NotificationFromClient(value.into()) } } +impl From for MessageFromClient { + fn from(value: TaskStatusNotification) -> Self { + MessageFromClient::NotificationFromClient(value.into()) + } +} impl From for MessageFromClient { fn from(value: RootsListChangedNotification) -> Self { MessageFromClient::NotificationFromClient(value.into()) @@ -2569,6 +2667,26 @@ impl From for ResultFromClient { Self::ClientResult(value.into()) } } +impl From for ResultFromClient { + fn from(value: GetTaskResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: GetTaskPayloadResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: CancelTaskResult) -> Self { + Self::ClientResult(value.into()) + } +} +impl From for ResultFromClient { + fn from(value: ListTasksResult) -> Self { + Self::ClientResult(value.into()) + } +} impl From for ResultFromClient { fn from(value: CreateMessageResult) -> Self { Self::ClientResult(value.into()) @@ -2589,6 +2707,26 @@ impl From for MessageFromClient { MessageFromClient::ResultFromClient(value.into()) } } +impl From for MessageFromClient { + fn from(value: GetTaskResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: GetTaskPayloadResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: CancelTaskResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} +impl From for MessageFromClient { + fn from(value: ListTasksResult) -> Self { + MessageFromClient::ResultFromClient(value.into()) + } +} impl From for MessageFromClient { fn from(value: CreateMessageResult) -> Self { MessageFromClient::ResultFromClient(value.into()) @@ -2617,6 +2755,7 @@ pub enum SdkErrorCodes { INVALID_PARAMS = -32602, INTERNAL_ERROR = -32603, PARSE_ERROR = -32700, + URL_ELICITATION_REQUIRED = -32042, } impl core::fmt::Display for SdkErrorCodes { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -2631,6 +2770,12 @@ impl core::fmt::Display for SdkErrorCodes { SdkErrorCodes::RESOURCE_NOT_FOUND => write!(f, "Resource not found"), SdkErrorCodes::BAD_REQUEST => write!(f, "Bad request"), SdkErrorCodes::SESSION_NOT_FOUND => write!(f, "Session not found"), + SdkErrorCodes::URL_ELICITATION_REQUIRED => { + write!( + f, + "A required URL was not provided. Please supply the requested URL to continue." + ) + } } } } @@ -2726,6 +2871,24 @@ impl SdkError { message: SdkErrorCodes::PARSE_ERROR.to_string(), } } + /// Creates a new `RpcError` indicating that a URL elicitation failed + /// and was required for the operation to continue. + /// + /// The resulting error uses the -32042 value as introduced in mcp protocol 2025-11-25 + /// The result json matches a UrlElicitError and the `data` value could be deserialized into UrlElicitErrorData + /// + pub fn url_elicit_required(elicit_url_params: Vec) -> Self { + Self { + code: UrlElicitError::code_value(), + data: Some(serde_json::to_value(elicit_url_params).unwrap_or_else(|_| { + json!( + { "elicitations" : [], "error" : + "failed to UrlElicitError data" } + ) + })), + message: "URL required. Please provide a URL.".to_string(), + } + } pub fn resource_not_found() -> Self { Self { code: SdkErrorCodes::RESOURCE_NOT_FOUND.into(), @@ -2749,7 +2912,7 @@ impl SdkError { self } } -/// Enum representing standard JSON-RPC error codes. +/// Enum representing standard and mcp specific JSON-RPC error codes. #[allow(non_camel_case_types)] pub enum RpcErrorCodes { PARSE_ERROR = -32700isize, @@ -2757,6 +2920,7 @@ pub enum RpcErrorCodes { METHOD_NOT_FOUND = -32601isize, INVALID_PARAMS = -32602isize, INTERNAL_ERROR = -32603isize, + URL_ELICITATION_REQUIRED = -32042isize, } impl From for i64 { fn from(code: RpcErrorCodes) -> Self { @@ -2808,6 +2972,24 @@ impl RpcError { message: "Method not found".to_string(), } } + /// Creates a new `RpcError` indicating that a URL elicitation failed + /// and was required for the operation to continue. + /// + /// The resulting error uses the -32042 value as introduced in mcp protocol 2025-11-25 + /// The result json matches a UrlElicitError and the `data` value could be deserialized into UrlElicitErrorData + /// + pub fn url_elicit_required(elicit_url_params: Vec) -> Self { + Self { + code: UrlElicitError::code_value(), + data: Some(serde_json::to_value(elicit_url_params).unwrap_or_else(|_| { + json!( + { "elicitations" : [], "error" : + "failed to UrlElicitError data" } + ) + })), + message: "URL required. Please provide a URL.".to_string(), + } + } /// Creates a new `RpcError` for "Invalid parameters". /// /// # Example @@ -2921,10 +3103,10 @@ impl FromStr for RpcError { .map_err(|error| RpcError::parse_error().with_data(Some(json!({ "details" : error.to_string() })))) } } -/// Constructs a new JsonrpcError using the provided arguments. -impl JsonrpcError { +///Constructs a new `JsonrpcErrorResponse` using the provided arguments. +impl JsonrpcErrorResponse { pub fn create( - id: RequestId, + id: Option, error_code: RpcErrorCodes, error_message: ::std::string::String, error_data: ::std::option::Option<::serde_json::Value>, @@ -2962,11 +3144,21 @@ impl From for NotificationFromServer { Self::ServerNotification(value.into()) } } +impl From for NotificationFromServer { + fn from(value: TaskStatusNotification) -> Self { + Self::ServerNotification(value.into()) + } +} impl From for NotificationFromServer { fn from(value: LoggingMessageNotification) -> Self { Self::ServerNotification(value.into()) } } +impl From for NotificationFromServer { + fn from(value: ElicitationCompleteNotification) -> Self { + Self::ServerNotification(value.into()) + } +} impl From for ServerJsonrpcNotification { fn from(value: CancelledNotification) -> Self { Self::new(value.into()) @@ -2997,11 +3189,21 @@ impl From for ServerJsonrpcNotification { Self::new(value.into()) } } +impl From for ServerJsonrpcNotification { + fn from(value: TaskStatusNotification) -> Self { + Self::new(value.into()) + } +} impl From for ServerJsonrpcNotification { fn from(value: LoggingMessageNotification) -> Self { Self::new(value.into()) } } +impl From for ServerJsonrpcNotification { + fn from(value: ElicitationCompleteNotification) -> Self { + Self::new(value.into()) + } +} impl From for MessageFromServer { fn from(value: CancelledNotification) -> Self { MessageFromServer::NotificationFromServer(value.into()) @@ -3032,16 +3234,46 @@ impl From for MessageFromServer { MessageFromServer::NotificationFromServer(value.into()) } } +impl From for MessageFromServer { + fn from(value: TaskStatusNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} impl From for MessageFromServer { fn from(value: LoggingMessageNotification) -> Self { MessageFromServer::NotificationFromServer(value.into()) } } +impl From for MessageFromServer { + fn from(value: ElicitationCompleteNotification) -> Self { + MessageFromServer::NotificationFromServer(value.into()) + } +} impl From for RequestFromServer { fn from(value: PingRequest) -> Self { Self::ServerRequest(value.into()) } } +impl From for RequestFromServer { + fn from(value: GetTaskRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: GetTaskPayloadRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: CancelTaskRequest) -> Self { + Self::ServerRequest(value.into()) + } +} +impl From for RequestFromServer { + fn from(value: ListTasksRequest) -> Self { + Self::ServerRequest(value.into()) + } +} impl From for RequestFromServer { fn from(value: CreateMessageRequest) -> Self { Self::ServerRequest(value.into()) @@ -3062,6 +3294,26 @@ impl From for MessageFromServer { MessageFromServer::RequestFromServer(value.into()) } } +impl From for MessageFromServer { + fn from(value: GetTaskRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetTaskPayloadRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CancelTaskRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListTasksRequest) -> Self { + MessageFromServer::RequestFromServer(value.into()) + } +} impl From for MessageFromServer { fn from(value: CreateMessageRequest) -> Self { MessageFromServer::RequestFromServer(value.into()) @@ -3122,6 +3374,26 @@ impl From for ResultFromServer { Self::ServerResult(value.into()) } } +impl From for ResultFromServer { + fn from(value: GetTaskResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: GetTaskPayloadResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: CancelTaskResult) -> Self { + Self::ServerResult(value.into()) + } +} +impl From for ResultFromServer { + fn from(value: ListTasksResult) -> Self { + Self::ServerResult(value.into()) + } +} impl From for ResultFromServer { fn from(value: CompleteResult) -> Self { Self::ServerResult(value.into()) @@ -3172,6 +3444,26 @@ impl From for MessageFromServer { MessageFromServer::ResultFromServer(value.into()) } } +impl From for MessageFromServer { + fn from(value: GetTaskResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: GetTaskPayloadResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: CancelTaskResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} +impl From for MessageFromServer { + fn from(value: ListTasksResult) -> Self { + MessageFromServer::ResultFromServer(value.into()) + } +} impl From for MessageFromServer { fn from(value: CompleteResult) -> Self { MessageFromServer::ResultFromServer(value.into()) @@ -3312,6 +3604,54 @@ impl ToMessage for CallToolRequest { ClientMessage::from_message(self, request_id) } } +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskPayloadRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskPayloadRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CancelTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CancelTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListTasksRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Request(ClientJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListTasksRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} impl FromMessage for ClientMessage { fn from_message(message: SetLevelRequest, request_id: Option) -> std::result::Result { let request_id = @@ -3351,6 +3691,66 @@ impl ToMessage for Result { ClientMessage::from_message(self, request_id) } } +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: GetTaskPayloadResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskPayloadResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: CancelTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CancelTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} +impl FromMessage for ClientMessage { + fn from_message(message: ListTasksResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ClientMessage::Response(ClientJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListTasksResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} impl FromMessage for ClientMessage { fn from_message(message: CreateMessageResult, request_id: Option) -> std::result::Result { let request_id = @@ -3441,6 +3841,21 @@ impl ToMessage for ProgressNotification { ClientMessage::from_message(self, request_id) } } +impl FromMessage for ClientMessage { + fn from_message(message: TaskStatusNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ClientMessage::Notification(ClientJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for TaskStatusNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ClientMessage::from_message(self, request_id) + } +} impl FromMessage for ClientMessage { fn from_message( message: RootsListChangedNotification, @@ -3471,8 +3886,56 @@ impl ToMessage for PingRequest { ServerMessage::from_message(self, request_id) } } -impl FromMessage for ServerMessage { - fn from_message(message: CreateMessageRequest, request_id: Option) -> std::result::Result { +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskPayloadRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for GetTaskPayloadRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CancelTaskRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for CancelTaskRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListTasksRequest, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) + } +} +impl ToMessage for ListTasksRequest { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CreateMessageRequest, request_id: Option) -> std::result::Result { let request_id = request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; Ok(ServerMessage::Request(ServerJsonrpcRequest::new(request_id, message.into()))) @@ -3645,6 +4108,66 @@ impl ToMessage for CallToolResult { ServerMessage::from_message(self, request_id) } } +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: GetTaskPayloadResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for GetTaskPayloadResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: CancelTaskResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for CancelTaskResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} +impl FromMessage for ServerMessage { + fn from_message(message: ListTasksResult, request_id: Option) -> std::result::Result { + let request_id = + request_id.ok_or_else(|| RpcError::internal_error().with_message("request_id is None!".to_string()))?; + Ok(ServerMessage::Response(ServerJsonrpcResponse::new( + request_id, + message.into(), + ))) + } +} +impl ToMessage for ListTasksResult { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} impl FromMessage for ServerMessage { fn from_message(message: CompleteResult, request_id: Option) -> std::result::Result { let request_id = @@ -3762,6 +4285,21 @@ impl ToMessage for ToolListChangedNotification { ServerMessage::from_message(self, request_id) } } +impl FromMessage for ServerMessage { + fn from_message(message: TaskStatusNotification, request_id: Option) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for TaskStatusNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} impl FromMessage for ServerMessage { fn from_message( message: LoggingMessageNotification, @@ -3780,6 +4318,24 @@ impl ToMessage for LoggingMessageNotification { ServerMessage::from_message(self, request_id) } } +impl FromMessage for ServerMessage { + fn from_message( + message: ElicitationCompleteNotification, + request_id: Option, + ) -> std::result::Result { + if request_id.is_some() { + return Err( + RpcError::internal_error().with_message("request_id expected to be None for Notifications!".to_string()) + ); + } + Ok(ServerMessage::Notification(ServerJsonrpcNotification::new(message.into()))) + } +} +impl ToMessage for ElicitationCompleteNotification { + fn to_message(self, request_id: Option) -> std::result::Result { + ServerMessage::from_message(self, request_id) + } +} impl TryFrom for InitializeRequest { type Error = RpcError; fn try_from(value: RequestFromClient) -> std::result::Result { @@ -3901,6 +4457,50 @@ impl TryFrom for CallToolRequest { } } } +impl TryFrom for GetTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::GetTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskRequest".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::GetTaskPayloadRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadRequest".to_string())) + } + } +} +impl TryFrom for CancelTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::CancelTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskRequest".to_string())) + } + } +} +impl TryFrom for ListTasksRequest { + type Error = RpcError; + fn try_from(value: RequestFromClient) -> std::result::Result { + let matched_type: ClientRequest = value.try_into()?; + if let ClientRequest::ListTasksRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksRequest".to_string())) + } + } +} impl TryFrom for SetLevelRequest { type Error = RpcError; fn try_from(value: RequestFromClient) -> std::result::Result { @@ -3934,6 +4534,50 @@ impl TryFrom for Result { } } } +impl TryFrom for GetTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::GetTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskResult".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::GetTaskPayloadResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadResult".to_string())) + } + } +} +impl TryFrom for CancelTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::CancelTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskResult".to_string())) + } + } +} +impl TryFrom for ListTasksResult { + type Error = RpcError; + fn try_from(value: ResultFromClient) -> std::result::Result { + let matched_type: ClientResult = value.try_into()?; + if let ClientResult::ListTasksResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksResult".to_string())) + } + } +} impl TryFrom for CreateMessageResult { type Error = RpcError; fn try_from(value: ResultFromClient) -> std::result::Result { @@ -4000,6 +4644,17 @@ impl TryFrom for ProgressNotification { } } } +impl TryFrom for TaskStatusNotification { + type Error = RpcError; + fn try_from(value: NotificationFromClient) -> std::result::Result { + let matched_type: ClientNotification = value.try_into()?; + if let ClientNotification::TaskStatusNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a TaskStatusNotification".to_string())) + } + } +} impl TryFrom for RootsListChangedNotification { type Error = RpcError; fn try_from(value: NotificationFromClient) -> std::result::Result { @@ -4022,6 +4677,50 @@ impl TryFrom for PingRequest { } } } +impl TryFrom for GetTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::GetTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskRequest".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::GetTaskPayloadRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadRequest".to_string())) + } + } +} +impl TryFrom for CancelTaskRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::CancelTaskRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskRequest".to_string())) + } + } +} +impl TryFrom for ListTasksRequest { + type Error = RpcError; + fn try_from(value: RequestFromServer) -> std::result::Result { + let matched_type: ServerRequest = value.try_into()?; + if let ServerRequest::ListTasksRequest(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksRequest".to_string())) + } + } +} impl TryFrom for CreateMessageRequest { type Error = RpcError; fn try_from(value: RequestFromServer) -> std::result::Result { @@ -4154,6 +4853,50 @@ impl TryFrom for CallToolResult { } } } +impl TryFrom for GetTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::GetTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskResult".to_string())) + } + } +} +impl TryFrom for GetTaskPayloadResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::GetTaskPayloadResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a GetTaskPayloadResult".to_string())) + } + } +} +impl TryFrom for CancelTaskResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::CancelTaskResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a CancelTaskResult".to_string())) + } + } +} +impl TryFrom for ListTasksResult { + type Error = RpcError; + fn try_from(value: ResultFromServer) -> std::result::Result { + let matched_type: ServerResult = value.try_into()?; + if let ServerResult::ListTasksResult(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ListTasksResult".to_string())) + } + } +} impl TryFrom for CompleteResult { type Error = RpcError; fn try_from(value: ResultFromServer) -> std::result::Result { @@ -4231,6 +4974,17 @@ impl TryFrom for ToolListChangedNotification { } } } +impl TryFrom for TaskStatusNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::TaskStatusNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a TaskStatusNotification".to_string())) + } + } +} impl TryFrom for LoggingMessageNotification { type Error = RpcError; fn try_from(value: NotificationFromServer) -> std::result::Result { @@ -4242,6 +4996,17 @@ impl TryFrom for LoggingMessageNotification { } } } +impl TryFrom for ElicitationCompleteNotification { + type Error = RpcError; + fn try_from(value: NotificationFromServer) -> std::result::Result { + let matched_type: ServerNotification = value.try_into()?; + if let ServerNotification::ElicitationCompleteNotification(result) = matched_type { + Ok(result) + } else { + Err(RpcError::internal_error().with_message("Not a ElicitationCompleteNotification".to_string())) + } + } +} impl ContentBlock { ///Create a ContentBlock::TextContent pub fn text_content(text: ::std::string::String) -> Self { @@ -4450,7 +5215,7 @@ mod tests { // assert!(matches!(result, MessageTypes::Response)); // // error message - // let message = JsonrpcError::create( + // let message = JsonrpcErrorResponse::create( // RequestId::Integer(0), // RpcErrorCodes::INVALID_PARAMS, // "Invalid params!".to_string(), diff --git a/src/generated_schema/draft/validators.rs b/src/generated_schema/draft/validators.rs index 7ce976a..62d4da6 100644 --- a/src/generated_schema/draft/validators.rs +++ b/src/generated_schema/draft/validators.rs @@ -33,22 +33,51 @@ where } } -/// Macro to generate a field-specific validator function for use with Serde. -/// -/// This avoids repetitive boilerplate when you have multiple fields/structs -/// requiring constant string validation. -/// -/// # Syntax -/// ```ignore -/// validate!(fn_name, "StructName", "field_name", "expected_value"); -/// ``` -/// -/// - `fn_name`: The function name to generate. -/// - `StructName`: The name of the struct (for error messages). -/// - `field_name`: The name of the field (for error messages). -/// - `expected_value`: The required constant string value. -/// +/// Validator for `Option` fields: +/// - None → accepted +/// - Some(s) → s must exactly match `expected` +pub fn const_str_option_validator<'de, D>( + struct_name: &'static str, + field_name: &'static str, + expected: &'static str, + deserializer: D, +) -> Result, D::Error> +where + D: serde::de::Deserializer<'de>, +{ + let opt: Option = serde::Deserialize::deserialize(deserializer)?; + match opt { + Some(ref value) if value != expected => { + Err(serde::de::Error::custom(format!( + "Expected field `{field_name}` in struct `{struct_name}` to be None or exactly \"{expected}\", but got Some(\"{value}\")", + ))) + } + Some(value) => Ok(Some(value)), // value == expected + None => Ok(None), + } +} + +fn i64_validator<'de, D>( + struct_name: &'static str, + field_name: &'static str, + expected: i64, + deserializer: D, +) -> Result +where + D: serde::de::Deserializer<'de>, +{ + let value = serde::Deserialize::deserialize(deserializer)?; + if value == expected { + Ok(value) + } else { + Err(serde::de::Error::custom(format!( + "Invalid {struct_name}::{field_name}: expected {expected}, got {value}" + ))) + } +} + macro_rules! validate { + // === String validation (required) === ($func_name:ident, $struct:expr, $field:expr, $expected:expr $(,)?) => { pub(crate) fn $func_name<'de, D>(deserializer: D) -> Result where @@ -57,6 +86,26 @@ macro_rules! validate { const_str_validator($struct, $field, $expected, deserializer) } }; + + // Optional String case (with trailing `, option`) + ($func_name:ident, $struct:expr, $field:expr, $expected:expr, option $(,)?) => { + pub(crate) fn $func_name<'de, D>(deserializer: D) -> Result, D::Error> + where + D: serde::de::Deserializer<'de>, + { + const_str_option_validator($struct, $field, $expected, deserializer) + } + }; + + // === i64 validation (required) === + ($func_name:ident, $struct:expr, $field:expr, $expected:expr, i64 $(,)?) => { + pub(crate) fn $func_name<'de, D>(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + i64_validator($struct, $field, $expected, deserializer) + } + }; } //* Validator Functions *// @@ -64,6 +113,8 @@ validate!(audio_content_type_, "AudioContent", "type_", "audio"); validate!(boolean_schema_type_, "BooleanSchema", "type_", "boolean"); validate!(call_tool_request_jsonrpc, "CallToolRequest", "jsonrpc", "2.0"); validate!(call_tool_request_method, "CallToolRequest", "method", "tools/call"); +validate!(cancel_task_request_jsonrpc, "CancelTaskRequest", "jsonrpc", "2.0"); +validate!(cancel_task_request_method, "CancelTaskRequest", "method", "tasks/cancel"); validate!(cancelled_notification_jsonrpc, "CancelledNotification", "jsonrpc", "2.0"); validate!( cancelled_notification_method, @@ -80,13 +131,41 @@ validate!( "method", "sampling/createMessage" ); +validate!(elicit_form_schema_type_, "ElicitFormSchema", "type_", "object"); validate!(elicit_request_jsonrpc, "ElicitRequest", "jsonrpc", "2.0"); validate!(elicit_request_method, "ElicitRequest", "method", "elicitation/create"); -validate!(elicit_requested_schema_type_, "ElicitRequestedSchema", "type_", "object"); +validate!( + elicit_request_form_params_mode, + "ElicitRequestFormParams", + "mode", + "form", + option +); +validate!(elicit_request_url_params_mode, "ElicitRequestUrlParams", "mode", "url"); +validate!( + elicitation_complete_notification_jsonrpc, + "ElicitationCompleteNotification", + "jsonrpc", + "2.0" +); +validate!( + elicitation_complete_notification_method, + "ElicitationCompleteNotification", + "method", + "notifications/elicitation/complete" +); validate!(embedded_resource_type_, "EmbeddedResource", "type_", "resource"); -validate!(enum_schema_type_, "EnumSchema", "type_", "string"); validate!(get_prompt_request_jsonrpc, "GetPromptRequest", "jsonrpc", "2.0"); validate!(get_prompt_request_method, "GetPromptRequest", "method", "prompts/get"); +validate!(get_task_payload_request_jsonrpc, "GetTaskPayloadRequest", "jsonrpc", "2.0"); +validate!( + get_task_payload_request_method, + "GetTaskPayloadRequest", + "method", + "tasks/result" +); +validate!(get_task_request_jsonrpc, "GetTaskRequest", "jsonrpc", "2.0"); +validate!(get_task_request_method, "GetTaskRequest", "method", "tasks/get"); validate!(image_content_type_, "ImageContent", "type_", "image"); validate!(initialize_request_jsonrpc, "InitializeRequest", "jsonrpc", "2.0"); validate!(initialize_request_method, "InitializeRequest", "method", "initialize"); @@ -97,10 +176,11 @@ validate!( "method", "notifications/initialized" ); -validate!(jsonrpc_error_jsonrpc, "JsonrpcError", "jsonrpc", "2.0"); +validate!(jsonrpc_error_response_jsonrpc, "JsonrpcErrorResponse", "jsonrpc", "2.0"); validate!(jsonrpc_notification_jsonrpc, "JsonrpcNotification", "jsonrpc", "2.0"); validate!(jsonrpc_request_jsonrpc, "JsonrpcRequest", "jsonrpc", "2.0"); -validate!(jsonrpc_response_jsonrpc, "JsonrpcResponse", "jsonrpc", "2.0"); +validate!(jsonrpc_result_response_jsonrpc, "JsonrpcResultResponse", "jsonrpc", "2.0"); +validate!(legacy_titled_enum_schema_type_, "LegacyTitledEnumSchema", "type_", "string"); validate!(list_prompts_request_jsonrpc, "ListPromptsRequest", "jsonrpc", "2.0"); validate!(list_prompts_request_method, "ListPromptsRequest", "method", "prompts/list"); validate!( @@ -124,6 +204,8 @@ validate!( ); validate!(list_roots_request_jsonrpc, "ListRootsRequest", "jsonrpc", "2.0"); validate!(list_roots_request_method, "ListRootsRequest", "method", "roots/list"); +validate!(list_tasks_request_jsonrpc, "ListTasksRequest", "jsonrpc", "2.0"); +validate!(list_tasks_request_method, "ListTasksRequest", "method", "tasks/list"); validate!(list_tools_request_jsonrpc, "ListToolsRequest", "jsonrpc", "2.0"); validate!(list_tools_request_method, "ListToolsRequest", "method", "tools/list"); validate!( @@ -216,7 +298,26 @@ validate!(set_level_request_method, "SetLevelRequest", "method", "logging/setLev validate!(string_schema_type_, "StringSchema", "type_", "string"); validate!(subscribe_request_jsonrpc, "SubscribeRequest", "jsonrpc", "2.0"); validate!(subscribe_request_method, "SubscribeRequest", "method", "resources/subscribe"); +validate!(task_status_notification_jsonrpc, "TaskStatusNotification", "jsonrpc", "2.0"); +validate!( + task_status_notification_method, + "TaskStatusNotification", + "method", + "notifications/tasks/status" +); validate!(text_content_type_, "TextContent", "type_", "text"); +validate!( + titled_multi_select_enum_schema_type_, + "TitledMultiSelectEnumSchema", + "type_", + "array" +); +validate!( + titled_single_select_enum_schema_type_, + "TitledSingleSelectEnumSchema", + "type_", + "string" +); validate!(tool_input_schema_type_, "ToolInputSchema", "type_", "object"); validate!( tool_list_changed_notification_jsonrpc, @@ -231,6 +332,8 @@ validate!( "notifications/tools/list_changed" ); validate!(tool_output_schema_type_, "ToolOutputSchema", "type_", "object"); +validate!(tool_result_content_type_, "ToolResultContent", "type_", "tool_result"); +validate!(tool_use_content_type_, "ToolUseContent", "type_", "tool_use"); validate!(unsubscribe_request_jsonrpc, "UnsubscribeRequest", "jsonrpc", "2.0"); validate!( unsubscribe_request_method, @@ -238,3 +341,28 @@ validate!( "method", "resources/unsubscribe" ); +validate!( + untitled_multi_select_enum_schema_type_, + "UntitledMultiSelectEnumSchema", + "type_", + "array" +); +validate!( + untitled_multi_select_enum_schema_items_type_, + "UntitledMultiSelectEnumSchemaItems", + "type_", + "string" +); +validate!( + untitled_single_select_enum_schema_type_, + "UntitledSingleSelectEnumSchema", + "type_", + "string" +); +validate!(url_elicit_error_code, "UrlElicitError", "code", -32042i64, i64); +validate!( + url_elicitation_required_error_jsonrpc, + "UrlElicitationRequiredError", + "jsonrpc", + "2.0" +); diff --git a/src/generated_schema/protocol_version.rs b/src/generated_schema/protocol_version.rs index 55e2e7f..bd6d2fd 100644 --- a/src/generated_schema/protocol_version.rs +++ b/src/generated_schema/protocol_version.rs @@ -4,6 +4,7 @@ pub enum ProtocolVersion { V2024_11_05, V2025_03_26, V2025_06_18, + V2025_11_25, Draft, } impl ProtocolVersion { @@ -12,6 +13,7 @@ impl ProtocolVersion { ProtocolVersion::V2024_11_05, ProtocolVersion::V2025_03_26, ProtocolVersion::V2025_06_18, + ProtocolVersion::V2025_11_25, ]; if include_draft { versions.push(ProtocolVersion::Draft); @@ -25,6 +27,7 @@ impl Display for ProtocolVersion { ProtocolVersion::V2024_11_05 => write!(f, "2024-11-05"), ProtocolVersion::V2025_03_26 => write!(f, "2025-03-26"), ProtocolVersion::V2025_06_18 => write!(f, "2025-06-18"), + ProtocolVersion::V2025_11_25 => write!(f, "2025-11-25"), ProtocolVersion::Draft => write!(f, "DRAFT-2025-v3"), } } @@ -55,6 +58,7 @@ impl TryFrom<&str> for ProtocolVersion { "2024-11-05" => Ok(ProtocolVersion::V2024_11_05), "2025-03-26" => Ok(ProtocolVersion::V2025_03_26), "2025-06-18" => Ok(ProtocolVersion::V2025_06_18), + "2025-11-25" => Ok(ProtocolVersion::V2025_11_25), "DRAFT-2025-v3" => Ok(ProtocolVersion::Draft), "DRAFT" => Ok(ProtocolVersion::Draft), other => Err(ParseProtocolVersionError { diff --git a/tests/2024_11_05_exclusive.rs b/tests/2024_11_05_exclusive.rs deleted file mode 100644 index a8c5e4f..0000000 --- a/tests/2024_11_05_exclusive.rs +++ /dev/null @@ -1,91 +0,0 @@ -//! Test cases applicable only to the specific version(s) of the schema (currently 2024_11_05) -#[path = "common/common.rs"] -pub mod common; - -#[cfg(feature = "2024_11_05")] -mod test_2024_11_05_exclusive { - use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; - use rust_mcp_schema::mcp_2024_11_05::*; - - use super::common::{get_message, re_serialize}; - - #[test] - fn test_server_list_resources_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::ListResourcesResult(ListResourcesResult { - meta: None, - next_cursor: None, - resources: vec![Resource { - annotations: None, - description: None, - mime_type: None, - name: "Resource 1".to_string(), - size: None, - uri: "test://static/resource/1".to_string(), - }], - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListResourcesResult(_))) - )); - } - - #[test] - fn test_client_list_resource_templates_request() { - // create a ClientMessage - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::ListResourceTemplatesRequest( - ListResourceTemplatesRequest::new(None), - )), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListResourceTemplatesRequest(_))) - )); - } - - #[test] - fn test_server_list_resource_templates_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::ListResourceTemplatesResult(ListResourceTemplatesResult { - meta: None, - next_cursor: None, - resource_templates: vec![], - })), - )); - - let message: ServerMessage = re_serialize(message); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListResourceTemplatesResult(_))) - )); - } - - #[test] - fn test_server_list_resource_templates_result_sample() { - let message = get_message("res_template_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListResourceTemplatesResult(_))) - )); - } - - #[test] - fn test_client_list_resource_templates_request_sample() { - let message = get_message("req_template_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListResourceTemplatesRequest(_))) - )); - } -} diff --git a/tests/miscellaneous.rs b/tests/before_2025_11_25/miscellaneous.rs similarity index 89% rename from tests/miscellaneous.rs rename to tests/before_2025_11_25/miscellaneous.rs index ec2e70a..fc4c4e0 100644 --- a/tests/miscellaneous.rs +++ b/tests/before_2025_11_25/miscellaneous.rs @@ -1,13 +1,16 @@ -#[path = "common/common.rs"] -pub mod common; - mod miscellaneous_tests { + #[cfg(feature = "2025_06_18")] + use rust_mcp_schema::mcp_2025_06_18::schema_utils::*; + #[cfg(feature = "2024_11_05")] use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; + #[cfg(feature = "2025_03_26")] use rust_mcp_schema::mcp_2025_03_26::schema_utils::*; + #[cfg(feature = "draft")] use rust_mcp_schema::mcp_draft::schema_utils::*; + #[cfg(feature = "latest")] use rust_mcp_schema::schema_utils::*; diff --git a/tests/before_2025_11_25/mod.rs b/tests/before_2025_11_25/mod.rs new file mode 100644 index 0000000..1bed794 --- /dev/null +++ b/tests/before_2025_11_25/mod.rs @@ -0,0 +1,9 @@ +#[path = "../common/common.rs"] +pub mod common; + +mod miscellaneous; +mod serde_smoke_test; +#[cfg(feature = "2024_11_05")] +mod test_2024_11_05_exclusive; +mod test_deserialize; +mod test_serialize; diff --git a/tests/serde_smoke_test.rs b/tests/before_2025_11_25/serde_smoke_test.rs similarity index 95% rename from tests/serde_smoke_test.rs rename to tests/before_2025_11_25/serde_smoke_test.rs index 5eb9632..aefab8a 100644 --- a/tests/serde_smoke_test.rs +++ b/tests/before_2025_11_25/serde_smoke_test.rs @@ -1,5 +1,8 @@ mod test_deserialize { + #[cfg(feature = "2025_06_18")] + use rust_mcp_schema::mcp_2025_06_18::*; + #[cfg(feature = "2024_11_05")] use rust_mcp_schema::mcp_2024_11_05::*; @@ -9,7 +12,7 @@ mod test_deserialize { #[cfg(feature = "draft")] use rust_mcp_schema::mcp_draft::*; - #[cfg(any(feature = "latest", feature = "2025_06_18"))] + #[cfg(feature = "latest")] use rust_mcp_schema::*; use serde::{Deserialize, Serialize}; @@ -183,7 +186,12 @@ mod test_deserialize { fn test_cancelled_notification() { let params = CancelledNotificationParams { reason: Some("test reason".to_string()), + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] request_id: RequestId::Integer(1), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + request_id: Some(RequestId::Integer(1)), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + meta: None, }; let notif = CancelledNotification::new(params); test_serde(¬if); @@ -236,7 +244,12 @@ mod test_deserialize { fn test_client_notification() { let notif = ClientNotification::CancelledNotification(CancelledNotification::new(CancelledNotificationParams { reason: None, + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] request_id: RequestId::Integer(0), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + request_id: Some(RequestId::Integer(0)), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + meta: None, })); test_serde(¬if); } @@ -271,7 +284,7 @@ mod test_deserialize { #[cfg(not(feature = "draft"))] #[test] fn test_complete_request() { - let argument = CompleteRequestParamsArgument { + let argument = CompleteRequestArgument { name: "test".to_string(), value: "test".to_string(), }; @@ -280,7 +293,7 @@ mod test_deserialize { argument, #[cfg(any(feature = "draft", feature = "2025_06_18"))] context: None, - ref_: CompleteRequestParamsRef::PromptReference(PromptReference::new( + ref_: CompleteRequestRef::PromptReference(PromptReference::new( "test".to_string(), #[cfg(any(feature = "draft", feature = "2025_06_18"))] None, @@ -729,6 +742,7 @@ mod test_deserialize { test_serde(&ref_); } + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] #[test] fn test_read_resource_request() { let params = ReadResourceRequestParams { uri: "test".to_string() }; @@ -868,7 +882,12 @@ mod test_deserialize { fn test_server_notification() { let notif = ServerNotification::CancelledNotification(CancelledNotification::new(CancelledNotificationParams { reason: Some("because".to_string()), + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] request_id: RequestId::Integer(15), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + request_id: Some(RequestId::Integer(15)), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + meta: None, })); test_serde(¬if); } @@ -1009,9 +1028,12 @@ mod test_deserialize { test_serde(¬if); } - #[cfg(any(feature = "draft", feature = "2025_06_18"))] + #[cfg(any(feature = "draft", feature = "2025_06_18", feature = "2025_11_25"))] #[test] fn test_tool_output_schema() { + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + let schema = ToolOutputSchema::new(vec!["hey".to_string()], None, None); + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] let schema = ToolOutputSchema::new(vec!["hey".to_string()], None); test_serde(&schema); } diff --git a/tests/before_2025_11_25/test_2024_11_05_exclusive.rs b/tests/before_2025_11_25/test_2024_11_05_exclusive.rs new file mode 100644 index 0000000..f724a0e --- /dev/null +++ b/tests/before_2025_11_25/test_2024_11_05_exclusive.rs @@ -0,0 +1,85 @@ +//! Test cases applicable only to the specific version(s) of the schema (currently 2024_11_05) + +use super::common::{get_message, re_serialize}; +use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; +use rust_mcp_schema::mcp_2024_11_05::*; + +#[test] +fn test_server_list_resources_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::ListResourcesResult(ListResourcesResult { + meta: None, + next_cursor: None, + resources: vec![Resource { + annotations: None, + description: None, + mime_type: None, + name: "Resource 1".to_string(), + size: None, + uri: "test://static/resource/1".to_string(), + }], + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListResourcesResult(_))) + )); +} + +#[test] +fn test_client_list_resource_templates_request() { + // create a ClientMessage + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::ListResourceTemplatesRequest( + ListResourceTemplatesRequest::new(None), + )), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListResourceTemplatesRequest(_))) + )); +} + +#[test] +fn test_server_list_resource_templates_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::ListResourceTemplatesResult(ListResourceTemplatesResult { + meta: None, + next_cursor: None, + resource_templates: vec![], + })), + )); + + let message: ServerMessage = re_serialize(message); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListResourceTemplatesResult(_))) + )); +} + +#[test] +fn test_server_list_resource_templates_result_sample() { + let message = get_message("res_template_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListResourceTemplatesResult(_))) + )); +} + +#[test] +fn test_client_list_resource_templates_request_sample() { + let message = get_message("req_template_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListResourceTemplatesRequest(_))) + )); +} diff --git a/tests/before_2025_11_25/test_deserialize.rs b/tests/before_2025_11_25/test_deserialize.rs new file mode 100644 index 0000000..56d327f --- /dev/null +++ b/tests/before_2025_11_25/test_deserialize.rs @@ -0,0 +1,342 @@ +#[cfg(feature = "2024_11_05")] +use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; + +#[cfg(feature = "2025_03_26")] +use rust_mcp_schema::mcp_2025_03_26::schema_utils::*; + +#[cfg(feature = "2025_06_18")] +use rust_mcp_schema::mcp_2025_06_18::schema_utils::*; +#[cfg(feature = "2025_06_18")] +use rust_mcp_schema::mcp_2025_06_18::*; + +#[cfg(feature = "draft")] +use rust_mcp_schema::mcp_draft::schema_utils::*; + +#[cfg(feature = "latest")] +use rust_mcp_schema::schema_utils::*; + +#[cfg(feature = "2024_11_05")] +use rust_mcp_schema::mcp_2024_11_05::*; +#[cfg(feature = "2025_03_26")] +use rust_mcp_schema::mcp_2025_03_26::*; +#[cfg(feature = "draft")] +use rust_mcp_schema::mcp_draft::*; +#[cfg(feature = "latest")] +use rust_mcp_schema::*; +use serde_json::json; + +use super::common::get_message; + +/* ---------------------- CLIENT REQUESTS ---------------------- */ +#[test] +fn test_client_initialize_request() { + let message = get_message("req_initialize", LATEST_PROTOCOL_VERSION); + assert!(matches!(&message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::InitializeRequest(_))) + )); + + if let ClientMessage::Request(client_message) = message { + matches!(&client_message.id, &RequestId::Integer(0)); + assert_eq!(client_message.jsonrpc(), JSONRPC_VERSION); + assert_eq!(client_message.method, "initialize"); + + if let RequestFromClient::ClientRequest(ClientRequest::InitializeRequest(request)) = client_message.request { + assert_eq!(request.method(), "initialize"); + assert_eq!(request.params.protocol_version, LATEST_PROTOCOL_VERSION); + assert_eq!(request.params.client_info.name, "mcp-inspector"); + assert_eq!(request.params.client_info.version, "0.0.1"); + assert!(request.params.capabilities.roots.is_some()); + + if let Some(roots) = request.params.capabilities.roots { + assert!(roots.list_changed.is_some()); + assert!(roots.list_changed.unwrap()); + } + } + } +} + +#[test] +fn test_client_list_resources_request() { + let message = get_message("req_resource_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListResourcesRequest(_))) + )); +} + +#[test] +fn test_client_read_resource_request() { + let message = get_message("req_resource_read", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ReadResourceRequest(_))) + )); +} + +#[test] +fn test_client_list_prompts_request() { + let message = get_message("req_prompts_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListPromptsRequest(_))) + )); +} + +#[test] +fn test_client_get_prompt_request() { + let message = get_message("req_prompts_get_1", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::GetPromptRequest(_))) + )); + + let message = get_message("req_prompts_get_2", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::GetPromptRequest(_))) + )); +} + +#[test] +fn test_client_list_tools_request() { + let message = get_message("req_tools_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListToolsRequest(_))) + )); +} + +#[test] +fn test_client_call_tool_request() { + let message = get_message("req_tools_call_1", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::CallToolRequest(_))) + )); + + let message = get_message("req_tools_call_2", LATEST_PROTOCOL_VERSION); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::CallToolRequest(_))) + )); + + let message = get_message("req_tools_call_3", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::CallToolRequest(_))) + )); + + let message = get_message("req_tools_call_4", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::CallToolRequest(_))) + )); +} + +#[test] +fn test_client_ping_request() { + let message = get_message("req_ping", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::PingRequest(_))) + )); +} + +/* ---------------------- CLIENT RESPONSES ---------------------- */ +#[test] +fn test_list_tools_result() { + let message = get_message("res_sampling_create_message_2", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Response(client_message) + if matches!(&client_message.result, ResultFromClient::ClientResult(client_result) + if matches!( client_result, ClientResult::CreateMessageResult(_)) + ) + )); +} +/* ---------------------- SERVER RESPONSES ---------------------- */ + +#[test] +fn test_server_initialize_result() { + let message = get_message("res_initialize", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::InitializeResult(_))) + )); +} + +#[test] +fn test_server_list_resources_result() { + let message = get_message("res_resource_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListResourcesResult(_))) + )); +} + +#[test] +fn test_server_read_resource_result() { + let message = get_message("res_resource_read", LATEST_PROTOCOL_VERSION); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ReadResourceResult(_))) + )); +} + +#[test] +fn test_server_list_prompts_result() { + let message = get_message("res_prompts_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListPromptsResult(_))) + )); +} + +#[test] +fn test_server_get_prompt_result() { + let message = get_message("res_prompts_get_1", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::GetPromptResult(_))) + )); + + let message = get_message("res_prompts_get_2", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::GetPromptResult(_))) + )); +} + +#[test] +fn test_server_list_tools_result() { + let message = get_message("res_tools_list", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListToolsResult(_))) + )); +} + +//TODO: add test case for DRAFT version +#[cfg(any(feature = "2025_03_26", feature = "2024_11_05"))] +#[test] +fn test_server_call_tool_result() { + let message = get_message("res_tools_call_1", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::CallToolResult(_))) + )); + + let message = get_message("res_tools_call_2", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::CallToolResult(_))) + )); + + let message = get_message("res_tools_call_4", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::CallToolResult(_))) + )); +} + +#[test] +fn test_server_ping_result() { + let message = get_message("res_ping", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(_server_result)) + )); +} + +/* ---------------------- CLIENT NOTIFICATIONS ---------------------- */ + +#[test] +fn test_client_notifications() { + //ClientInitializedNotification + let message = get_message("ntf_initialized", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::InitializedNotification(_))) + )); + + //ClientRootsListChangedNotification + let message = get_message("ntf_root_list_changed", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::RootsListChangedNotification(_))) + )); + + //ClientCancelledNotification + let message = get_message("ntf_cancelled", LATEST_PROTOCOL_VERSION); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::CancelledNotification(notification) if notification.params.reason == Some("Request timed out".to_string()))) + )); +} + +/* ---------------------- SERVER REQUESTS ---------------------- */ +#[test] +fn test_server_requests() { + //ServerCreateMessageRequest + let message = get_message("req_sampling_create_message_1", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Request(server_message) + if matches!(&server_message.request,RequestFromServer::ServerRequest(server_request) + if matches!( server_request, ServerRequest::CreateMessageRequest(_))) + )); + + let message = get_message("req_sampling_create_message_2", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Request(server_message) + if matches!(&server_message.request,RequestFromServer::ServerRequest(server_request) + if matches!( server_request, ServerRequest::CreateMessageRequest(_))) + )); +} + +/* ---------------------- CLIENT & SERVER ERRORS ---------------------- */ + +#[test] +fn test_errors() { + let message: ClientMessage = get_message("err_sampling_rejected", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ClientMessage::Error(_))); + + let message: ServerMessage = get_message("err_sampling_rejected", LATEST_PROTOCOL_VERSION); + assert!(matches!(message, ServerMessage::Error(_))); +} + +#[test] +fn test_deserialize_with_wrong_method() { + let payload = r#"{"method":"sampling/INVALID","params":{"maxTokens":0,"messages":[]}}"#; + let result = serde_json::from_str::(payload); + assert!(result.is_err()); +} + +#[test] +fn test_deserialize_with_wrong_jsonrpc_version() { + let payload = r#"{"error":{"code":-32603,"message":"Internal error"},"id":0,"jsonrpc":"1.0"}"#; + + #[cfg(not(any(feature = "draft", feature = "2025_11_25")))] + let result = serde_json::from_str::(payload); + #[cfg(any(feature = "draft", feature = "2025_11_25"))] + let result = serde_json::from_str::(payload); + assert!(result.is_err()); +} + +#[test] +fn test_server_notification_deserialization() { + let json = json!({ + "method": "notifications/progress", + "params": { + "progress": 50, + "status": "test", + "task_id": "test", + "progressToken":"xyz" + } + }); + + let notif: ServerNotification = serde_json::from_value(json).unwrap(); + if let ServerNotification::ProgressNotification(req) = notif { + assert_eq!(req.method(), "notifications/progress"); + } else { + panic!("Unexpected variant"); + } +} diff --git a/tests/before_2025_11_25/test_serialize.rs b/tests/before_2025_11_25/test_serialize.rs new file mode 100644 index 0000000..0c333fc --- /dev/null +++ b/tests/before_2025_11_25/test_serialize.rs @@ -0,0 +1,899 @@ +use std::str::FromStr; +use std::vec; + +#[cfg(feature = "2024_11_05")] +use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; +#[cfg(feature = "2024_11_05")] +use rust_mcp_schema::mcp_2024_11_05::*; + +#[cfg(feature = "2025_06_18")] +use rust_mcp_schema::mcp_2025_06_18::schema_utils::*; +#[cfg(feature = "2025_06_18")] +use rust_mcp_schema::mcp_2025_06_18::*; + +#[cfg(feature = "2025_03_26")] +use rust_mcp_schema::mcp_2025_03_26::schema_utils::*; +#[cfg(feature = "2025_03_26")] +use rust_mcp_schema::mcp_2025_03_26::*; + +#[cfg(feature = "draft")] +use rust_mcp_schema::mcp_draft::schema_utils::*; +#[cfg(feature = "draft")] +use rust_mcp_schema::mcp_draft::*; + +#[cfg(feature = "latest")] +use rust_mcp_schema::schema_utils::*; +#[cfg(feature = "latest")] +use rust_mcp_schema::*; + +use serde_json::json; + +use super::common::re_serialize; + +/* ---------------------- CLIENT REQUESTS ---------------------- */ +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_initialize_request() { + // create a ClientMessage + let request = InitializeRequest::new(InitializeRequestParams { + capabilities: ClientCapabilities { + experimental: None, + roots: None, + sampling: None, + #[cfg(any(feature = "draft", feature = "2025_06_18"))] + elicitation: None, + }, + client_info: Implementation { + name: "client-name".to_string(), + version: "0.0.1".to_string(), + #[cfg(any(feature = "draft", feature = "2025_06_18"))] + title: None, + }, + protocol_version: LATEST_PROTOCOL_VERSION.to_string(), + }); + + let client_request = ClientRequest::InitializeRequest(request); + + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(client_request.clone()), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(message.is_request()); + assert!(!message.is_response()); + assert!(!message.is_notification()); + assert!(!message.is_error()); + assert!(message.message_type() == MessageTypes::Request); + assert!(matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15))); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::InitializeRequest(_))) + )); + + // test From for RequestFromClient + let message: ClientMessage = + ClientMessage::Request(ClientJsonrpcRequest::new(RequestId::Integer(15), client_request.into())); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::InitializeRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_list_resources_request() { + // create a ClientMessage + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::ListResourcesRequest(ListResourcesRequest::new(None))), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListResourcesRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_read_resource_request() { + // create a ClientMessage + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::ReadResourceRequest(ReadResourceRequest::new( + ReadResourceRequestParams { + uri: "test://static/resource/1".to_string(), + }, + ))), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ReadResourceRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_list_prompts_request() { + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::ListPromptsRequest(ListPromptsRequest::new(None))), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListPromptsRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_get_prompt_request() { + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::GetPromptRequest(GetPromptRequest::new( + GetPromptRequestParams { + name: "simple_prompt".to_string(), + arguments: None, + }, + ))), + )); + + let message: ClientMessage = re_serialize(message); + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::GetPromptRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_list_tools_request() { + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::ListToolsRequest(ListToolsRequest::new(None))), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::ListToolsRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_call_tool_request() { + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::CallToolRequest(CallToolRequest::new(CallToolRequestParams { + name: "add".to_string(), + arguments: None, + }))), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::CallToolRequest(_))) + )); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_ping_request() { + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::PingRequest(PingRequest::new(None))), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::PingRequest(_))) + )); +} + +#[test] +fn test_client_custom_request() { + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::CustomRequest(json!({"method":"my_custom_method"})), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::CustomRequest(_)) && client_message.method == "my_custom_method" + )); + + // test From for RequestFromClient + let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( + RequestId::Integer(15), + json!({"method":"my_custom_method"}).into(), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Request(client_message) + if matches!(&client_message.request, RequestFromClient::CustomRequest(_)) && client_message.method == "my_custom_method" + )); +} + +/* ---------------------- CLIENT RESPONSES ---------------------- */ +#[test] +fn test_list_tools_result() { + let client_result = ClientResult::CreateMessageResult(CreateMessageResult { + content: CreateMessageResultContent::TextContent(TextContent::new( + "This is a stub response.".to_string(), + None, + #[cfg(any(feature = "draft", feature = "2025_06_18"))] + None, + )), + meta: None, + model: "stub-model".to_string(), + role: Role::Assistant, + stop_reason: Some("endTurn".to_string()), + }); + + let message: ClientMessage = ClientMessage::Response(ClientJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromClient::ClientResult(client_result.clone()), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(!message.is_request()); + assert!(message.is_response()); + assert!(!message.is_notification()); + assert!(!message.is_error()); + assert!(message.message_type() == MessageTypes::Response); + assert!(matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15))); + + assert!(matches!(message, ClientMessage::Response(client_message) + if matches!(&client_message.result, ResultFromClient::ClientResult(client_result) + if matches!( client_result, ClientResult::CreateMessageResult(_)) + ) + )); + + // test From for ResultFromClient + let message: ClientMessage = + ClientMessage::Response(ClientJsonrpcResponse::new(RequestId::Integer(15), client_result.into())); + + assert!(matches!(message, ClientMessage::Response(client_message) + if matches!(&client_message.result, ResultFromClient::ClientResult(client_result) + if matches!( client_result, ClientResult::CreateMessageResult(_)) + ) + )); +} + +/* ---------------------- SERVER RESPONSES ---------------------- */ + +#[test] +fn test_server_initialize_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::InitializeResult(InitializeResult { + capabilities: ServerCapabilities { + experimental: None, + logging: None, + prompts: None, + resources: None, + tools: None, + #[cfg(any(feature = "2025_03_26", feature = "draft", feature = "2025_06_18"))] + completions: None, + }, + instructions: None, + meta: None, + protocol_version: LATEST_PROTOCOL_VERSION.to_string(), + server_info: Implementation { + #[cfg(feature = "draft")] + icons: vec![], + #[cfg(feature = "draft")] + website_url: None, + name: "example-servers/everything".to_string(), + version: "1.0.0".to_string(), + #[cfg(any(feature = "2025_06_18", feature = "draft"))] + title: None, + }, + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(!message.is_request()); + assert!(message.is_response()); + assert!(!message.is_notification()); + assert!(!message.is_error()); + assert!(message.message_type() == MessageTypes::Response); + + assert!(matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15))); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::InitializeResult(_))) + )); +} + +#[test] +fn test_server_read_resource_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::ReadResourceResult(ReadResourceResult { + contents: vec![], + meta: None, + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ReadResourceResult(_))) + )); +} + +#[test] +fn test_server_list_prompts_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::ListPromptsResult(ListPromptsResult { + meta: None, + next_cursor: None, + prompts: vec![], + })), + )); + + let message: ServerMessage = re_serialize(message); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListPromptsResult(_))) + )); +} + +#[test] +fn test_server_get_prompt_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::GetPromptResult(GetPromptResult { + meta: None, + description: None, + messages: vec![], + })), + )); + + let message: ServerMessage = re_serialize(message); + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::GetPromptResult(_))) + )); +} + +#[test] +fn test_server_list_tools_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::ListToolsResult(ListToolsResult { + meta: None, + next_cursor: None, + tools: vec![], + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListToolsResult(_))) + )); +} + +#[cfg(any(feature = "2025_03_26", feature = "2024_11_05"))] +#[test] +fn test_server_call_tool_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::CallToolResult(CallToolResult { + meta: None, + content: vec![], + is_error: None, + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::CallToolResult(_))) + )); +} + +#[test] +fn test_server_custom_result() { + let custom_result: serde_json::Map = json!({ + "custom_key":"custom_value", + "custom_number": 15.21 + }) + .as_object() + .unwrap() + .clone(); + + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::Result(Result { + meta: None, + extra: Some(custom_result), + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::Result(result) + if result.extra.is_some() + )) + )); +} + +/* ---------------------- CLIENT NOTIFICATIONS ---------------------- */ + +#[test] +fn test_client_initialized_notification() { + let init_notification = InitializedNotification::new(Some(InitializedNotificationParams { meta: None, extra: None })); + + let message: ClientMessage = ClientMessage::Notification(ClientJsonrpcNotification::new( + NotificationFromClient::ClientNotification(ClientNotification::InitializedNotification(init_notification.clone())), + )); + + let message: ClientMessage = re_serialize(message); + + assert!(!message.is_request()); + assert!(!message.is_response()); + assert!(message.is_notification()); + assert!(!message.is_error()); + assert!(message.message_type() == MessageTypes::Notification); + assert!(message.request_id().is_none()); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::InitializedNotification(_))) + )); + + // test From for NotificationFromClient + let message: ClientMessage = + ClientMessage::Notification(ClientJsonrpcNotification::new(init_notification.clone().into())); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::InitializedNotification(_))) + )); + + // test From for ClientJsonrpcNotification + let message: ClientMessage = ClientMessage::Notification(init_notification.into()); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::InitializedNotification(_))) + )); +} + +#[test] +fn test_client_root_list_changed_notification() { + let message: ClientMessage = + ClientMessage::Notification(ClientJsonrpcNotification::new(NotificationFromClient::ClientNotification( + ClientNotification::RootsListChangedNotification(RootsListChangedNotification::new(None)), + ))); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::RootsListChangedNotification(_))) + )); +} + +#[test] +fn test_client_cancelled_notification() { + let message: ClientMessage = + ClientMessage::Notification(ClientJsonrpcNotification::new(NotificationFromClient::ClientNotification( + ClientNotification::CancelledNotification(CancelledNotification::new(CancelledNotificationParams { + reason: Some("Request timed out".to_string()), + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] + request_id: RequestId::Integer(15), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + request_id: Some(RequestId::Integer(15)), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + meta: None, + })), + ))); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) + if matches!( client_notification, ClientNotification::CancelledNotification(notification) if notification.params.reason == Some("Request timed out".to_string()))) + )); +} + +#[test] +fn test_client_custom_notification() { + let message: ClientMessage = ClientMessage::Notification(ClientJsonrpcNotification::new( + NotificationFromClient::CustomNotification(json!({"method":"my_notification"})), + )); + + let message: ClientMessage = re_serialize(message); + + // test Display trait + let str = message.to_string(); + assert_eq!(str, "{\"jsonrpc\":\"2.0\",\"method\":\"my_notification\",\"params\":{\"method\":\"my_notification\",\"params\":{\"method\":\"my_notification\"}}}"); + + assert!(matches!(message, ClientMessage::Notification(client_message) + if matches!(&client_message.notification, NotificationFromClient::CustomNotification(_)) && client_message.method == "my_notification" + )); +} + +/* ---------------------- SERVER NOTIFICATIONS ---------------------- */ +#[test] +fn test_server_cancel_notification() { + let cancel_notification = CancelledNotification::new(CancelledNotificationParams { + reason: Some("Request timed out".to_string()), + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] + request_id: RequestId::Integer(15), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + request_id: Some(RequestId::Integer(15)), + #[cfg(any(feature = "2025_11_25", feature = "draft"))] + meta: None, + }); + let message: ServerMessage = ServerMessage::Notification(ServerJsonrpcNotification::new( + NotificationFromServer::ServerNotification(ServerNotification::CancelledNotification(cancel_notification.clone())), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(!message.is_request()); + assert!(!message.is_response()); + assert!(message.is_notification()); + assert!(!message.is_error()); + assert!(message.message_type() == MessageTypes::Notification); + assert!(message.request_id().is_none()); + + assert!(matches!(message, ServerMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification) + if matches!( client_notification, ServerNotification::CancelledNotification(_))) + )); + + // test From for NotificationFromServer + let message: ServerMessage = + ServerMessage::Notification(ServerJsonrpcNotification::new(cancel_notification.clone().into())); + + assert!(matches!(message, ServerMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification) + if matches!( client_notification, ServerNotification::CancelledNotification(_))) + )); + + // test From for ServerNotification + let message: ServerMessage = ServerMessage::Notification(cancel_notification.into()); + + assert!(matches!(message, ServerMessage::Notification(client_message) + if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification) + if matches!( client_notification, ServerNotification::CancelledNotification(_))) + )); +} + +/* ---------------------- SERVER REQUESTS ---------------------- */ +#[cfg(not(feature = "draft"))] +#[test] +fn test_server_requests() { + let message: ServerMessage = ServerMessage::Request(ServerJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromServer::ServerRequest(ServerRequest::CreateMessageRequest(CreateMessageRequest::new( + CreateMessageRequestParams { + include_context: None, + max_tokens: 21, + messages: vec![], + metadata: None, + model_preferences: None, + stop_sequences: vec![], + system_prompt: None, + temperature: None, + }, + ))), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(message.is_request()); + assert!(!message.is_response()); + assert!(!message.is_notification()); + assert!(!message.is_error()); + assert!(message.message_type() == MessageTypes::Request); + + assert!(matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15))); + + assert!(matches!(message, ServerMessage::Request(server_message) + if matches!(&server_message.request,RequestFromServer::ServerRequest(server_request) + if matches!( server_request, ServerRequest::CreateMessageRequest(_))) + )); +} + +#[test] +fn test_client_custom_server_request() { + let message: ServerMessage = ServerMessage::Request(ServerJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromServer::CustomRequest(json!({"method":"my_custom_method"})), + )); + + // test Display trait + let str = message.to_string(); + assert_eq!( + str, + "{\"id\":15,\"jsonrpc\":\"2.0\",\"method\":\"my_custom_method\",\"params\":{\"method\":\"my_custom_method\"}}" + ); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Request(server_message) + if matches!(&server_message.request, RequestFromServer::CustomRequest(_)) && server_message.method == "my_custom_method" + )); +} + +/* ---------------------- CLIENT & SERVER ERRORS ---------------------- */ + +#[test] +fn test_errors() { + let message: ClientMessage = ClientMessage::Error(JsonrpcError::create( + RequestId::Integer(15), + RpcErrorCodes::INTERNAL_ERROR, + "err_sampling_rejected".to_string(), + None, + )); + + let message: ClientMessage = re_serialize(message); + + assert!(matches!(message, ClientMessage::Error(_))); + assert!(!message.is_request()); + assert!(!message.is_response()); + assert!(!message.is_notification()); + assert!(message.is_error()); + assert!(message.message_type() == MessageTypes::Error); + + assert!(matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15))); + + let message: ServerMessage = ServerMessage::Error(JsonrpcError::create( + RequestId::Integer(15), + RpcErrorCodes::INTERNAL_ERROR, + "err_sampling_rejected".to_string(), + None, + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Error(_))); + + assert!(!message.is_request()); + assert!(!message.is_response()); + assert!(!message.is_notification()); + assert!(message.is_error()); + assert!(message.message_type() == MessageTypes::Error); + + assert!(matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15))); +} + +/* ---------------------- RpcError ---------------------- */ +#[test] +fn test_new() { + let error_object = RpcError::new( + RpcErrorCodes::METHOD_NOT_FOUND, + "Error Message!".to_string(), + Some(json!({"details":"error detail"})), + ); + + let error_object: RpcError = re_serialize(error_object); + + assert_eq!(error_object.code, -32601); + assert_eq!(error_object.message, "Error Message!".to_string()); + matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); +} + +#[test] +fn test_method_not_found() { + let error_object = RpcError::method_not_found(); + assert_eq!(error_object.code, -32601); + assert_eq!(error_object.message, "Method not found".to_string()); + assert!(error_object.data.is_none()); + + // builder pattern + let error_object = RpcError::method_not_found() + .with_message("Error Message!".to_string()) + .with_data(Some(json!({"details":"error detail"}))); + + let error_object: RpcError = re_serialize(error_object); + + assert_eq!(error_object.code, -32601); + assert_eq!(error_object.message, "Error Message!".to_string()); + matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); +} + +#[test] +fn test_invalid_params() { + let error_object = RpcError::invalid_params(); + assert_eq!(error_object.code, -32602); + assert_eq!(error_object.message, "Invalid params".to_string()); + assert!(error_object.data.is_none()); + + // builder pattern + let error_object = RpcError::invalid_params() + .with_message("Error Message!".to_string()) + .with_data(Some(json!({"details":"error detail"}))); + + let error_object: RpcError = re_serialize(error_object); + + assert_eq!(error_object.code, -32602); + assert_eq!(error_object.message, "Error Message!".to_string()); + matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); +} + +#[test] +fn test_invalid_request() { + let error_object = RpcError::invalid_request(); + assert_eq!(error_object.code, -32600); + assert_eq!(error_object.message, "Invalid request".to_string()); + assert!(error_object.data.is_none()); + + // builder pattern + let error_object = RpcError::invalid_request() + .with_message("Error Message!".to_string()) + .with_data(Some(json!({"details":"error detail"}))); + + let error_object: RpcError = re_serialize(error_object); + + assert_eq!(error_object.code, -32600); + assert_eq!(error_object.message, "Error Message!".to_string()); + matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); +} + +#[test] +fn test_internal_error() { + let error_object = RpcError::internal_error(); + assert_eq!(error_object.code, -32603); + assert_eq!(error_object.message, "Internal error".to_string()); + assert!(error_object.data.is_none()); + + // builder pattern + let error_object = RpcError::internal_error() + .with_message("Error Message!".to_string()) + .with_data(Some(json!({"details":"error detail"}))); + + let error_object: RpcError = re_serialize(error_object); + + assert_eq!(error_object.code, -32603); + assert_eq!(error_object.message, "Error Message!".to_string()); + matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); +} + +#[test] +fn test_parse_error() { + let error_object = RpcError::parse_error(); + assert_eq!(error_object.code, -32700); + assert_eq!(error_object.message, "Parse error".to_string()); + assert!(error_object.data.is_none()); + + // builder pattern + let error_object = RpcError::parse_error() + .with_message("Error Message!".to_string()) + .with_data(Some(json!({"details":"error detail"}))); + + let error_object: RpcError = re_serialize(error_object); + + assert_eq!(error_object.code, -32700); + assert_eq!(error_object.message, "Error Message!".to_string()); + matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); +} + +#[cfg(not(feature = "draft"))] +#[test] +fn test_client_jsonrpc_request() { + let message = ClientJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromClient::ClientRequest(ClientRequest::PingRequest(PingRequest::new(None))), + ); + + let message_str = message.to_string(); + + let message: ClientJsonrpcRequest = ClientJsonrpcRequest::from_str(&message_str).unwrap(); + + assert!(matches!(&message.request, RequestFromClient::ClientRequest(client_request) + if matches!(client_request, ClientRequest::PingRequest(_)))); +} + +#[test] +fn test_client_jsonrpc_notification() { + let message = ClientJsonrpcNotification::new(NotificationFromClient::CustomNotification(json!({"method":"notify"}))); + + let message_str = message.to_string(); + + let message: ClientJsonrpcNotification = ClientJsonrpcNotification::from_str(&message_str).unwrap(); + + assert!( + matches!(&message.notification, NotificationFromClient::CustomNotification(client_request) + if client_request["method"] == "notify") + ); +} + +#[test] +fn test_server_jsonrpc_request() { + let message = ServerJsonrpcRequest::new( + RequestId::Integer(15), + RequestFromServer::CustomRequest(json!({"method":"req"})), + ); + + let message_str = message.to_string(); + + let message: ServerJsonrpcRequest = ServerJsonrpcRequest::from_str(&message_str).unwrap(); + + assert!(matches!(&message.request, RequestFromServer::CustomRequest(request) + if request["method"] == "req")); +} + +#[test] +fn test_server_jsonrpc_notification() { + let message = ServerJsonrpcNotification::new(NotificationFromServer::CustomNotification(json!({"method":"notify"}))); + + let message_str = message.to_string(); + + let message: ServerJsonrpcNotification = ServerJsonrpcNotification::from_str(&message_str).unwrap(); + + assert!( + matches!(&message.notification, NotificationFromServer::CustomNotification(server_request) + if server_request["method"] == "notify") + ); +} + +#[test] +fn test_server_list_resources_result() { + let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( + RequestId::Integer(15), + ResultFromServer::ServerResult(ServerResult::ListResourcesResult(ListResourcesResult { + meta: None, + next_cursor: None, + resources: vec![Resource { + #[cfg(feature = "draft")] + icons: vec![], + annotations: None, + description: None, + mime_type: None, + name: "Resource 1".to_string(), + uri: "test://static/resource/1".to_string(), + size: None, + #[cfg(any(feature = "2025_06_18", feature = "draft"))] + meta: None, + #[cfg(any(feature = "2025_06_18", feature = "draft"))] + title: None, + }], + })), + )); + + let message: ServerMessage = re_serialize(message); + + assert!(matches!(message, ServerMessage::Response(server_message) + if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) + if matches!(server_result, ServerResult::ListResourcesResult(_))) + )); +} diff --git a/tests/common/common.rs b/tests/common/common.rs index 4ba5b93..bd95c89 100644 --- a/tests/common/common.rs +++ b/tests/common/common.rs @@ -1,12 +1,13 @@ +use serde::{Deserialize, Serialize}; use serde_json::Value; use std::str::FromStr; use std::sync::OnceLock; use std::{collections::HashMap, env::current_dir, fs}; const JSON_FILENAME: &str = "sample_mcp_messages.json"; - +#[allow(unused)] static TEST_DATA: OnceLock = OnceLock::new(); - +#[allow(unused)] pub fn get_test_payload(key: &str) -> &String { let test_data = TEST_DATA.get_or_init(TestData::new); test_data.test_payload(key) @@ -42,6 +43,7 @@ impl TestData { } } +#[allow(unused)] /// Converts a message to a JSON string and then deserializes it back. /// Tests help to ensures consistent serialization and deserialization across all enum variants. pub fn re_serialize(message: T) -> T @@ -56,6 +58,7 @@ where T::from_str(&message_str).unwrap() } +#[allow(unused)] /// get a test message payload from the sample_mcp_messages.json by key pub fn get_message(test_payload_key: &str, version: &str) -> T where @@ -66,3 +69,21 @@ where //{"id":13,"jsonrpc":"2.0","method":"tools/list","params":{}} T::from_str(&message_str).unwrap() } + +#[allow(unused)] +pub fn round_trip_test(original: &T) +where + T: Serialize + for<'de> Deserialize<'de> + std::fmt::Debug, +{ + // Serialize the original object to JSON + let json = serde_json::to_string(original).expect("Failed to serialize original object"); + + // Deserialize back to the same type + let deserialized: T = serde_json::from_str(&json).expect("Failed to deserialize JSON"); + + // Serialize the deserialized object to JSON + let json_deserialized = serde_json::to_string(&deserialized).expect("Failed to serialize deserialized object"); + + // Compare the JSON strings to ensure consistency + assert_eq!(json, json_deserialized, "JSON serialization mismatch for {original:?}"); +} diff --git a/tests/main.rs b/tests/main.rs new file mode 100644 index 0000000..b6d7327 --- /dev/null +++ b/tests/main.rs @@ -0,0 +1,5 @@ +#[cfg(any(feature = "2024_11_05", feature = "2025_03_26", feature = "2025_06_18"))] +mod before_2025_11_25; + +#[cfg(feature = "2025_11_25")] +mod v2025_11_25; diff --git a/tests/test_deserialize.rs b/tests/test_deserialize.rs deleted file mode 100644 index 093bc09..0000000 --- a/tests/test_deserialize.rs +++ /dev/null @@ -1,336 +0,0 @@ -#[path = "common/common.rs"] -pub mod common; - -mod test_deserialize { - #[cfg(feature = "2024_11_05")] - use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; - #[cfg(feature = "2025_03_26")] - use rust_mcp_schema::mcp_2025_03_26::schema_utils::*; - #[cfg(feature = "draft")] - use rust_mcp_schema::mcp_draft::schema_utils::*; - #[cfg(any(feature = "latest", feature = "2025_06_18"))] - use rust_mcp_schema::schema_utils::*; - - #[cfg(feature = "2024_11_05")] - use rust_mcp_schema::mcp_2024_11_05::*; - #[cfg(feature = "2025_03_26")] - use rust_mcp_schema::mcp_2025_03_26::*; - #[cfg(feature = "draft")] - use rust_mcp_schema::mcp_draft::*; - #[cfg(any(feature = "latest", feature = "2025_06_18"))] - use rust_mcp_schema::*; - use serde_json::json; - - use super::common::get_message; - - /* ---------------------- CLIENT REQUESTS ---------------------- */ - #[test] - fn test_client_initialize_request() { - let message = get_message("req_initialize", LATEST_PROTOCOL_VERSION); - assert!(matches!(&message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::InitializeRequest(_))) - )); - - if let ClientMessage::Request(client_message) = message { - matches!(&client_message.id, &RequestId::Integer(0)); - assert_eq!(client_message.jsonrpc(), JSONRPC_VERSION); - assert_eq!(client_message.method, "initialize"); - - if let RequestFromClient::ClientRequest(ClientRequest::InitializeRequest(request)) = client_message.request { - assert_eq!(request.method(), "initialize"); - assert_eq!(request.params.protocol_version, LATEST_PROTOCOL_VERSION); - assert_eq!(request.params.client_info.name, "mcp-inspector"); - assert_eq!(request.params.client_info.version, "0.0.1"); - assert!(request.params.capabilities.roots.is_some()); - - if let Some(roots) = request.params.capabilities.roots { - assert!(roots.list_changed.is_some()); - assert!(roots.list_changed.unwrap()); - } - } - } - } - - #[test] - fn test_client_list_resources_request() { - let message = get_message("req_resource_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListResourcesRequest(_))) - )); - } - - #[test] - fn test_client_read_resource_request() { - let message = get_message("req_resource_read", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ReadResourceRequest(_))) - )); - } - - #[test] - fn test_client_list_prompts_request() { - let message = get_message("req_prompts_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListPromptsRequest(_))) - )); - } - - #[test] - fn test_client_get_prompt_request() { - let message = get_message("req_prompts_get_1", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::GetPromptRequest(_))) - )); - - let message = get_message("req_prompts_get_2", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::GetPromptRequest(_))) - )); - } - - #[test] - fn test_client_list_tools_request() { - let message = get_message("req_tools_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListToolsRequest(_))) - )); - } - - #[test] - fn test_client_call_tool_request() { - let message = get_message("req_tools_call_1", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::CallToolRequest(_))) - )); - - let message = get_message("req_tools_call_2", LATEST_PROTOCOL_VERSION); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::CallToolRequest(_))) - )); - - let message = get_message("req_tools_call_3", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::CallToolRequest(_))) - )); - - let message = get_message("req_tools_call_4", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::CallToolRequest(_))) - )); - } - - #[test] - fn test_client_ping_request() { - let message = get_message("req_ping", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::PingRequest(_))) - )); - } - - /* ---------------------- CLIENT RESPONSES ---------------------- */ - #[test] - fn test_list_tools_result() { - let message = get_message("res_sampling_create_message_2", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Response(client_message) - if matches!(&client_message.result, ResultFromClient::ClientResult(client_result) - if matches!( client_result, ClientResult::CreateMessageResult(_)) - ) - )); - } - /* ---------------------- SERVER RESPONSES ---------------------- */ - - #[test] - fn test_server_initialize_result() { - let message = get_message("res_initialize", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::InitializeResult(_))) - )); - } - - #[test] - fn test_server_list_resources_result() { - let message = get_message("res_resource_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListResourcesResult(_))) - )); - } - - #[test] - fn test_server_read_resource_result() { - let message = get_message("res_resource_read", LATEST_PROTOCOL_VERSION); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ReadResourceResult(_))) - )); - } - - #[test] - fn test_server_list_prompts_result() { - let message = get_message("res_prompts_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListPromptsResult(_))) - )); - } - - #[test] - fn test_server_get_prompt_result() { - let message = get_message("res_prompts_get_1", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::GetPromptResult(_))) - )); - - let message = get_message("res_prompts_get_2", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::GetPromptResult(_))) - )); - } - - #[test] - fn test_server_list_tools_result() { - let message = get_message("res_tools_list", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListToolsResult(_))) - )); - } - - //TODO: add test case for DRAFT version - #[cfg(any(feature = "2025_03_26", feature = "2024_11_05"))] - #[test] - fn test_server_call_tool_result() { - let message = get_message("res_tools_call_1", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::CallToolResult(_))) - )); - - let message = get_message("res_tools_call_2", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::CallToolResult(_))) - )); - - let message = get_message("res_tools_call_4", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::CallToolResult(_))) - )); - } - - #[test] - fn test_server_ping_result() { - let message = get_message("res_ping", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(_server_result)) - )); - } - - /* ---------------------- CLIENT NOTIFICATIONS ---------------------- */ - - #[test] - fn test_client_notifications() { - //ClientInitializedNotification - let message = get_message("ntf_initialized", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::InitializedNotification(_))) - )); - - //ClientRootsListChangedNotification - let message = get_message("ntf_root_list_changed", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::RootsListChangedNotification(_))) - )); - - //ClientCancelledNotification - let message = get_message("ntf_cancelled", LATEST_PROTOCOL_VERSION); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::CancelledNotification(notification) if notification.params.reason == Some("Request timed out".to_string()))) - )); - } - - /* ---------------------- SERVER REQUESTS ---------------------- */ - #[test] - fn test_server_requests() { - //ServerCreateMessageRequest - let message = get_message("req_sampling_create_message_1", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Request(server_message) - if matches!(&server_message.request,RequestFromServer::ServerRequest(server_request) - if matches!( server_request, ServerRequest::CreateMessageRequest(_))) - )); - - let message = get_message("req_sampling_create_message_2", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Request(server_message) - if matches!(&server_message.request,RequestFromServer::ServerRequest(server_request) - if matches!( server_request, ServerRequest::CreateMessageRequest(_))) - )); - } - - /* ---------------------- CLIENT & SERVER ERRORS ---------------------- */ - - #[test] - fn test_errors() { - let message: ClientMessage = get_message("err_sampling_rejected", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ClientMessage::Error(_))); - - let message: ServerMessage = get_message("err_sampling_rejected", LATEST_PROTOCOL_VERSION); - assert!(matches!(message, ServerMessage::Error(_))); - } - - #[test] - fn test_deserialize_with_wrong_method() { - let payload = r#"{"method":"sampling/INVALID","params":{"maxTokens":0,"messages":[]}}"#; - let result = serde_json::from_str::(payload); - assert!(result.is_err()); - } - - #[test] - fn test_deserialize_with_wrong_jsonrpc_version() { - let payload = r#"{"error":{"code":-32603,"message":"Internal error"},"id":0,"jsonrpc":"1.0"}"#; - - let result = serde_json::from_str::(payload); - assert!(result.is_err()); - } - - #[test] - fn test_server_notification_deserialization() { - let json = json!({ - "method": "notifications/progress", - "params": { - "progress": 50, - "status": "test", - "task_id": "test", - "progressToken":"xyz" - } - }); - - let notif: ServerNotification = serde_json::from_value(json).unwrap(); - if let ServerNotification::ProgressNotification(req) = notif { - assert_eq!(req.method(), "notifications/progress"); - } else { - panic!("Unexpected variant"); - } - } -} diff --git a/tests/test_serialize.rs b/tests/test_serialize.rs deleted file mode 100644 index e6aed94..0000000 --- a/tests/test_serialize.rs +++ /dev/null @@ -1,904 +0,0 @@ -#[path = "common/common.rs"] -pub mod common; - -mod test_serialize { - use std::str::FromStr; - use std::vec; - - #[cfg(feature = "2024_11_05")] - use rust_mcp_schema::mcp_2024_11_05::schema_utils::*; - #[cfg(feature = "2024_11_05")] - use rust_mcp_schema::mcp_2024_11_05::*; - - #[cfg(feature = "2025_03_26")] - use rust_mcp_schema::mcp_2025_03_26::schema_utils::*; - #[cfg(feature = "2025_03_26")] - use rust_mcp_schema::mcp_2025_03_26::*; - - #[cfg(feature = "draft")] - use rust_mcp_schema::mcp_draft::schema_utils::*; - #[cfg(feature = "draft")] - use rust_mcp_schema::mcp_draft::*; - - #[cfg(feature = "latest")] - use rust_mcp_schema::schema_utils::*; - #[cfg(feature = "latest")] - use rust_mcp_schema::*; - - use serde_json::json; - - use super::common::re_serialize; - - /* ---------------------- CLIENT REQUESTS ---------------------- */ - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_initialize_request() { - // create a ClientMessage - let request = InitializeRequest::new(InitializeRequestParams { - capabilities: ClientCapabilities { - experimental: None, - roots: None, - sampling: None, - #[cfg(any(feature = "draft", feature = "2025_06_18"))] - elicitation: None, - }, - client_info: Implementation { - name: "client-name".to_string(), - version: "0.0.1".to_string(), - #[cfg(any(feature = "draft", feature = "2025_06_18"))] - title: None, - }, - protocol_version: LATEST_PROTOCOL_VERSION.to_string(), - }); - - let client_request = ClientRequest::InitializeRequest(request); - - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(client_request.clone()), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(message.is_request()); - assert!(!message.is_response()); - assert!(!message.is_notification()); - assert!(!message.is_error()); - assert!(message.message_type() == MessageTypes::Request); - assert!( - matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15)) - ); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::InitializeRequest(_))) - )); - - // test From for RequestFromClient - let message: ClientMessage = - ClientMessage::Request(ClientJsonrpcRequest::new(RequestId::Integer(15), client_request.into())); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::InitializeRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_list_resources_request() { - // create a ClientMessage - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::ListResourcesRequest(ListResourcesRequest::new(None))), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListResourcesRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_read_resource_request() { - // create a ClientMessage - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::ReadResourceRequest(ReadResourceRequest::new( - ReadResourceRequestParams { - uri: "test://static/resource/1".to_string(), - }, - ))), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ReadResourceRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_list_prompts_request() { - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::ListPromptsRequest(ListPromptsRequest::new(None))), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListPromptsRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_get_prompt_request() { - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::GetPromptRequest(GetPromptRequest::new( - GetPromptRequestParams { - name: "simple_prompt".to_string(), - arguments: None, - }, - ))), - )); - - let message: ClientMessage = re_serialize(message); - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::GetPromptRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_list_tools_request() { - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::ListToolsRequest(ListToolsRequest::new(None))), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::ListToolsRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_call_tool_request() { - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::CallToolRequest(CallToolRequest::new(CallToolRequestParams { - name: "add".to_string(), - arguments: None, - }))), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::CallToolRequest(_))) - )); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_ping_request() { - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::PingRequest(PingRequest::new(None))), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::PingRequest(_))) - )); - } - - #[test] - fn test_client_custom_request() { - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::CustomRequest(json!({"method":"my_custom_method"})), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::CustomRequest(_)) && client_message.method == "my_custom_method" - )); - - // test From for RequestFromClient - let message: ClientMessage = ClientMessage::Request(ClientJsonrpcRequest::new( - RequestId::Integer(15), - json!({"method":"my_custom_method"}).into(), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Request(client_message) - if matches!(&client_message.request, RequestFromClient::CustomRequest(_)) && client_message.method == "my_custom_method" - )); - } - - /* ---------------------- CLIENT RESPONSES ---------------------- */ - #[test] - fn test_list_tools_result() { - let client_result = ClientResult::CreateMessageResult(CreateMessageResult { - content: CreateMessageResultContent::TextContent(TextContent::new( - "This is a stub response.".to_string(), - None, - #[cfg(any(feature = "draft", feature = "2025_06_18"))] - None, - )), - meta: None, - model: "stub-model".to_string(), - role: Role::Assistant, - stop_reason: Some("endTurn".to_string()), - }); - - let message: ClientMessage = ClientMessage::Response(ClientJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromClient::ClientResult(client_result.clone()), - )); - - let message: ClientMessage = re_serialize(message); - - assert!(!message.is_request()); - assert!(message.is_response()); - assert!(!message.is_notification()); - assert!(!message.is_error()); - assert!(message.message_type() == MessageTypes::Response); - assert!( - matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15)) - ); - - assert!(matches!(message, ClientMessage::Response(client_message) - if matches!(&client_message.result, ResultFromClient::ClientResult(client_result) - if matches!( client_result, ClientResult::CreateMessageResult(_)) - ) - )); - - // test From for ResultFromClient - let message: ClientMessage = - ClientMessage::Response(ClientJsonrpcResponse::new(RequestId::Integer(15), client_result.into())); - - assert!(matches!(message, ClientMessage::Response(client_message) - if matches!(&client_message.result, ResultFromClient::ClientResult(client_result) - if matches!( client_result, ClientResult::CreateMessageResult(_)) - ) - )); - } - - /* ---------------------- SERVER RESPONSES ---------------------- */ - - #[test] - fn test_server_initialize_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::InitializeResult(InitializeResult { - capabilities: ServerCapabilities { - experimental: None, - logging: None, - prompts: None, - resources: None, - tools: None, - #[cfg(any(feature = "2025_03_26", feature = "draft", feature = "2025_06_18"))] - completions: None, - }, - instructions: None, - meta: None, - protocol_version: LATEST_PROTOCOL_VERSION.to_string(), - server_info: Implementation { - #[cfg(feature = "draft")] - icons: vec![], - #[cfg(feature = "draft")] - website_url: None, - name: "example-servers/everything".to_string(), - version: "1.0.0".to_string(), - #[cfg(any(feature = "2025_06_18", feature = "draft"))] - title: None, - }, - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(!message.is_request()); - assert!(message.is_response()); - assert!(!message.is_notification()); - assert!(!message.is_error()); - assert!(message.message_type() == MessageTypes::Response); - - assert!( - matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15)) - ); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::InitializeResult(_))) - )); - } - - #[test] - fn test_server_read_resource_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::ReadResourceResult(ReadResourceResult { - contents: vec![], - meta: None, - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ReadResourceResult(_))) - )); - } - - #[test] - fn test_server_list_prompts_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::ListPromptsResult(ListPromptsResult { - meta: None, - next_cursor: None, - prompts: vec![], - })), - )); - - let message: ServerMessage = re_serialize(message); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListPromptsResult(_))) - )); - } - - #[test] - fn test_server_get_prompt_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::GetPromptResult(GetPromptResult { - meta: None, - description: None, - messages: vec![], - })), - )); - - let message: ServerMessage = re_serialize(message); - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::GetPromptResult(_))) - )); - } - - #[test] - fn test_server_list_tools_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::ListToolsResult(ListToolsResult { - meta: None, - next_cursor: None, - tools: vec![], - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListToolsResult(_))) - )); - } - - #[cfg(any(feature = "2025_03_26", feature = "2024_11_05"))] - #[test] - fn test_server_call_tool_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::CallToolResult(CallToolResult { - meta: None, - content: vec![], - is_error: None, - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::CallToolResult(_))) - )); - } - - #[test] - fn test_server_custom_result() { - let custom_result: serde_json::Map = json!({ - "custom_key":"custom_value", - "custom_number": 15.21 - }) - .as_object() - .unwrap() - .clone(); - - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::Result(Result { - meta: None, - extra: Some(custom_result), - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::Result(result) - if result.extra.is_some() - )) - )); - } - - /* ---------------------- CLIENT NOTIFICATIONS ---------------------- */ - - #[test] - fn test_client_initialized_notification() { - let init_notification = - InitializedNotification::new(Some(InitializedNotificationParams { meta: None, extra: None })); - - let message: ClientMessage = - ClientMessage::Notification(ClientJsonrpcNotification::new(NotificationFromClient::ClientNotification( - ClientNotification::InitializedNotification(init_notification.clone()), - ))); - - let message: ClientMessage = re_serialize(message); - - assert!(!message.is_request()); - assert!(!message.is_response()); - assert!(message.is_notification()); - assert!(!message.is_error()); - assert!(message.message_type() == MessageTypes::Notification); - assert!(message.request_id().is_none()); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::InitializedNotification(_))) - )); - - // test From for NotificationFromClient - let message: ClientMessage = - ClientMessage::Notification(ClientJsonrpcNotification::new(init_notification.clone().into())); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::InitializedNotification(_))) - )); - - // test From for ClientJsonrpcNotification - let message: ClientMessage = ClientMessage::Notification(init_notification.into()); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::InitializedNotification(_))) - )); - } - - #[test] - fn test_client_root_list_changed_notification() { - let message: ClientMessage = - ClientMessage::Notification(ClientJsonrpcNotification::new(NotificationFromClient::ClientNotification( - ClientNotification::RootsListChangedNotification(RootsListChangedNotification::new(None)), - ))); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::RootsListChangedNotification(_))) - )); - } - - #[test] - fn test_client_cancelled_notification() { - let message: ClientMessage = - ClientMessage::Notification(ClientJsonrpcNotification::new(NotificationFromClient::ClientNotification( - ClientNotification::CancelledNotification(CancelledNotification::new(CancelledNotificationParams { - reason: Some("Request timed out".to_string()), - request_id: RequestId::Integer(15), - })), - ))); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromClient::ClientNotification(client_notification) - if matches!( client_notification, ClientNotification::CancelledNotification(notification) if notification.params.reason == Some("Request timed out".to_string()))) - )); - } - - #[test] - fn test_client_custom_notification() { - let message: ClientMessage = ClientMessage::Notification(ClientJsonrpcNotification::new( - NotificationFromClient::CustomNotification(json!({"method":"my_notification"})), - )); - - let message: ClientMessage = re_serialize(message); - - // test Display trait - let str = message.to_string(); - assert_eq!(str, "{\"jsonrpc\":\"2.0\",\"method\":\"my_notification\",\"params\":{\"method\":\"my_notification\",\"params\":{\"method\":\"my_notification\"}}}"); - - assert!(matches!(message, ClientMessage::Notification(client_message) - if matches!(&client_message.notification, NotificationFromClient::CustomNotification(_)) && client_message.method == "my_notification" - )); - } - - /* ---------------------- SERVER NOTIFICATIONS ---------------------- */ - #[test] - fn test_server_cancel_notification() { - let cancel_notification = CancelledNotification::new(CancelledNotificationParams { - reason: Some("Request timed out".to_string()), - request_id: RequestId::Integer(15), - }); - let message: ServerMessage = - ServerMessage::Notification(ServerJsonrpcNotification::new(NotificationFromServer::ServerNotification( - ServerNotification::CancelledNotification(cancel_notification.clone()), - ))); - - let message: ServerMessage = re_serialize(message); - - assert!(!message.is_request()); - assert!(!message.is_response()); - assert!(message.is_notification()); - assert!(!message.is_error()); - assert!(message.message_type() == MessageTypes::Notification); - assert!(message.request_id().is_none()); - - assert!(matches!(message, ServerMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification) - if matches!( client_notification, ServerNotification::CancelledNotification(_))) - )); - - // test From for NotificationFromServer - let message: ServerMessage = - ServerMessage::Notification(ServerJsonrpcNotification::new(cancel_notification.clone().into())); - - assert!(matches!(message, ServerMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification) - if matches!( client_notification, ServerNotification::CancelledNotification(_))) - )); - - // test From for ServerNotification - let message: ServerMessage = ServerMessage::Notification(cancel_notification.into()); - - assert!(matches!(message, ServerMessage::Notification(client_message) - if matches!(&client_message.notification,NotificationFromServer::ServerNotification(client_notification) - if matches!( client_notification, ServerNotification::CancelledNotification(_))) - )); - } - - /* ---------------------- SERVER REQUESTS ---------------------- */ - #[cfg(not(feature = "draft"))] - #[test] - fn test_server_requests() { - let message: ServerMessage = ServerMessage::Request(ServerJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromServer::ServerRequest(ServerRequest::CreateMessageRequest(CreateMessageRequest::new( - CreateMessageRequestParams { - include_context: None, - max_tokens: 21, - messages: vec![], - metadata: None, - model_preferences: None, - stop_sequences: vec![], - system_prompt: None, - temperature: None, - }, - ))), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(message.is_request()); - assert!(!message.is_response()); - assert!(!message.is_notification()); - assert!(!message.is_error()); - assert!(message.message_type() == MessageTypes::Request); - - assert!( - matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15)) - ); - - assert!(matches!(message, ServerMessage::Request(server_message) - if matches!(&server_message.request,RequestFromServer::ServerRequest(server_request) - if matches!( server_request, ServerRequest::CreateMessageRequest(_))) - )); - } - - #[test] - fn test_client_custom_server_request() { - let message: ServerMessage = ServerMessage::Request(ServerJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromServer::CustomRequest(json!({"method":"my_custom_method"})), - )); - - // test Display trait - let str = message.to_string(); - assert_eq!( - str, - "{\"id\":15,\"jsonrpc\":\"2.0\",\"method\":\"my_custom_method\",\"params\":{\"method\":\"my_custom_method\"}}" - ); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Request(server_message) - if matches!(&server_message.request, RequestFromServer::CustomRequest(_)) && server_message.method == "my_custom_method" - )); - } - - /* ---------------------- CLIENT & SERVER ERRORS ---------------------- */ - - #[test] - fn test_errors() { - let message: ClientMessage = ClientMessage::Error(JsonrpcError::create( - RequestId::Integer(15), - RpcErrorCodes::INTERNAL_ERROR, - "err_sampling_rejected".to_string(), - None, - )); - - let message: ClientMessage = re_serialize(message); - - assert!(matches!(message, ClientMessage::Error(_))); - assert!(!message.is_request()); - assert!(!message.is_response()); - assert!(!message.is_notification()); - assert!(message.is_error()); - assert!(message.message_type() == MessageTypes::Error); - - assert!( - matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15)) - ); - - let message: ServerMessage = ServerMessage::Error(JsonrpcError::create( - RequestId::Integer(15), - RpcErrorCodes::INTERNAL_ERROR, - "err_sampling_rejected".to_string(), - None, - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Error(_))); - - assert!(!message.is_request()); - assert!(!message.is_response()); - assert!(!message.is_notification()); - assert!(message.is_error()); - assert!(message.message_type() == MessageTypes::Error); - - assert!( - matches!(message.request_id(), Some(request_id) if matches!(request_id , RequestId::Integer(r) if *r == 15)) - ); - } - - /* ---------------------- RpcError ---------------------- */ - #[test] - fn test_new() { - let error_object = RpcError::new( - RpcErrorCodes::METHOD_NOT_FOUND, - "Error Message!".to_string(), - Some(json!({"details":"error detail"})), - ); - - let error_object: RpcError = re_serialize(error_object); - - assert_eq!(error_object.code, -32601); - assert_eq!(error_object.message, "Error Message!".to_string()); - matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); - } - - #[test] - fn test_method_not_found() { - let error_object = RpcError::method_not_found(); - assert_eq!(error_object.code, -32601); - assert_eq!(error_object.message, "Method not found".to_string()); - assert!(error_object.data.is_none()); - - // builder pattern - let error_object = RpcError::method_not_found() - .with_message("Error Message!".to_string()) - .with_data(Some(json!({"details":"error detail"}))); - - let error_object: RpcError = re_serialize(error_object); - - assert_eq!(error_object.code, -32601); - assert_eq!(error_object.message, "Error Message!".to_string()); - matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); - } - - #[test] - fn test_invalid_params() { - let error_object = RpcError::invalid_params(); - assert_eq!(error_object.code, -32602); - assert_eq!(error_object.message, "Invalid params".to_string()); - assert!(error_object.data.is_none()); - - // builder pattern - let error_object = RpcError::invalid_params() - .with_message("Error Message!".to_string()) - .with_data(Some(json!({"details":"error detail"}))); - - let error_object: RpcError = re_serialize(error_object); - - assert_eq!(error_object.code, -32602); - assert_eq!(error_object.message, "Error Message!".to_string()); - matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); - } - - #[test] - fn test_invalid_request() { - let error_object = RpcError::invalid_request(); - assert_eq!(error_object.code, -32600); - assert_eq!(error_object.message, "Invalid request".to_string()); - assert!(error_object.data.is_none()); - - // builder pattern - let error_object = RpcError::invalid_request() - .with_message("Error Message!".to_string()) - .with_data(Some(json!({"details":"error detail"}))); - - let error_object: RpcError = re_serialize(error_object); - - assert_eq!(error_object.code, -32600); - assert_eq!(error_object.message, "Error Message!".to_string()); - matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); - } - - #[test] - fn test_internal_error() { - let error_object = RpcError::internal_error(); - assert_eq!(error_object.code, -32603); - assert_eq!(error_object.message, "Internal error".to_string()); - assert!(error_object.data.is_none()); - - // builder pattern - let error_object = RpcError::internal_error() - .with_message("Error Message!".to_string()) - .with_data(Some(json!({"details":"error detail"}))); - - let error_object: RpcError = re_serialize(error_object); - - assert_eq!(error_object.code, -32603); - assert_eq!(error_object.message, "Error Message!".to_string()); - matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); - } - - #[test] - fn test_parse_error() { - let error_object = RpcError::parse_error(); - assert_eq!(error_object.code, -32700); - assert_eq!(error_object.message, "Parse error".to_string()); - assert!(error_object.data.is_none()); - - // builder pattern - let error_object = RpcError::parse_error() - .with_message("Error Message!".to_string()) - .with_data(Some(json!({"details":"error detail"}))); - - let error_object: RpcError = re_serialize(error_object); - - assert_eq!(error_object.code, -32700); - assert_eq!(error_object.message, "Error Message!".to_string()); - matches!(error_object.data, Some(data) if data["details"].as_str().unwrap() == "error detail"); - } - - #[cfg(not(feature = "draft"))] - #[test] - fn test_client_jsonrpc_request() { - let message = ClientJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromClient::ClientRequest(ClientRequest::PingRequest(PingRequest::new(None))), - ); - - let message_str = message.to_string(); - - let message: ClientJsonrpcRequest = ClientJsonrpcRequest::from_str(&message_str).unwrap(); - - assert!(matches!(&message.request, RequestFromClient::ClientRequest(client_request) - if matches!(client_request, ClientRequest::PingRequest(_)))); - } - - #[test] - fn test_client_jsonrpc_notification() { - let message = ClientJsonrpcNotification::new(NotificationFromClient::CustomNotification(json!({"method":"notify"}))); - - let message_str = message.to_string(); - - let message: ClientJsonrpcNotification = ClientJsonrpcNotification::from_str(&message_str).unwrap(); - - assert!( - matches!(&message.notification, NotificationFromClient::CustomNotification(client_request) - if client_request["method"] == "notify") - ); - } - - #[test] - fn test_server_jsonrpc_request() { - let message = ServerJsonrpcRequest::new( - RequestId::Integer(15), - RequestFromServer::CustomRequest(json!({"method":"req"})), - ); - - let message_str = message.to_string(); - - let message: ServerJsonrpcRequest = ServerJsonrpcRequest::from_str(&message_str).unwrap(); - - assert!(matches!(&message.request, RequestFromServer::CustomRequest(request) - if request["method"] == "req")); - } - - #[test] - fn test_server_jsonrpc_notification() { - let message = ServerJsonrpcNotification::new(NotificationFromServer::CustomNotification(json!({"method":"notify"}))); - - let message_str = message.to_string(); - - let message: ServerJsonrpcNotification = ServerJsonrpcNotification::from_str(&message_str).unwrap(); - - assert!( - matches!(&message.notification, NotificationFromServer::CustomNotification(server_request) - if server_request["method"] == "notify") - ); - } - - #[test] - fn test_server_list_resources_result() { - let message: ServerMessage = ServerMessage::Response(ServerJsonrpcResponse::new( - RequestId::Integer(15), - ResultFromServer::ServerResult(ServerResult::ListResourcesResult(ListResourcesResult { - meta: None, - next_cursor: None, - resources: vec![Resource { - #[cfg(feature = "draft")] - icons: vec![], - annotations: None, - description: None, - mime_type: None, - name: "Resource 1".to_string(), - uri: "test://static/resource/1".to_string(), - size: None, - #[cfg(any(feature = "2025_06_18", feature = "draft"))] - meta: None, - #[cfg(any(feature = "2025_06_18", feature = "draft"))] - title: None, - }], - })), - )); - - let message: ServerMessage = re_serialize(message); - - assert!(matches!(message, ServerMessage::Response(server_message) - if matches!(&server_message.result, ResultFromServer::ServerResult(server_result) - if matches!(server_result, ServerResult::ListResourcesResult(_))) - )); - } -} diff --git a/tests/v2025_11_25/mod.rs b/tests/v2025_11_25/mod.rs new file mode 100644 index 0000000..8627d2d --- /dev/null +++ b/tests/v2025_11_25/mod.rs @@ -0,0 +1,5 @@ +#[path = "../common/common.rs"] +pub mod common; + +mod schema_2025_11_25; +mod test_schema_utils; diff --git a/tests/v2025_11_25/schema_2025_11_25.rs b/tests/v2025_11_25/schema_2025_11_25.rs new file mode 100644 index 0000000..2dbd4f4 --- /dev/null +++ b/tests/v2025_11_25/schema_2025_11_25.rs @@ -0,0 +1,222 @@ +use super::common::round_trip_test; +use rust_mcp_schema::*; + +#[test] +fn test_annotations() { + let ann = Annotations { + audience: vec![Role::User, Role::Assistant], + last_modified: Some("2025-01-12T15:00:58Z".to_string()), + priority: Some(0.0), + }; + round_trip_test(&ann); + + round_trip_test(&Annotations::default()); +} + +#[test] +fn test_tool_execution_task_support_enum() { + // The enum is usually a simple string, but we test all variants + let variants = [ + ToolExecutionTaskSupport::Forbidden, + ToolExecutionTaskSupport::Optional, + ToolExecutionTaskSupport::Required, + ]; + for v in variants { + round_trip_test(&v); + } +} + +#[test] +fn test_base_metadata() { + let meta = BaseMetadata { + name: "my-tool".into(), + title: Some("My Awesome Tool".into()), + }; + round_trip_test(&meta); + + round_trip_test(&BaseMetadata { + name: "only-name".into(), + title: None, + }); +} + +#[test] +fn test_audio_content() { + let audio = AudioContent::new( + "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAA==".into(), + "audio/wav".into(), + Some(Annotations::default()), + None, + ); + round_trip_test(&audio); +} + +#[test] +fn test_call_tool_request() { + let req = CallToolRequest::new( + RequestId::String("req-123".into()), + CallToolRequestParams { + name: "calculator".into(), + arguments: Some(serde_json::json!({ "a": 1, "b": 2 }).as_object().unwrap().clone()), + meta: Some(CallToolMeta::default()), + task: Some(TaskMetadata::default()), + }, + ); + round_trip_test(&req); + + // Minimal version (no optionals) + let minimal = CallToolRequest::new( + RequestId::Integer(42), + CallToolRequestParams { + name: "hello".into(), + arguments: None, + meta: None, + task: None, + }, + ); + round_trip_test(&minimal); +} + +#[test] +fn test_call_tool_result() { + let result = CallToolResult { + content: vec![ContentBlock::TextContent(TextContent::new("42".into(), None, None))], + is_error: Some(true), + meta: None, + structured_content: Some(serde_json::json!({ "answer": 42 }).as_object().unwrap().clone()), + }; + round_trip_test(&result); + + // Success case + let success = CallToolResult { + content: vec![], + is_error: None, + meta: None, + structured_content: None, + }; + round_trip_test(&success); +} + +#[test] +fn test_tool_use_and_result_content() { + let tool_use = ToolUseContent::new( + "use-1".into(), + serde_json::json!({ "query": "weather" }).as_object().unwrap().clone(), + "weather_tool".into(), + None, + ); + round_trip_test(&tool_use); + + let tool_result = ToolResultContent::new( + vec![ContentBlock::TextContent(TextContent::new("Sunny".into(), None, None))], + "use-1".into(), + Some(false), + None, + None, + ); + round_trip_test(&tool_result); +} + +#[test] +fn test_client_capabilities_roundtrip() { + let caps = ClientCapabilities { + elicitation: Some(ClientElicitation::default()), + experimental: None, + roots: Some(ClientRoots { + list_changed: Some(true), + }), + sampling: Some(ClientSampling { + context: Some(serde_json::json!({ "enabled": true }).as_object().unwrap().clone()), + tools: None, + }), + tasks: Some(ClientTasks { + cancel: Some(serde_json::json!({}).as_object().unwrap().clone()), + list: None, + requests: Some(ClientTaskRequest { + elicitation: Some(ClientTaskElicitation { + create: Some(serde_json::json!({}).as_object().unwrap().clone()), + }), + sampling: None, + }), + }), + }; + round_trip_test(&caps); + + round_trip_test(&ClientCapabilities::default()); +} + +#[test] +fn test_untagged_enums() { + // These are the big ones that often break if serde attributes are wrong + let notifications: Vec = vec![ + ClientNotification::CancelledNotification(CancelledNotification::new(CancelledNotificationParams::default())), + ClientNotification::InitializedNotification(InitializedNotification::new(None)), + ClientNotification::ProgressNotification(ProgressNotification::new(ProgressNotificationParams { + message: Some("message".into()), + meta: None, + progress: 53., + progress_token: ProgressToken::String("a-b-c".to_string()), + total: Some(100.), + })), + ]; + + for n in notifications { + round_trip_test(&n); + } + + let requests: Vec = vec![ + ClientRequest::PingRequest(PingRequest::new(RequestId::Integer(1), None)), + ClientRequest::CallToolRequest(CallToolRequest::new( + RequestId::String("abc".into()), + CallToolRequestParams { + name: "test".into(), + arguments: None, + meta: None, + task: None, + }, + )), + ]; + + for r in requests { + round_trip_test(&r); + } +} + +#[test] +fn test_error_responses() { + let err = UrlElicitationRequiredError::new( + UrlElicitError::new( + UrlElicitErrorData { + elicitations: vec![], + extra: None, + }, + "Need more info".into(), + ), + Some(RequestId::String("req-1".into())), + ); + round_trip_test(&err); +} + +#[test] +fn test_blob_resource_contents() { + let blob = BlobResourceContents { + blob: "aGVsbG8gd29ybGQ=".into(), + meta: None, + mime_type: Some("text/plain".into()), + uri: "file:///tmp/hello.txt".into(), + }; + round_trip_test(&blob); +} + +#[test] +fn test_boolean_schema_and_tool_output_schema() { + let bool_schema = BooleanSchema::new(Some(true), None, Some("Enable magic".into())); + round_trip_test(&bool_schema); + + let output_schema = ToolOutputSchema::new( + vec!["result".into()], + None, + Some("https://json-schema.org/draft/2020-12/schema".into()), + ); + round_trip_test(&output_schema); +} diff --git a/tests/v2025_11_25/test_schema_utils.rs b/tests/v2025_11_25/test_schema_utils.rs new file mode 100644 index 0000000..47c1ca2 --- /dev/null +++ b/tests/v2025_11_25/test_schema_utils.rs @@ -0,0 +1,270 @@ +#[cfg(any(feature = "2025_11_25", feature = "draft"))] +mod tests_schema_utils { + use rust_mcp_schema::mcp_2025_11_25::*; + use serde_json::{json, Value}; + + // Helper to extract the inner map from a JSON value + fn map_from_json(value: Value) -> serde_json::Map { + value.as_object().unwrap().clone() + } + + #[test] + fn test_string_schema_minimal() { + let map = map_from_json(json!({ + "type": "string" + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + match result { + PrimitiveSchemaDefinition::StringSchema(s) => { + assert_eq!(s.type_(), "string"); + assert!(s.default.is_none()); + assert!(s.title.is_none()); + assert!(s.description.is_none()); + assert!(s.max_length.is_none()); + assert!(s.min_length.is_none()); + assert!(s.format.is_none()); + } + _ => panic!("Expected StringSchema"), + } + } + + #[test] + fn test_string_schema_full() { + let map = map_from_json(json!({ + "type": "string", + "title": "Username", + "description": "User's username", + "default": "guest", + "minLength": 3, + "maxLength": 20, + "format": "byte" + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + if let PrimitiveSchemaDefinition::StringSchema(s) = result { + assert_eq!(s.type_(), "string"); + assert_eq!(s.title.as_deref(), Some("Username")); + assert_eq!(s.description.as_deref(), Some("User's username")); + assert_eq!(s.default.as_deref(), Some("guest")); + assert_eq!(s.min_length, Some(3)); + assert_eq!(s.max_length, Some(20)); + #[cfg(not(any(feature = "2025_11_25", feature = "draft")))] + assert_eq!(s.format, Some(StringSchemaFormat::Byte)); + } else { + panic!("Expected StringSchema"); + } + } + + #[test] + fn test_number_schema_minimal() { + let map = map_from_json(json!({ + "type": "integer" + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + match result { + PrimitiveSchemaDefinition::NumberSchema(n) => { + assert_eq!(n.type_, NumberSchemaType::Integer); + } + _ => panic!("Expected NumberSchema"), + } + } + + #[test] + fn test_number_schema_full() { + let map = map_from_json(json!({ + "type": "number", + "title": "Age", + "description": "Age in years", + "minimum": 0, + "maximum": 130, + "default": 25 + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + if let PrimitiveSchemaDefinition::NumberSchema(n) = result { + assert_eq!(n.type_, NumberSchemaType::Number); + assert_eq!(n.title.as_deref(), Some("Age")); + assert_eq!(n.minimum, Some(0)); + assert_eq!(n.maximum, Some(130)); + assert_eq!(n.default, Some(25)); + } else { + panic!("Expected NumberSchema"); + } + } + + #[test] + fn test_boolean_schema() { + let map = map_from_json(json!({ + "type": "boolean", + "title": "Is Active", + "default": true + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + if let PrimitiveSchemaDefinition::BooleanSchema(b) = result { + assert_eq!(b.type_(), "boolean"); + assert_eq!(b.default, Some(true)); + assert_eq!(b.title.as_deref(), Some("Is Active")); + } else { + panic!("Expected BooleanSchema"); + } + } + + #[test] + fn test_untitled_single_select_enum_schema() { + let map = map_from_json(json!({ + "type": "string", + "enum": ["red", "green", "blue"], + "default": "green" + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + match result { + PrimitiveSchemaDefinition::UntitledSingleSelectEnumSchema(e) => { + assert_eq!(e.type_(), "string"); + assert_eq!(e.enum_, vec!["red", "green", "blue"]); + assert_eq!(e.default.as_deref(), Some("green")); + } + _ => panic!("Expected UntitledSingleSelectEnumSchema"), + } + } + + #[test] + fn test_titled_single_select_enum_schema() { + let map = map_from_json(json!({ + "type": "string", + "oneOf": [ + { "const": "admin", "title": "Administrator" }, + { "const": "user", "title": "Regular User" } + ], + "default": "user" + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + match result { + PrimitiveSchemaDefinition::TitledSingleSelectEnumSchema(e) => { + assert_eq!(e.one_of.len(), 2); + assert_eq!(e.one_of[0].const_, "admin"); + assert_eq!(e.one_of[0].title, "Administrator"); + assert_eq!(e.default.as_deref(), Some("user")); + } + _ => panic!("Expected TitledSingleSelectEnumSchema"), + } + } + + #[test] + fn test_untitled_multi_select_enum_schema() { + let map = map_from_json(json!({ + "type": "array", + "items": { "type": "string", "enum": ["read", "write", "delete"] }, + "minItems": 1, + "maxItems": 3, + "default": ["read"] + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + match result { + PrimitiveSchemaDefinition::UntitledMultiSelectEnumSchema(e) => { + assert_eq!(e.min_items, Some(1)); + assert_eq!(e.max_items, Some(3)); + assert_eq!(e.default, vec!["read"]); + let UntitledMultiSelectEnumSchemaItems { enum_, .. } = &e.items; + assert_eq!(*enum_, vec!["read", "write", "delete"]); + } + _ => panic!("Expected UntitledMultiSelectEnumSchema"), + } + } + + #[test] + fn test_titled_multi_select_enum_schema() { + let map = map_from_json(json!({ + "type": "array", + "items": { + "anyOf": [ + { "const": "admin", "title": "Admin Role" }, + { "const": "editor", "title": "Editor" } + ] + }, + "default": ["editor"] + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + + match result { + PrimitiveSchemaDefinition::TitledMultiSelectEnumSchema(e) => { + assert_eq!(e.default, vec!["editor"]); + let TitledMultiSelectEnumSchemaItems { any_of } = &e.items; + assert_eq!(any_of.len(), 2); + assert_eq!(any_of[0].const_, "admin"); + assert_eq!(any_of[0].title, "Admin Role"); + } + _ => panic!("Expected TitledMultiSelectEnumSchema"), + } + } + + #[test] + fn test_legacy_titled_enum_schema() { + let map = map_from_json(json!({ + "type": "string", + "enum": ["draft", "published"], + "enumNames": ["Draft", "Published"], + "default": "draft", + "title": "Status" + })); + + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + match result { + PrimitiveSchemaDefinition::LegacyTitledEnumSchema(e) => { + assert_eq!(e.enum_, vec!["draft", "published"]); + assert_eq!(e.enum_names, vec!["Draft", "Published"]); + assert_eq!(e.default.as_deref(), Some("draft")); + assert_eq!(e.title.as_deref(), Some("Status")); + } + _ => panic!("Expected LegacyTitledEnumSchema"), + } + } + + #[test] + fn test_invalid_schema_rejected() { + // Missing type + let map = map_from_json(json!({ + "title": "Bad" + })); + + let err = PrimitiveSchemaDefinition::try_from(&map); + assert!(err.is_err()); + + // Wrong type + let map2 = map_from_json(json!({ + "type": "object" + })); + assert!(PrimitiveSchemaDefinition::try_from(&map2).is_err()); + } + + #[test] + fn test_priority_of_variants() { + // This tests that more specific schemas are matched before generic ones + // For example: a schema with "oneOf" should be TitledSingleSelect, not fall into StringSchema + + let titled_single = json!({ + "type": "string", + "oneOf": [{ "const": "yes", "title": "Yes" }], + "title": "Confirmed?" + }); + + let map = map_from_json(titled_single); + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + assert!(matches!(result, PrimitiveSchemaDefinition::TitledSingleSelectEnumSchema(_))); + + let untitled_enum = json!({ + "type": "string", + "enum": ["a", "b"] + }); + + let map = map_from_json(untitled_enum); + let result = PrimitiveSchemaDefinition::try_from(&map).unwrap(); + assert!(matches!(result, PrimitiveSchemaDefinition::UntitledSingleSelectEnumSchema(_))); + } +} From e8a26644289ec87be57d3a9bee8844d26e6be1a1 Mon Sep 17 00:00:00 2001 From: Ali Hashemi Date: Mon, 1 Dec 2025 18:30:01 -0400 Subject: [PATCH 2/5] chore: update readme --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f182196..81f9781 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ A type-safe Rust implementation of the official Model Context Protocol (MCP) schema, supporting all official MCP Protocol versions: -- `2025_11_25` -- `2025_06_18` -- `2025_03_26` -- `2024_11_05` +- `2025-11-25` +- `2025-06-18` +- `2025-03-26` +- `2024-11-05` - `draft` The MCP schemas in this repository are [automatically generated](#how-are-schemas-generated) from the official Model Context Protocol, ensuring they are always up-to-date and aligned with the latest official specifications. @@ -52,7 +52,7 @@ Focus on your app's logic while [rust-mcp-sdk](https://crates.io/crates/rust-mcp - 🧩 Type-safe implementation of the MCP protocol specification. - 💎 Auto-generated schemas are always synchronized with the official schema specifications. -- 📜 Includes all official released versions : `2025_11_25`, `2025_06_18`, `2025_03_26`, `2024_11_05` and `draft` version for early adoption. +- 📜 Includes all official released versions : `2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05` and `draft` version for early adoption. - 🛠 Complimentary schema utility module (schema_utils) to boost productivity and ensure development integrity. ## How can this crate be used? @@ -76,10 +76,10 @@ For more information on the MCP architecture, refer to the [official documentati This repository provides all official released versions the schema , including draft version, enabling you to prepare and adapt your applications ahead of upcoming official schema releases. -- [2025_11_25](src/generated_schema/2025_11_25) -- [2025_06_18](src/generated_schema/2025_06_18) -- [2025_03_26](src/generated_schema/2025_03_26) -- [2024_11_05](src/generated_schema/2024_11_05) +- [2025-11-25](src/generated_schema/2025_11_25) +- [2025-06-18](src/generated_schema/2025_06_18) +- [2025-03-26](src/generated_schema/2025_03_26) +- [2024-11-05](src/generated_schema/2024_11_05) - [draft](src/generated_schema/draft) ### How to switch between different schema versions? @@ -93,7 +93,7 @@ Multiple schema versions may be enabled concurrently if needed. Non-default vers - rust_mcp_schema::mcp_2025_06_18 - rust_mcp_schema::mcp_draft" -Example: enable `2025_06_18` version of the schema: +Example: enable `2025-06-18` version of the schema: From 718c2b55351331d6212f42f379fd625897f455f6 Mon Sep 17 00:00:00 2001 From: Ali Hashemi Date: Mon, 1 Dec 2025 18:49:40 -0400 Subject: [PATCH 3/5] chore: generate fresh schemas --- src/generated_schema/2024_11_05/mcp_schema.rs | 4 ++-- src/generated_schema/2025_03_26/mcp_schema.rs | 4 ++-- src/generated_schema/2025_06_18/mcp_schema.rs | 4 ++-- src/generated_schema/2025_11_25/mcp_schema.rs | 4 ++-- src/generated_schema/draft/mcp_schema.rs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/generated_schema/2024_11_05/mcp_schema.rs b/src/generated_schema/2024_11_05/mcp_schema.rs index bd98a8e..b647c4a 100644 --- a/src/generated_schema/2024_11_05/mcp_schema.rs +++ b/src/generated_schema/2024_11_05/mcp_schema.rs @@ -8,8 +8,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : UNKNOWN -/// Generated at : 2025-12-01 14:17:31 +/// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 +/// Generated at : 2025-12-01 18:46:18 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/2025_03_26/mcp_schema.rs b/src/generated_schema/2025_03_26/mcp_schema.rs index 928575e..7dc26a9 100644 --- a/src/generated_schema/2025_03_26/mcp_schema.rs +++ b/src/generated_schema/2025_03_26/mcp_schema.rs @@ -8,8 +8,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : UNKNOWN -/// Generated at : 2025-12-01 14:17:33 +/// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 +/// Generated at : 2025-12-01 18:46:20 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/2025_06_18/mcp_schema.rs b/src/generated_schema/2025_06_18/mcp_schema.rs index 9f6c596..b109d2d 100644 --- a/src/generated_schema/2025_06_18/mcp_schema.rs +++ b/src/generated_schema/2025_06_18/mcp_schema.rs @@ -8,8 +8,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : UNKNOWN -/// Generated at : 2025-12-01 14:17:33 +/// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 +/// Generated at : 2025-12-01 18:46:20 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/2025_11_25/mcp_schema.rs b/src/generated_schema/2025_11_25/mcp_schema.rs index bceccd1..24d285e 100644 --- a/src/generated_schema/2025_11_25/mcp_schema.rs +++ b/src/generated_schema/2025_11_25/mcp_schema.rs @@ -8,8 +8,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : UNKNOWN -/// Generated at : 2025-12-01 14:17:34 +/// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 +/// Generated at : 2025-12-01 18:46:21 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/draft/mcp_schema.rs b/src/generated_schema/draft/mcp_schema.rs index 88ce39c..e7974b9 100644 --- a/src/generated_schema/draft/mcp_schema.rs +++ b/src/generated_schema/draft/mcp_schema.rs @@ -8,8 +8,8 @@ /// modify or extend the implementations as needed, but please do so at your own risk. /// /// Generated from : -/// Hash : UNKNOWN -/// Generated at : 2025-12-01 14:17:35 +/// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 +/// Generated at : 2025-12-01 18:46:22 /// ---------------------------------------------------------------------------- /// use super::validators as validate; From c709e59b3abff15dfc832b256a67a91842e3ebb7 Mon Sep 17 00:00:00 2001 From: Ali Hashemi Date: Mon, 1 Dec 2025 18:53:25 -0400 Subject: [PATCH 4/5] chore: last update --- src/generated_schema/2024_11_05/mcp_schema.rs | 3 +-- src/generated_schema/2025_03_26/mcp_schema.rs | 3 +-- src/generated_schema/2025_06_18/mcp_schema.rs | 3 +-- src/generated_schema/2025_11_25/mcp_schema.rs | 5 ++--- src/generated_schema/draft/mcp_schema.rs | 3 +-- src/generated_schema/protocol_version.rs | 4 ---- 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/generated_schema/2024_11_05/mcp_schema.rs b/src/generated_schema/2024_11_05/mcp_schema.rs index b647c4a..7bc16f9 100644 --- a/src/generated_schema/2024_11_05/mcp_schema.rs +++ b/src/generated_schema/2024_11_05/mcp_schema.rs @@ -1,6 +1,5 @@ /// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) /// Licensed under the MIT License. See LICENSE in the project root. -/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- /// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: @@ -9,7 +8,7 @@ /// /// Generated from : /// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 -/// Generated at : 2025-12-01 18:46:18 +/// Generated at : 2025-12-01 18:52:52 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/2025_03_26/mcp_schema.rs b/src/generated_schema/2025_03_26/mcp_schema.rs index 7dc26a9..87edea1 100644 --- a/src/generated_schema/2025_03_26/mcp_schema.rs +++ b/src/generated_schema/2025_03_26/mcp_schema.rs @@ -1,6 +1,5 @@ /// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) /// Licensed under the MIT License. See LICENSE in the project root. -/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- /// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: @@ -9,7 +8,7 @@ /// /// Generated from : /// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 -/// Generated at : 2025-12-01 18:46:20 +/// Generated at : 2025-12-01 18:52:54 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/2025_06_18/mcp_schema.rs b/src/generated_schema/2025_06_18/mcp_schema.rs index b109d2d..1d6ff2a 100644 --- a/src/generated_schema/2025_06_18/mcp_schema.rs +++ b/src/generated_schema/2025_06_18/mcp_schema.rs @@ -1,6 +1,5 @@ /// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) /// Licensed under the MIT License. See LICENSE in the project root. -/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- /// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: @@ -9,7 +8,7 @@ /// /// Generated from : /// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 -/// Generated at : 2025-12-01 18:46:20 +/// Generated at : 2025-12-01 18:52:54 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/2025_11_25/mcp_schema.rs b/src/generated_schema/2025_11_25/mcp_schema.rs index 24d285e..3183de0 100644 --- a/src/generated_schema/2025_11_25/mcp_schema.rs +++ b/src/generated_schema/2025_11_25/mcp_schema.rs @@ -1,6 +1,5 @@ /// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) /// Licensed under the MIT License. See LICENSE in the project root. -/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- /// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: @@ -9,12 +8,12 @@ /// /// Generated from : /// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 -/// Generated at : 2025-12-01 18:46:21 +/// Generated at : 2025-12-01 18:52:55 /// ---------------------------------------------------------------------------- /// use super::validators as validate; /// MCP Protocol Version -pub const LATEST_PROTOCOL_VERSION: &str = "2025-11-25"; +pub const LATEST_PROTOCOL_VERSION: &str = "DRAFT-2025-v3"; /// JSON-RPC Version pub const JSONRPC_VERSION: &str = "2.0"; /// Parse error. Invalid JSON was received. An error occurred while parsing the JSON text. diff --git a/src/generated_schema/draft/mcp_schema.rs b/src/generated_schema/draft/mcp_schema.rs index e7974b9..e245962 100644 --- a/src/generated_schema/draft/mcp_schema.rs +++ b/src/generated_schema/draft/mcp_schema.rs @@ -1,6 +1,5 @@ /// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack) /// Licensed under the MIT License. See LICENSE in the project root. -/// Include this notice in copies or substantial portions of the Software. /// ---------------------------------------------------------------------------- /// This file is auto-generated by mcp-schema-gen v0.5.0. /// WARNING: @@ -9,7 +8,7 @@ /// /// Generated from : /// Hash : 391c69f42f21bab3a5df0923b45b9ad3174414b9 -/// Generated at : 2025-12-01 18:46:22 +/// Generated at : 2025-12-01 18:52:56 /// ---------------------------------------------------------------------------- /// use super::validators as validate; diff --git a/src/generated_schema/protocol_version.rs b/src/generated_schema/protocol_version.rs index bd6d2fd..55e2e7f 100644 --- a/src/generated_schema/protocol_version.rs +++ b/src/generated_schema/protocol_version.rs @@ -4,7 +4,6 @@ pub enum ProtocolVersion { V2024_11_05, V2025_03_26, V2025_06_18, - V2025_11_25, Draft, } impl ProtocolVersion { @@ -13,7 +12,6 @@ impl ProtocolVersion { ProtocolVersion::V2024_11_05, ProtocolVersion::V2025_03_26, ProtocolVersion::V2025_06_18, - ProtocolVersion::V2025_11_25, ]; if include_draft { versions.push(ProtocolVersion::Draft); @@ -27,7 +25,6 @@ impl Display for ProtocolVersion { ProtocolVersion::V2024_11_05 => write!(f, "2024-11-05"), ProtocolVersion::V2025_03_26 => write!(f, "2025-03-26"), ProtocolVersion::V2025_06_18 => write!(f, "2025-06-18"), - ProtocolVersion::V2025_11_25 => write!(f, "2025-11-25"), ProtocolVersion::Draft => write!(f, "DRAFT-2025-v3"), } } @@ -58,7 +55,6 @@ impl TryFrom<&str> for ProtocolVersion { "2024-11-05" => Ok(ProtocolVersion::V2024_11_05), "2025-03-26" => Ok(ProtocolVersion::V2025_03_26), "2025-06-18" => Ok(ProtocolVersion::V2025_06_18), - "2025-11-25" => Ok(ProtocolVersion::V2025_11_25), "DRAFT-2025-v3" => Ok(ProtocolVersion::Draft), "DRAFT" => Ok(ProtocolVersion::Draft), other => Err(ParseProtocolVersionError { From 0ed7a509c12c6fd87930bb513c76fc10470f381f Mon Sep 17 00:00:00 2001 From: Ali Hashemi Date: Mon, 1 Dec 2025 18:57:08 -0400 Subject: [PATCH 5/5] chore: set minimum rust version --- Cargo.toml | 2 ++ rust-toolchain.toml | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/Cargo.toml b/Cargo.toml index 8821f44..f6be0e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,8 @@ documentation = "https://docs.rs/rust-mcp-schema" keywords = ["rust-mcp-stack", "model", "context", "protocol", "schema"] license = "MIT" edition = "2021" +rust-version = "1.80.0" + [lib] path = "src/rust-mcp-schema.rs" diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 7855e6d..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "1.88.0" -components = ["rustfmt", "clippy"]