Skip to main content

flymcprust_spec/v2026_07_28/
mod.rs

1// @generated by `cargo xtask codegen` from MCP spec revision 2026-07-28 (commit 271ecc9accafdd9b83a3c869fa67c22953b2af80).
2// Do not edit by hand: change xtask/ or xtask/overrides/2026-07-28.toml instead.
3
4//! Protocol types for MCP specification revision `2026-07-28`.
5//!
6//! Generated from the official `schema.json` and `schema.ts` (commit `271ecc9accafdd9b83a3c869fa67c22953b2af80`).
7use serde::{Deserialize, Serialize};
8/// The protocol revision these types describe.
9pub const PROTOCOL_VERSION: &str = "2026-07-28";
10/// JSON-RPC error codes defined by the schema.
11pub mod error_codes {
12    /// Error code of [`HeaderMismatchError`](super::HeaderMismatchError).
13    pub const HEADER_MISMATCH_ERROR: i64 = -32020i64;
14    /// Error code of [`InternalError`](super::InternalError).
15    pub const INTERNAL_ERROR: i64 = -32603i64;
16    /// Error code of [`InvalidParamsError`](super::InvalidParamsError).
17    pub const INVALID_PARAMS_ERROR: i64 = -32602i64;
18    /// Error code of [`InvalidRequestError`](super::InvalidRequestError).
19    pub const INVALID_REQUEST_ERROR: i64 = -32600i64;
20    /// Error code of [`MethodNotFoundError`](super::MethodNotFoundError).
21    pub const METHOD_NOT_FOUND_ERROR: i64 = -32601i64;
22    /// Error code of [`MissingRequiredClientCapabilityError`](super::MissingRequiredClientCapabilityError).
23    pub const MISSING_REQUIRED_CLIENT_CAPABILITY_ERROR: i64 = -32021i64;
24    /// Error code of [`ParseError`](super::ParseError).
25    pub const PARSE_ERROR: i64 = -32700i64;
26    /// Error code of [`UnsupportedProtocolVersionError`](super::UnsupportedProtocolVersionError).
27    pub const UNSUPPORTED_PROTOCOL_VERSION_ERROR: i64 = -32022i64;
28}
29/// Method names defined by the schema.
30pub mod methods {
31    /// The `completion/complete` method.
32    pub const COMPLETION_COMPLETE: &str = "completion/complete";
33    /// The `elicitation/create` method.
34    pub const ELICITATION_CREATE: &str = "elicitation/create";
35    /// The `notifications/cancelled` method.
36    pub const NOTIFICATIONS_CANCELLED: &str = "notifications/cancelled";
37    /// The `notifications/message` method.
38    pub const NOTIFICATIONS_MESSAGE: &str = "notifications/message";
39    /// The `notifications/progress` method.
40    pub const NOTIFICATIONS_PROGRESS: &str = "notifications/progress";
41    /// The `notifications/prompts/list_changed` method.
42    pub const NOTIFICATIONS_PROMPTS_LIST_CHANGED: &str = "notifications/prompts/list_changed";
43    /// The `notifications/resources/list_changed` method.
44    pub const NOTIFICATIONS_RESOURCES_LIST_CHANGED: &str = "notifications/resources/list_changed";
45    /// The `notifications/resources/updated` method.
46    pub const NOTIFICATIONS_RESOURCES_UPDATED: &str = "notifications/resources/updated";
47    /// The `notifications/subscriptions/acknowledged` method.
48    pub const NOTIFICATIONS_SUBSCRIPTIONS_ACKNOWLEDGED: &str =
49        "notifications/subscriptions/acknowledged";
50    /// The `notifications/tools/list_changed` method.
51    pub const NOTIFICATIONS_TOOLS_LIST_CHANGED: &str = "notifications/tools/list_changed";
52    /// The `prompts/get` method.
53    pub const PROMPTS_GET: &str = "prompts/get";
54    /// The `prompts/list` method.
55    pub const PROMPTS_LIST: &str = "prompts/list";
56    /// The `resources/list` method.
57    pub const RESOURCES_LIST: &str = "resources/list";
58    /// The `resources/read` method.
59    pub const RESOURCES_READ: &str = "resources/read";
60    /// The `resources/templates/list` method.
61    pub const RESOURCES_TEMPLATES_LIST: &str = "resources/templates/list";
62    /// The `roots/list` method.
63    pub const ROOTS_LIST: &str = "roots/list";
64    /// The `sampling/createMessage` method.
65    pub const SAMPLING_CREATE_MESSAGE: &str = "sampling/createMessage";
66    /// The `server/discover` method.
67    pub const SERVER_DISCOVER: &str = "server/discover";
68    /// The `subscriptions/listen` method.
69    pub const SUBSCRIPTIONS_LISTEN: &str = "subscriptions/listen";
70    /// The `tools/call` method.
71    pub const TOOLS_CALL: &str = "tools/call";
72    /// The `tools/list` method.
73    pub const TOOLS_LIST: &str = "tools/list";
74}
75/// Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
76#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
77pub struct Annotations {
78    /// Describes who the intended audience of this object or data is.
79    ///
80    /// It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).
81    #[serde(rename = "audience", default, skip_serializing_if = "Option::is_none")]
82    pub audience: Option<Vec<Role>>,
83    /// The moment the resource was last modified, as an ISO 8601 formatted string.
84    ///
85    /// Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z").
86    ///
87    /// Examples: last activity timestamp in an open file, timestamp when the resource
88    /// was attached, etc.
89    #[serde(
90        rename = "lastModified",
91        default,
92        skip_serializing_if = "Option::is_none"
93    )]
94    pub last_modified: Option<String>,
95    /// Describes how important this data is for operating the server.
96    ///
97    /// A value of 1 means "most important," and indicates that the data is
98    /// effectively required, while 0 means "least important," and indicates that
99    /// the data is entirely optional.
100    #[serde(rename = "priority", default, skip_serializing_if = "Option::is_none")]
101    pub priority: Option<f64>,
102}
103/// The constant `"array"`.
104#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
105pub enum ArrayType {
106    /// The constant `"array"`.
107    #[default]
108    #[serde(rename = "array")]
109    Array,
110}
111impl ArrayType {
112    /// The wire representation of this constant.
113    pub const VALUE: &'static str = "array";
114}
115/// Audio provided to or from an LLM.
116#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
117pub struct AudioContent {
118    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
119    pub meta: Option<MetaObject>,
120    /// Optional annotations for the client.
121    #[serde(
122        rename = "annotations",
123        default,
124        skip_serializing_if = "Option::is_none"
125    )]
126    pub annotations: Option<Annotations>,
127    /// The base64-encoded audio data.
128    #[serde(rename = "data")]
129    pub data: String,
130    /// The MIME type of the audio. Different providers may support different audio types.
131    #[serde(rename = "mimeType")]
132    pub mime_type: String,
133    #[serde(rename = "type")]
134    pub r#type: AudioType,
135}
136impl AudioContent {
137    /// Creates a value from its required fields; optional fields are `None`.
138    #[must_use]
139    pub fn new(data: String, mime_type: String) -> Self {
140        Self {
141            meta: None,
142            annotations: None,
143            data,
144            mime_type,
145            r#type: Default::default(),
146        }
147    }
148}
149/// The constant `"audio"`.
150#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
151pub enum AudioType {
152    /// The constant `"audio"`.
153    #[default]
154    #[serde(rename = "audio")]
155    Audio,
156}
157impl AudioType {
158    /// The wire representation of this constant.
159    pub const VALUE: &'static str = "audio";
160}
161/// Base interface for metadata with name (identifier) and title (display name) properties.
162#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
163pub struct BaseMetadata {
164    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
165    #[serde(rename = "name")]
166    pub name: String,
167    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
168    /// even by those unfamiliar with domain-specific terminology.
169    ///
170    /// If not provided, the name should be used for display (except for `Tool`,
171    /// where `annotations.title` should be given precedence over using `name`,
172    /// if present).
173    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
174    pub title: Option<String>,
175}
176impl BaseMetadata {
177    /// Creates a value from its required fields; optional fields are `None`.
178    #[must_use]
179    pub fn new(name: String) -> Self {
180        Self { name, title: None }
181    }
182}
183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
184pub struct BlobResourceContents {
185    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
186    pub meta: Option<MetaObject>,
187    /// A base64-encoded string representing the binary data of the item.
188    #[serde(rename = "blob")]
189    pub blob: String,
190    /// The MIME type of this resource, if known.
191    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
192    pub mime_type: Option<String>,
193    /// The URI of this resource.
194    #[serde(rename = "uri")]
195    pub uri: String,
196}
197impl BlobResourceContents {
198    /// Creates a value from its required fields; optional fields are `None`.
199    #[must_use]
200    pub fn new(blob: String, uri: String) -> Self {
201        Self {
202            meta: None,
203            blob,
204            mime_type: None,
205            uri,
206        }
207    }
208}
209#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
210pub struct BooleanSchema {
211    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
212    pub default: Option<bool>,
213    #[serde(
214        rename = "description",
215        default,
216        skip_serializing_if = "Option::is_none"
217    )]
218    pub description: Option<String>,
219    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
220    pub title: Option<String>,
221    #[serde(rename = "type")]
222    pub r#type: BooleanType,
223}
224/// The constant `"boolean"`.
225#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
226pub enum BooleanType {
227    /// The constant `"boolean"`.
228    #[default]
229    #[serde(rename = "boolean")]
230    Boolean,
231}
232impl BooleanType {
233    /// The wire representation of this constant.
234    pub const VALUE: &'static str = "boolean";
235}
236/// Indicates the intended scope of the cached response, analogous to HTTP
237/// `Cache-Control: public` vs `Cache-Control: private`.
238///
239/// - `"public"`: The response does not contain user-specific data. Any
240///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
241///  the response and serve it across authorization contexts.
242/// - `"private"`: The response MAY be cached and reused only within the
243///  same authorization context. Caches MUST NOT be shared across
244///  authorization contexts (e.g., a different access token requires a
245///  different cache).
246#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
247pub enum CacheScope {
248    /// `"private"`
249    #[serde(rename = "private")]
250    Private,
251    /// `"public"`
252    #[serde(rename = "public")]
253    Public,
254}
255impl CacheScope {
256    /// The wire representation of this value.
257    #[must_use]
258    pub const fn as_str(self) -> &'static str {
259        match self {
260            Self::Private => "private",
261            Self::Public => "public",
262        }
263    }
264}
265/// A result that supports a time-to-live (TTL) hint for client-side caching.
266#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
267pub struct CacheableResult {
268    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
269    pub meta: Option<ResultMetaObject>,
270    /// Indicates the intended scope of the cached response, analogous to HTTP
271    /// `Cache-Control: public` vs `Cache-Control: private`.
272    ///
273    /// - `"public"`: The response does not contain user-specific data. Any
274    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
275    ///  the response and serve it across authorization contexts.
276    /// - `"private"`: The response MAY be cached and reused only within the
277    ///  same authorization context. Caches MUST NOT be shared across
278    ///  authorization contexts (e.g., a different access token requires a
279    ///  different cache).
280    #[serde(rename = "cacheScope")]
281    pub cache_scope: CacheScope,
282    /// Indicates the type of the result, which allows the client to determine
283    /// how to parse the result object.
284    ///
285    /// Servers implementing this protocol version MUST include this field.
286    /// For backward compatibility, when a client receives a result from a
287    /// server implementing an earlier protocol version (which does not include
288    /// `resultType`), the client MUST treat the absent field as `"complete"`.
289    #[serde(rename = "resultType")]
290    pub result_type: String,
291    /// A hint from the server indicating how long (in milliseconds) the
292    /// client MAY cache this response before re-fetching. Semantics are
293    /// analogous to HTTP Cache-Control max-age.
294    ///
295    /// - If 0, The response SHOULD be considered immediately stale,
296    ///  The client MAY re-fetch every time the result is needed.
297    /// - If positive, the client SHOULD consider the result fresh for this many
298    ///  milliseconds after receiving the response.
299    #[serde(rename = "ttlMs")]
300    pub ttl_ms: u64,
301}
302impl CacheableResult {
303    /// Creates a value from its required fields; optional fields are `None`.
304    #[must_use]
305    pub fn new(cache_scope: CacheScope, result_type: String, ttl_ms: u64) -> Self {
306        Self {
307            meta: None,
308            cache_scope,
309            result_type,
310            ttl_ms,
311        }
312    }
313}
314/// Used by the client to invoke a tool provided by the server.
315#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
316pub struct CallToolRequest {
317    #[serde(rename = "id")]
318    pub id: RequestId,
319    #[serde(rename = "jsonrpc")]
320    pub jsonrpc: JsonRpcVersion,
321    #[serde(rename = "method")]
322    pub method: ToolsCallMethod,
323    #[serde(rename = "params")]
324    pub params: CallToolRequestParams,
325}
326impl CallToolRequest {
327    /// Creates a value from its required fields; optional fields are `None`.
328    #[must_use]
329    pub fn new(id: RequestId, params: CallToolRequestParams) -> Self {
330        Self {
331            id,
332            jsonrpc: Default::default(),
333            method: Default::default(),
334            params,
335        }
336    }
337}
338/// Parameters for a `tools/call` request.
339#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
340pub struct CallToolRequestParams {
341    #[serde(rename = "_meta")]
342    pub meta: RequestMetaObject,
343    /// Arguments to use for the tool call.
344    #[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
345    pub arguments: Option<serde_json::Map<String, serde_json::Value>>,
346    #[serde(
347        rename = "inputResponses",
348        default,
349        skip_serializing_if = "Option::is_none"
350    )]
351    pub input_responses: Option<InputResponses>,
352    /// The name of the tool.
353    #[serde(rename = "name")]
354    pub name: String,
355    #[serde(
356        rename = "requestState",
357        default,
358        skip_serializing_if = "Option::is_none"
359    )]
360    pub request_state: Option<String>,
361}
362impl CallToolRequestParams {
363    /// Creates a value from its required fields; optional fields are `None`.
364    #[must_use]
365    pub fn new(meta: RequestMetaObject, name: String) -> Self {
366        Self {
367            meta,
368            arguments: None,
369            input_responses: None,
370            name,
371            request_state: None,
372        }
373    }
374}
375/// The result returned by the server for a `CallToolRequesttools/call` request.
376#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
377pub struct CallToolResult {
378    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
379    pub meta: Option<ResultMetaObject>,
380    /// A list of content objects that represent the unstructured result of the tool call.
381    #[serde(rename = "content")]
382    pub content: Vec<ContentBlock>,
383    /// Whether the tool call ended in an error.
384    ///
385    /// If not set, this is assumed to be false (the call was successful).
386    ///
387    /// Any errors that originate from the tool SHOULD be reported inside the result
388    /// object, with `isError` set to true, _not_ as an MCP protocol-level error
389    /// response. Otherwise, the LLM would not be able to see that an error occurred
390    /// and self-correct.
391    ///
392    /// However, any errors in _finding_ the tool, an error indicating that the
393    /// server does not support tool calls, or any other exceptional conditions,
394    /// should be reported as an MCP error response.
395    #[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")]
396    pub is_error: Option<bool>,
397    /// Indicates the type of the result, which allows the client to determine
398    /// how to parse the result object.
399    ///
400    /// Servers implementing this protocol version MUST include this field.
401    /// For backward compatibility, when a client receives a result from a
402    /// server implementing an earlier protocol version (which does not include
403    /// `resultType`), the client MUST treat the absent field as `"complete"`.
404    #[serde(rename = "resultType")]
405    pub result_type: String,
406    /// An optional JSON value that represents the structured result of the tool call.
407    ///
408    /// This can be any JSON value (object, array, string, number, boolean, or null)
409    /// that conforms to the tool's outputSchema if one is defined.
410    #[serde(
411        rename = "structuredContent",
412        default,
413        skip_serializing_if = "Option::is_none"
414    )]
415    pub structured_content: Option<serde_json::Value>,
416}
417impl CallToolResult {
418    /// Creates a value from its required fields; optional fields are `None`.
419    #[must_use]
420    pub fn new(content: Vec<ContentBlock>, result_type: String) -> Self {
421        Self {
422            meta: None,
423            content,
424            is_error: None,
425            result_type,
426            structured_content: None,
427        }
428    }
429}
430/// A successful response from the server for a `CallToolRequesttools/call` request.
431#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
432pub struct CallToolResultResponse {
433    #[serde(rename = "id")]
434    pub id: RequestId,
435    #[serde(rename = "jsonrpc")]
436    pub jsonrpc: JsonRpcVersion,
437    #[serde(rename = "result")]
438    pub result: CallToolResultResponseResult,
439}
440impl CallToolResultResponse {
441    /// Creates a value from its required fields; optional fields are `None`.
442    #[must_use]
443    pub fn new(id: RequestId, result: CallToolResultResponseResult) -> Self {
444        Self {
445            id,
446            jsonrpc: Default::default(),
447            result,
448        }
449    }
450}
451#[derive(Debug, Clone, PartialEq, Serialize)]
452#[serde(untagged)]
453pub enum CallToolResultResponseResult {
454    /// The [`InputRequiredResult`] variant.
455    InputRequired(InputRequiredResult),
456    /// The [`CallToolResult`] variant.
457    CallTool(CallToolResult),
458}
459impl From<InputRequiredResult> for CallToolResultResponseResult {
460    fn from(v: InputRequiredResult) -> Self {
461        Self::InputRequired(v)
462    }
463}
464impl From<CallToolResult> for CallToolResultResponseResult {
465    fn from(v: CallToolResult) -> Self {
466        Self::CallTool(v)
467    }
468}
469impl<'de> Deserialize<'de> for CallToolResultResponseResult {
470    fn deserialize<D: serde::Deserializer<'de>>(
471        deserializer: D,
472    ) -> ::core::result::Result<Self, D::Error> {
473        use serde::de::Error as _;
474        let value = serde_json::Value::deserialize(deserializer)?;
475        let tag = value
476            .get("resultType")
477            .and_then(serde_json::Value::as_str)
478            .map(str::to_owned);
479        match tag.as_deref() {
480            Some("input_required") => serde_json::from_value(value)
481                .map(Self::InputRequired)
482                .map_err(D::Error::custom),
483            _ => serde_json::from_value(value)
484                .map(Self::CallTool)
485                .map_err(D::Error::custom),
486        }
487    }
488}
489/// This notification is sent by the client to indicate that it is cancelling a request it previously issued.
490///
491/// On stdio, the server also sends this notification, solely to terminate a `SubscriptionsListenRequestsubscriptions/listen` stream: it references the ID of the `subscriptions/listen` request that opened the stream. Servers MUST NOT use this notification to cancel any other request.
492///
493/// 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.
494///
495/// This notification indicates that the result will be unused, so any associated processing SHOULD cease.
496#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
497pub struct CancelledNotification {
498    #[serde(rename = "jsonrpc")]
499    pub jsonrpc: JsonRpcVersion,
500    #[serde(rename = "method")]
501    pub method: NotificationsCancelledMethod,
502    #[serde(rename = "params")]
503    pub params: CancelledNotificationParams,
504}
505impl CancelledNotification {
506    /// Creates a value from its required fields; optional fields are `None`.
507    #[must_use]
508    pub fn new(params: CancelledNotificationParams) -> Self {
509        Self {
510            jsonrpc: Default::default(),
511            method: Default::default(),
512            params,
513        }
514    }
515}
516/// Parameters for a `notifications/cancelled` notification.
517#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
518pub struct CancelledNotificationParams {
519    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
520    pub meta: Option<NotificationMetaObject>,
521    /// An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
522    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
523    pub reason: Option<String>,
524    /// The ID of the request to cancel.
525    ///
526    /// This MUST correspond to the ID of a request the client previously issued.
527    #[serde(rename = "requestId")]
528    pub request_id: RequestId,
529}
530impl CancelledNotificationParams {
531    /// Creates a value from its required fields; optional fields are `None`.
532    #[must_use]
533    pub fn new(request_id: RequestId) -> Self {
534        Self {
535            meta: None,
536            reason: None,
537            request_id,
538        }
539    }
540}
541/// 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.
542#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
543pub struct ClientCapabilities {
544    /// Present if the client supports elicitation from the server.
545    #[serde(
546        rename = "elicitation",
547        default,
548        skip_serializing_if = "Option::is_none"
549    )]
550    pub elicitation: Option<ClientCapabilitiesElicitation>,
551    /// Experimental, non-standard capabilities that the client supports.
552    #[serde(
553        rename = "experimental",
554        default,
555        skip_serializing_if = "Option::is_none"
556    )]
557    pub experimental:
558        Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
559    /// Optional MCP extensions that the client supports. Keys are extension identifiers
560    /// (e.g., "io.modelcontextprotocol/oauth-client-credentials"), and values are
561    /// per-extension settings objects. An empty object indicates support with no settings.
562    ///
563    /// Keys MUST follow the `MetaObject`_meta``, with a
564    /// mandatory prefix.
565    #[serde(
566        rename = "extensions",
567        default,
568        skip_serializing_if = "Option::is_none"
569    )]
570    pub extensions:
571        Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
572    /// Present if the client supports listing roots.
573    #[deprecated(
574        note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
575    )]
576    #[serde(rename = "roots", default, skip_serializing_if = "Option::is_none")]
577    pub roots: Option<ClientCapabilitiesRoots>,
578    /// Present if the client supports sampling from an LLM.
579    #[deprecated(
580        note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
581    )]
582    #[serde(rename = "sampling", default, skip_serializing_if = "Option::is_none")]
583    pub sampling: Option<ClientCapabilitiesSampling>,
584}
585/// Present if the client supports elicitation from the server.
586#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
587pub struct ClientCapabilitiesElicitation {
588    #[serde(rename = "form", default, skip_serializing_if = "Option::is_none")]
589    pub form: Option<serde_json::Map<String, serde_json::Value>>,
590    #[serde(rename = "url", default, skip_serializing_if = "Option::is_none")]
591    pub url: Option<serde_json::Map<String, serde_json::Value>>,
592}
593/// Present if the client supports listing roots.
594#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
595pub struct ClientCapabilitiesRoots {}
596/// Present if the client supports sampling from an LLM.
597#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
598pub struct ClientCapabilitiesSampling {
599    /// Whether the client supports context inclusion via `includeContext` parameter.
600    /// If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
601    #[serde(rename = "context", default, skip_serializing_if = "Option::is_none")]
602    pub context: Option<serde_json::Map<String, serde_json::Value>>,
603    /// Whether the client supports tool use via `tools` and `toolChoice` parameters.
604    #[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
605    pub tools: Option<serde_json::Map<String, serde_json::Value>>,
606}
607/// This notification is sent by the client to indicate that it is cancelling a request it previously issued.
608///
609/// On stdio, the server also sends this notification, solely to terminate a `SubscriptionsListenRequestsubscriptions/listen` stream: it references the ID of the `subscriptions/listen` request that opened the stream. Servers MUST NOT use this notification to cancel any other request.
610///
611/// 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.
612///
613/// This notification indicates that the result will be unused, so any associated processing SHOULD cease.
614#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
615pub struct ClientNotification {
616    #[serde(rename = "jsonrpc")]
617    pub jsonrpc: JsonRpcVersion,
618    #[serde(rename = "method")]
619    pub method: NotificationsCancelledMethod,
620    #[serde(rename = "params")]
621    pub params: CancelledNotificationParams,
622}
623impl ClientNotification {
624    /// Creates a value from its required fields; optional fields are `None`.
625    #[must_use]
626    pub fn new(params: CancelledNotificationParams) -> Self {
627        Self {
628            jsonrpc: Default::default(),
629            method: Default::default(),
630            params,
631        }
632    }
633}
634#[derive(Debug, Clone, PartialEq, Serialize)]
635#[serde(untagged)]
636pub enum ClientRequest {
637    /// The [`DiscoverRequest`] variant.
638    Discover(DiscoverRequest),
639    /// The [`ListResourcesRequest`] variant.
640    ListResources(ListResourcesRequest),
641    /// The [`ListResourceTemplatesRequest`] variant.
642    ListResourceTemplates(ListResourceTemplatesRequest),
643    /// The [`ReadResourceRequest`] variant.
644    ReadResource(ReadResourceRequest),
645    /// The [`SubscriptionsListenRequest`] variant.
646    SubscriptionsListen(SubscriptionsListenRequest),
647    /// The [`ListPromptsRequest`] variant.
648    ListPrompts(ListPromptsRequest),
649    /// The [`GetPromptRequest`] variant.
650    GetPrompt(GetPromptRequest),
651    /// The [`ListToolsRequest`] variant.
652    ListTools(ListToolsRequest),
653    /// The [`CallToolRequest`] variant.
654    CallTool(CallToolRequest),
655    /// The [`CompleteRequest`] variant.
656    Complete(CompleteRequest),
657}
658impl From<DiscoverRequest> for ClientRequest {
659    fn from(v: DiscoverRequest) -> Self {
660        Self::Discover(v)
661    }
662}
663impl From<ListResourcesRequest> for ClientRequest {
664    fn from(v: ListResourcesRequest) -> Self {
665        Self::ListResources(v)
666    }
667}
668impl From<ListResourceTemplatesRequest> for ClientRequest {
669    fn from(v: ListResourceTemplatesRequest) -> Self {
670        Self::ListResourceTemplates(v)
671    }
672}
673impl From<ReadResourceRequest> for ClientRequest {
674    fn from(v: ReadResourceRequest) -> Self {
675        Self::ReadResource(v)
676    }
677}
678impl From<SubscriptionsListenRequest> for ClientRequest {
679    fn from(v: SubscriptionsListenRequest) -> Self {
680        Self::SubscriptionsListen(v)
681    }
682}
683impl From<ListPromptsRequest> for ClientRequest {
684    fn from(v: ListPromptsRequest) -> Self {
685        Self::ListPrompts(v)
686    }
687}
688impl From<GetPromptRequest> for ClientRequest {
689    fn from(v: GetPromptRequest) -> Self {
690        Self::GetPrompt(v)
691    }
692}
693impl From<ListToolsRequest> for ClientRequest {
694    fn from(v: ListToolsRequest) -> Self {
695        Self::ListTools(v)
696    }
697}
698impl From<CallToolRequest> for ClientRequest {
699    fn from(v: CallToolRequest) -> Self {
700        Self::CallTool(v)
701    }
702}
703impl From<CompleteRequest> for ClientRequest {
704    fn from(v: CompleteRequest) -> Self {
705        Self::Complete(v)
706    }
707}
708impl<'de> Deserialize<'de> for ClientRequest {
709    fn deserialize<D: serde::Deserializer<'de>>(
710        deserializer: D,
711    ) -> ::core::result::Result<Self, D::Error> {
712        use serde::de::Error as _;
713        let value = serde_json::Value::deserialize(deserializer)?;
714        let tag = value
715            .get("method")
716            .and_then(serde_json::Value::as_str)
717            .map(str::to_owned);
718        match tag.as_deref() {
719            Some("server/discover") => serde_json::from_value(value)
720                .map(Self::Discover)
721                .map_err(D::Error::custom),
722            Some("resources/list") => serde_json::from_value(value)
723                .map(Self::ListResources)
724                .map_err(D::Error::custom),
725            Some("resources/templates/list") => serde_json::from_value(value)
726                .map(Self::ListResourceTemplates)
727                .map_err(D::Error::custom),
728            Some("resources/read") => serde_json::from_value(value)
729                .map(Self::ReadResource)
730                .map_err(D::Error::custom),
731            Some("subscriptions/listen") => serde_json::from_value(value)
732                .map(Self::SubscriptionsListen)
733                .map_err(D::Error::custom),
734            Some("prompts/list") => serde_json::from_value(value)
735                .map(Self::ListPrompts)
736                .map_err(D::Error::custom),
737            Some("prompts/get") => serde_json::from_value(value)
738                .map(Self::GetPrompt)
739                .map_err(D::Error::custom),
740            Some("tools/list") => serde_json::from_value(value)
741                .map(Self::ListTools)
742                .map_err(D::Error::custom),
743            Some("tools/call") => serde_json::from_value(value)
744                .map(Self::CallTool)
745                .map_err(D::Error::custom),
746            Some("completion/complete") => serde_json::from_value(value)
747                .map(Self::Complete)
748                .map_err(D::Error::custom),
749            None => Err(D::Error::missing_field("method")),
750            Some(other) => Err(D::Error::unknown_variant(
751                other,
752                &[
753                    "server/discover",
754                    "resources/list",
755                    "resources/templates/list",
756                    "resources/read",
757                    "subscriptions/listen",
758                    "prompts/list",
759                    "prompts/get",
760                    "tools/list",
761                    "tools/call",
762                    "completion/complete",
763                ],
764            )),
765        }
766    }
767}
768/// A request from the client to the server, to ask for completion options.
769#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
770pub struct CompleteRequest {
771    #[serde(rename = "id")]
772    pub id: RequestId,
773    #[serde(rename = "jsonrpc")]
774    pub jsonrpc: JsonRpcVersion,
775    #[serde(rename = "method")]
776    pub method: CompletionCompleteMethod,
777    #[serde(rename = "params")]
778    pub params: CompleteRequestParams,
779}
780impl CompleteRequest {
781    /// Creates a value from its required fields; optional fields are `None`.
782    #[must_use]
783    pub fn new(id: RequestId, params: CompleteRequestParams) -> Self {
784        Self {
785            id,
786            jsonrpc: Default::default(),
787            method: Default::default(),
788            params,
789        }
790    }
791}
792/// Parameters for a `completion/complete` request.
793#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
794pub struct CompleteRequestParams {
795    #[serde(rename = "_meta")]
796    pub meta: RequestMetaObject,
797    /// The argument's information
798    #[serde(rename = "argument")]
799    pub argument: CompleteRequestParamsArgument,
800    /// Additional, optional context for completions
801    #[serde(rename = "context", default, skip_serializing_if = "Option::is_none")]
802    pub context: Option<CompleteRequestParamsContext>,
803    #[serde(rename = "ref")]
804    pub r#ref: CompleteRequestParamsRef,
805}
806impl CompleteRequestParams {
807    /// Creates a value from its required fields; optional fields are `None`.
808    #[must_use]
809    pub fn new(
810        meta: RequestMetaObject,
811        argument: CompleteRequestParamsArgument,
812        r#ref: CompleteRequestParamsRef,
813    ) -> Self {
814        Self {
815            meta,
816            argument,
817            context: None,
818            r#ref,
819        }
820    }
821}
822/// The argument's information
823#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
824pub struct CompleteRequestParamsArgument {
825    /// The name of the argument
826    #[serde(rename = "name")]
827    pub name: String,
828    /// The value of the argument to use for completion matching.
829    #[serde(rename = "value")]
830    pub value: String,
831}
832impl CompleteRequestParamsArgument {
833    /// Creates a value from its required fields; optional fields are `None`.
834    #[must_use]
835    pub fn new(name: String, value: String) -> Self {
836        Self { name, value }
837    }
838}
839/// Additional, optional context for completions
840#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
841pub struct CompleteRequestParamsContext {
842    /// Previously-resolved variables in a URI template or prompt.
843    #[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
844    pub arguments: Option<std::collections::BTreeMap<String, String>>,
845}
846#[derive(Debug, Clone, PartialEq, Serialize)]
847#[serde(untagged)]
848pub enum CompleteRequestParamsRef {
849    /// The [`PromptReference`] variant.
850    Prompt(PromptReference),
851    /// The [`ResourceTemplateReference`] variant.
852    ResourceTemplate(ResourceTemplateReference),
853}
854impl From<PromptReference> for CompleteRequestParamsRef {
855    fn from(v: PromptReference) -> Self {
856        Self::Prompt(v)
857    }
858}
859impl From<ResourceTemplateReference> for CompleteRequestParamsRef {
860    fn from(v: ResourceTemplateReference) -> Self {
861        Self::ResourceTemplate(v)
862    }
863}
864impl<'de> Deserialize<'de> for CompleteRequestParamsRef {
865    fn deserialize<D: serde::Deserializer<'de>>(
866        deserializer: D,
867    ) -> ::core::result::Result<Self, D::Error> {
868        use serde::de::Error as _;
869        let value = serde_json::Value::deserialize(deserializer)?;
870        let tag = value
871            .get("type")
872            .and_then(serde_json::Value::as_str)
873            .map(str::to_owned);
874        match tag.as_deref() {
875            Some("ref/prompt") => serde_json::from_value(value)
876                .map(Self::Prompt)
877                .map_err(D::Error::custom),
878            Some("ref/resource") => serde_json::from_value(value)
879                .map(Self::ResourceTemplate)
880                .map_err(D::Error::custom),
881            None => Err(D::Error::missing_field("type")),
882            Some(other) => Err(D::Error::unknown_variant(
883                other,
884                &["ref/prompt", "ref/resource"],
885            )),
886        }
887    }
888}
889/// The result returned by the server for a `CompleteRequestcompletion/complete` request.
890#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
891pub struct CompleteResult {
892    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
893    pub meta: Option<ResultMetaObject>,
894    #[serde(rename = "completion")]
895    pub completion: CompleteResultCompletion,
896    /// Indicates the type of the result, which allows the client to determine
897    /// how to parse the result object.
898    ///
899    /// Servers implementing this protocol version MUST include this field.
900    /// For backward compatibility, when a client receives a result from a
901    /// server implementing an earlier protocol version (which does not include
902    /// `resultType`), the client MUST treat the absent field as `"complete"`.
903    #[serde(rename = "resultType")]
904    pub result_type: String,
905}
906impl CompleteResult {
907    /// Creates a value from its required fields; optional fields are `None`.
908    #[must_use]
909    pub fn new(completion: CompleteResultCompletion, result_type: String) -> Self {
910        Self {
911            meta: None,
912            completion,
913            result_type,
914        }
915    }
916}
917#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
918pub struct CompleteResultCompletion {
919    /// Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
920    #[serde(rename = "hasMore", default, skip_serializing_if = "Option::is_none")]
921    pub has_more: Option<bool>,
922    /// The total number of completion options available. This can exceed the number of values actually sent in the response.
923    #[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
924    pub total: Option<i64>,
925    /// An array of completion values. Must not exceed 100 items.
926    #[serde(rename = "values")]
927    pub values: Vec<String>,
928}
929impl CompleteResultCompletion {
930    /// Creates a value from its required fields; optional fields are `None`.
931    #[must_use]
932    pub fn new(values: Vec<String>) -> Self {
933        Self {
934            has_more: None,
935            total: None,
936            values,
937        }
938    }
939}
940/// A successful response from the server for a `CompleteRequestcompletion/complete` request.
941#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
942pub struct CompleteResultResponse {
943    #[serde(rename = "id")]
944    pub id: RequestId,
945    #[serde(rename = "jsonrpc")]
946    pub jsonrpc: JsonRpcVersion,
947    #[serde(rename = "result")]
948    pub result: CompleteResult,
949}
950impl CompleteResultResponse {
951    /// Creates a value from its required fields; optional fields are `None`.
952    #[must_use]
953    pub fn new(id: RequestId, result: CompleteResult) -> Self {
954        Self {
955            id,
956            jsonrpc: Default::default(),
957            result,
958        }
959    }
960}
961/// The constant `"completion/complete"`.
962#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
963pub enum CompletionCompleteMethod {
964    /// The constant `"completion/complete"`.
965    #[default]
966    #[serde(rename = "completion/complete")]
967    CompletionComplete,
968}
969impl CompletionCompleteMethod {
970    /// The wire representation of this constant.
971    pub const VALUE: &'static str = "completion/complete";
972}
973#[derive(Debug, Clone, PartialEq, Serialize)]
974#[serde(untagged)]
975pub enum ContentBlock {
976    /// The [`TextContent`] variant.
977    TextContent(TextContent),
978    /// The [`ImageContent`] variant.
979    ImageContent(ImageContent),
980    /// The [`AudioContent`] variant.
981    AudioContent(AudioContent),
982    /// The [`ResourceLink`] variant.
983    ResourceLink(ResourceLink),
984    /// The [`EmbeddedResource`] variant.
985    EmbeddedResource(EmbeddedResource),
986}
987impl From<TextContent> for ContentBlock {
988    fn from(v: TextContent) -> Self {
989        Self::TextContent(v)
990    }
991}
992impl From<ImageContent> for ContentBlock {
993    fn from(v: ImageContent) -> Self {
994        Self::ImageContent(v)
995    }
996}
997impl From<AudioContent> for ContentBlock {
998    fn from(v: AudioContent) -> Self {
999        Self::AudioContent(v)
1000    }
1001}
1002impl From<ResourceLink> for ContentBlock {
1003    fn from(v: ResourceLink) -> Self {
1004        Self::ResourceLink(v)
1005    }
1006}
1007impl From<EmbeddedResource> for ContentBlock {
1008    fn from(v: EmbeddedResource) -> Self {
1009        Self::EmbeddedResource(v)
1010    }
1011}
1012impl<'de> Deserialize<'de> for ContentBlock {
1013    fn deserialize<D: serde::Deserializer<'de>>(
1014        deserializer: D,
1015    ) -> ::core::result::Result<Self, D::Error> {
1016        use serde::de::Error as _;
1017        let value = serde_json::Value::deserialize(deserializer)?;
1018        let tag = value
1019            .get("type")
1020            .and_then(serde_json::Value::as_str)
1021            .map(str::to_owned);
1022        match tag.as_deref() {
1023            Some("text") => serde_json::from_value(value)
1024                .map(Self::TextContent)
1025                .map_err(D::Error::custom),
1026            Some("image") => serde_json::from_value(value)
1027                .map(Self::ImageContent)
1028                .map_err(D::Error::custom),
1029            Some("audio") => serde_json::from_value(value)
1030                .map(Self::AudioContent)
1031                .map_err(D::Error::custom),
1032            Some("resource_link") => serde_json::from_value(value)
1033                .map(Self::ResourceLink)
1034                .map_err(D::Error::custom),
1035            Some("resource") => serde_json::from_value(value)
1036                .map(Self::EmbeddedResource)
1037                .map_err(D::Error::custom),
1038            None => Err(D::Error::missing_field("type")),
1039            Some(other) => Err(D::Error::unknown_variant(
1040                other,
1041                &["text", "image", "audio", "resource_link", "resource"],
1042            )),
1043        }
1044    }
1045}
1046/// 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.
1047#[deprecated(
1048    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
1049)]
1050#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1051pub struct CreateMessageRequest {
1052    #[serde(rename = "method")]
1053    pub method: SamplingCreateMessageMethod,
1054    #[serde(rename = "params")]
1055    pub params: CreateMessageRequestParams,
1056}
1057impl CreateMessageRequest {
1058    /// Creates a value from its required fields; optional fields are `None`.
1059    #[must_use]
1060    pub fn new(params: CreateMessageRequestParams) -> Self {
1061        Self {
1062            method: Default::default(),
1063            params,
1064        }
1065    }
1066}
1067/// Parameters for a `sampling/createMessage` request.
1068#[deprecated(
1069    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
1070)]
1071#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1072pub struct CreateMessageRequestParams {
1073    /// A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
1074    /// The client MAY ignore this request.
1075    ///
1076    /// Default is `"none"`. The values `"thisServer"` and `"allServers"` are deprecated (SEP-2596): servers SHOULD
1077    /// omit this field or use `"none"`, and SHOULD only use the deprecated values if the client declares
1078    /// `ClientCapabilities.sampling.context`.
1079    #[deprecated(
1080        note = "The `\"thisServer\"` and `\"allServers\"` values are deprecated as of protocol version 2025-11-25 (SEP-2596) and will be removed no later than the Sampling feature itself (SEP-2577). Omit this field or use `\"none\"`."
1081    )]
1082    #[serde(
1083        rename = "includeContext",
1084        default,
1085        skip_serializing_if = "Option::is_none"
1086    )]
1087    pub include_context: Option<CreateMessageRequestParamsIncludeContext>,
1088    /// The requested maximum number of tokens to sample (to prevent runaway completions).
1089    ///
1090    /// The client MAY choose to sample fewer tokens than the requested maximum.
1091    #[serde(rename = "maxTokens")]
1092    pub max_tokens: i64,
1093    #[serde(rename = "messages")]
1094    pub messages: Vec<SamplingMessage>,
1095    /// Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
1096    #[serde(rename = "metadata", default, skip_serializing_if = "Option::is_none")]
1097    pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
1098    /// The server's preferences for which model to select. The client MAY ignore these preferences.
1099    #[serde(
1100        rename = "modelPreferences",
1101        default,
1102        skip_serializing_if = "Option::is_none"
1103    )]
1104    pub model_preferences: Option<ModelPreferences>,
1105    #[serde(
1106        rename = "stopSequences",
1107        default,
1108        skip_serializing_if = "Option::is_none"
1109    )]
1110    pub stop_sequences: Option<Vec<String>>,
1111    /// An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
1112    #[serde(
1113        rename = "systemPrompt",
1114        default,
1115        skip_serializing_if = "Option::is_none"
1116    )]
1117    pub system_prompt: Option<String>,
1118    #[serde(
1119        rename = "temperature",
1120        default,
1121        skip_serializing_if = "Option::is_none"
1122    )]
1123    pub temperature: Option<f64>,
1124    /// Controls how the model uses tools.
1125    /// The client MUST return an error if this field is provided but `ClientCapabilities.sampling.tools` is not declared.
1126    /// Default is `{ mode: "auto" }`.
1127    #[serde(
1128        rename = "toolChoice",
1129        default,
1130        skip_serializing_if = "Option::is_none"
1131    )]
1132    pub tool_choice: Option<ToolChoice>,
1133    /// Tools that the model may use during generation.
1134    /// The client MUST return an error if this field is provided but `ClientCapabilities.sampling.tools` is not declared.
1135    #[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
1136    pub tools: Option<Vec<Tool>>,
1137}
1138impl CreateMessageRequestParams {
1139    /// Creates a value from its required fields; optional fields are `None`.
1140    #[must_use]
1141    pub fn new(max_tokens: i64, messages: Vec<SamplingMessage>) -> Self {
1142        Self {
1143            include_context: None,
1144            max_tokens,
1145            messages,
1146            metadata: None,
1147            model_preferences: None,
1148            stop_sequences: None,
1149            system_prompt: None,
1150            temperature: None,
1151            tool_choice: None,
1152            tools: None,
1153        }
1154    }
1155}
1156/// A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
1157/// The client MAY ignore this request.
1158///
1159/// Default is `"none"`. The values `"thisServer"` and `"allServers"` are deprecated (SEP-2596): servers SHOULD
1160/// omit this field or use `"none"`, and SHOULD only use the deprecated values if the client declares
1161/// `ClientCapabilities.sampling.context`.
1162#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1163pub enum CreateMessageRequestParamsIncludeContext {
1164    /// `"allServers"`
1165    #[serde(rename = "allServers")]
1166    AllServers,
1167    /// `"none"`
1168    #[serde(rename = "none")]
1169    None,
1170    /// `"thisServer"`
1171    #[serde(rename = "thisServer")]
1172    ThisServer,
1173}
1174impl CreateMessageRequestParamsIncludeContext {
1175    /// The wire representation of this value.
1176    #[must_use]
1177    pub const fn as_str(self) -> &'static str {
1178        match self {
1179            Self::AllServers => "allServers",
1180            Self::None => "none",
1181            Self::ThisServer => "thisServer",
1182        }
1183    }
1184}
1185/// The result returned by the client for a `CreateMessageRequestsampling/createMessage` request.
1186/// The client should inform the user before returning the sampled message, to allow them
1187/// to inspect the response (human in the loop) and decide whether to allow the server to see it.
1188#[deprecated(
1189    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
1190)]
1191#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1192pub struct CreateMessageResult {
1193    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
1194    pub meta: Option<MetaObject>,
1195    #[serde(rename = "content")]
1196    pub content: CreateMessageResultContent,
1197    /// The name of the model that generated the message.
1198    #[serde(rename = "model")]
1199    pub model: String,
1200    #[serde(rename = "role")]
1201    pub role: Role,
1202    /// The reason why sampling stopped, if known.
1203    ///
1204    /// Standard values:
1205    /// - `"endTurn"`: Natural end of the assistant's turn
1206    /// - `"stopSequence"`: A stop sequence was encountered
1207    /// - `"maxTokens"`: Maximum token limit was reached
1208    /// - `"toolUse"`: The model wants to use one or more tools
1209    ///
1210    /// This field is an open string to allow for provider-specific stop reasons.
1211    #[serde(
1212        rename = "stopReason",
1213        default,
1214        skip_serializing_if = "Option::is_none"
1215    )]
1216    pub stop_reason: Option<String>,
1217}
1218impl CreateMessageResult {
1219    /// Creates a value from its required fields; optional fields are `None`.
1220    #[must_use]
1221    pub fn new(content: CreateMessageResultContent, model: String, role: Role) -> Self {
1222        Self {
1223            meta: None,
1224            content,
1225            model,
1226            role,
1227            stop_reason: None,
1228        }
1229    }
1230}
1231#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1232#[serde(untagged)]
1233pub enum CreateMessageResultContent {
1234    /// The [`TextContent`] variant.
1235    TextContent(TextContent),
1236    /// The [`ImageContent`] variant.
1237    ImageContent(ImageContent),
1238    /// The [`AudioContent`] variant.
1239    AudioContent(AudioContent),
1240    /// The [`ToolUseContent`] variant.
1241    ToolUseContent(ToolUseContent),
1242    /// The [`ToolResultContent`] variant.
1243    ToolResultContent(ToolResultContent),
1244    /// An inline variant.
1245    List(Vec<SamplingMessageContentBlock>),
1246}
1247impl From<TextContent> for CreateMessageResultContent {
1248    fn from(v: TextContent) -> Self {
1249        Self::TextContent(v)
1250    }
1251}
1252impl From<ImageContent> for CreateMessageResultContent {
1253    fn from(v: ImageContent) -> Self {
1254        Self::ImageContent(v)
1255    }
1256}
1257impl From<AudioContent> for CreateMessageResultContent {
1258    fn from(v: AudioContent) -> Self {
1259        Self::AudioContent(v)
1260    }
1261}
1262impl From<ToolUseContent> for CreateMessageResultContent {
1263    fn from(v: ToolUseContent) -> Self {
1264        Self::ToolUseContent(v)
1265    }
1266}
1267impl From<ToolResultContent> for CreateMessageResultContent {
1268    fn from(v: ToolResultContent) -> Self {
1269        Self::ToolResultContent(v)
1270    }
1271}
1272impl From<Vec<SamplingMessageContentBlock>> for CreateMessageResultContent {
1273    fn from(v: Vec<SamplingMessageContentBlock>) -> Self {
1274        Self::List(v)
1275    }
1276}
1277/// An opaque token used to represent a cursor for pagination.
1278pub type Cursor = String;
1279/// A request from the client asking the server to advertise its supported
1280/// protocol versions, capabilities, and other metadata. Servers **MUST**
1281/// implement `server/discover`. Clients **MAY** call it but are not required
1282/// to — version negotiation can also happen inline via per-request `_meta`.
1283#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1284pub struct DiscoverRequest {
1285    #[serde(rename = "id")]
1286    pub id: RequestId,
1287    #[serde(rename = "jsonrpc")]
1288    pub jsonrpc: JsonRpcVersion,
1289    #[serde(rename = "method")]
1290    pub method: ServerDiscoverMethod,
1291    #[serde(rename = "params")]
1292    pub params: RequestParams,
1293}
1294impl DiscoverRequest {
1295    /// Creates a value from its required fields; optional fields are `None`.
1296    #[must_use]
1297    pub fn new(id: RequestId, params: RequestParams) -> Self {
1298        Self {
1299            id,
1300            jsonrpc: Default::default(),
1301            method: Default::default(),
1302            params,
1303        }
1304    }
1305}
1306/// The result returned by the server for a `DiscoverRequestserver/discover` request.
1307#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1308pub struct DiscoverResult {
1309    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
1310    pub meta: Option<ResultMetaObject>,
1311    /// Indicates the intended scope of the cached response, analogous to HTTP
1312    /// `Cache-Control: public` vs `Cache-Control: private`.
1313    ///
1314    /// - `"public"`: The response does not contain user-specific data. Any
1315    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
1316    ///  the response and serve it across authorization contexts.
1317    /// - `"private"`: The response MAY be cached and reused only within the
1318    ///  same authorization context. Caches MUST NOT be shared across
1319    ///  authorization contexts (e.g., a different access token requires a
1320    ///  different cache).
1321    #[serde(rename = "cacheScope")]
1322    pub cache_scope: CacheScope,
1323    /// The capabilities of the server.
1324    #[serde(rename = "capabilities")]
1325    pub capabilities: ServerCapabilities,
1326    /// Natural-language guidance describing the server and its features.
1327    ///
1328    /// This can be used by clients to improve an LLM's understanding of
1329    /// available tools (e.g., by including it in a system prompt). It should
1330    /// focus on information that helps the model use the server effectively
1331    /// and should not duplicate information already in tool descriptions.
1332    #[serde(
1333        rename = "instructions",
1334        default,
1335        skip_serializing_if = "Option::is_none"
1336    )]
1337    pub instructions: Option<String>,
1338    /// Indicates the type of the result, which allows the client to determine
1339    /// how to parse the result object.
1340    ///
1341    /// Servers implementing this protocol version MUST include this field.
1342    /// For backward compatibility, when a client receives a result from a
1343    /// server implementing an earlier protocol version (which does not include
1344    /// `resultType`), the client MUST treat the absent field as `"complete"`.
1345    #[serde(rename = "resultType")]
1346    pub result_type: String,
1347    /// MCP Protocol Versions this server supports. The client should choose a
1348    /// version from this list for use in subsequent requests.
1349    #[serde(rename = "supportedVersions")]
1350    pub supported_versions: Vec<String>,
1351    /// A hint from the server indicating how long (in milliseconds) the
1352    /// client MAY cache this response before re-fetching. Semantics are
1353    /// analogous to HTTP Cache-Control max-age.
1354    ///
1355    /// - If 0, The response SHOULD be considered immediately stale,
1356    ///  The client MAY re-fetch every time the result is needed.
1357    /// - If positive, the client SHOULD consider the result fresh for this many
1358    ///  milliseconds after receiving the response.
1359    #[serde(rename = "ttlMs")]
1360    pub ttl_ms: u64,
1361}
1362impl DiscoverResult {
1363    /// Creates a value from its required fields; optional fields are `None`.
1364    #[must_use]
1365    pub fn new(
1366        cache_scope: CacheScope,
1367        capabilities: ServerCapabilities,
1368        result_type: String,
1369        supported_versions: Vec<String>,
1370        ttl_ms: u64,
1371    ) -> Self {
1372        Self {
1373            meta: None,
1374            cache_scope,
1375            capabilities,
1376            instructions: None,
1377            result_type,
1378            supported_versions,
1379            ttl_ms,
1380        }
1381    }
1382}
1383/// A successful response from the server for a `DiscoverRequestserver/discover` request.
1384#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1385pub struct DiscoverResultResponse {
1386    #[serde(rename = "id")]
1387    pub id: RequestId,
1388    #[serde(rename = "jsonrpc")]
1389    pub jsonrpc: JsonRpcVersion,
1390    #[serde(rename = "result")]
1391    pub result: DiscoverResult,
1392}
1393impl DiscoverResultResponse {
1394    /// Creates a value from its required fields; optional fields are `None`.
1395    #[must_use]
1396    pub fn new(id: RequestId, result: DiscoverResult) -> Self {
1397        Self {
1398            id,
1399            jsonrpc: Default::default(),
1400            result,
1401        }
1402    }
1403}
1404/// A request from the server to elicit additional information from the user via the client.
1405#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1406pub struct ElicitRequest {
1407    #[serde(rename = "method")]
1408    pub method: ElicitationCreateMethod,
1409    #[serde(rename = "params")]
1410    pub params: ElicitRequestParams,
1411}
1412impl ElicitRequest {
1413    /// Creates a value from its required fields; optional fields are `None`.
1414    #[must_use]
1415    pub fn new(params: ElicitRequestParams) -> Self {
1416        Self {
1417            method: Default::default(),
1418            params,
1419        }
1420    }
1421}
1422/// The parameters for a request to elicit non-sensitive information from the user via a form in the client.
1423#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1424pub struct ElicitRequestFormParams {
1425    /// The message to present to the user describing what information is being requested.
1426    #[serde(rename = "message")]
1427    pub message: String,
1428    /// The elicitation mode.
1429    #[serde(rename = "mode", default, skip_serializing_if = "Option::is_none")]
1430    pub mode: Option<FormMode>,
1431    /// A restricted subset of JSON Schema.
1432    /// Only top-level properties are allowed, without nesting.
1433    #[serde(rename = "requestedSchema")]
1434    pub requested_schema: ElicitRequestFormParamsRequestedSchema,
1435}
1436impl ElicitRequestFormParams {
1437    /// Creates a value from its required fields; optional fields are `None`.
1438    #[must_use]
1439    pub fn new(message: String, requested_schema: ElicitRequestFormParamsRequestedSchema) -> Self {
1440        Self {
1441            message,
1442            mode: None,
1443            requested_schema,
1444        }
1445    }
1446}
1447/// A restricted subset of JSON Schema.
1448/// Only top-level properties are allowed, without nesting.
1449#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1450pub struct ElicitRequestFormParamsRequestedSchema {
1451    #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
1452    pub schema: Option<String>,
1453    #[serde(rename = "properties")]
1454    pub properties: std::collections::BTreeMap<String, PrimitiveSchemaDefinition>,
1455    #[serde(rename = "required", default, skip_serializing_if = "Option::is_none")]
1456    pub required: Option<Vec<String>>,
1457    #[serde(rename = "type")]
1458    pub r#type: ObjectType,
1459}
1460impl ElicitRequestFormParamsRequestedSchema {
1461    /// Creates a value from its required fields; optional fields are `None`.
1462    #[must_use]
1463    pub fn new(properties: std::collections::BTreeMap<String, PrimitiveSchemaDefinition>) -> Self {
1464        Self {
1465            schema: None,
1466            properties,
1467            required: None,
1468            r#type: Default::default(),
1469        }
1470    }
1471}
1472/// The parameters for a request to elicit additional information from the user via the client.
1473#[derive(Debug, Clone, PartialEq, Serialize)]
1474#[serde(untagged)]
1475pub enum ElicitRequestParams {
1476    /// The [`ElicitRequestFormParams`] variant.
1477    ElicitRequestForm(ElicitRequestFormParams),
1478    /// The [`ElicitRequestUrlParams`] variant.
1479    ElicitRequestUrl(ElicitRequestUrlParams),
1480}
1481impl From<ElicitRequestFormParams> for ElicitRequestParams {
1482    fn from(v: ElicitRequestFormParams) -> Self {
1483        Self::ElicitRequestForm(v)
1484    }
1485}
1486impl From<ElicitRequestUrlParams> for ElicitRequestParams {
1487    fn from(v: ElicitRequestUrlParams) -> Self {
1488        Self::ElicitRequestUrl(v)
1489    }
1490}
1491impl<'de> Deserialize<'de> for ElicitRequestParams {
1492    fn deserialize<D: serde::Deserializer<'de>>(
1493        deserializer: D,
1494    ) -> ::core::result::Result<Self, D::Error> {
1495        use serde::de::Error as _;
1496        let value = serde_json::Value::deserialize(deserializer)?;
1497        let tag = value
1498            .get("mode")
1499            .and_then(serde_json::Value::as_str)
1500            .map(str::to_owned);
1501        match tag.as_deref() {
1502            Some("form") => serde_json::from_value(value)
1503                .map(Self::ElicitRequestForm)
1504                .map_err(D::Error::custom),
1505            Some("url") => serde_json::from_value(value)
1506                .map(Self::ElicitRequestUrl)
1507                .map_err(D::Error::custom),
1508            None => serde_json::from_value(value)
1509                .map(Self::ElicitRequestForm)
1510                .map_err(D::Error::custom),
1511            Some(other) => Err(D::Error::unknown_variant(other, &["form", "url"])),
1512        }
1513    }
1514}
1515/// The parameters for a request to elicit information from the user via a URL in the client.
1516#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1517pub struct ElicitRequestUrlParams {
1518    /// The message to present to the user explaining why the interaction is needed.
1519    #[serde(rename = "message")]
1520    pub message: String,
1521    /// The elicitation mode.
1522    #[serde(rename = "mode")]
1523    pub mode: UrlMode,
1524    /// The URL that the user should navigate to.
1525    #[serde(rename = "url")]
1526    pub url: String,
1527}
1528impl ElicitRequestUrlParams {
1529    /// Creates a value from its required fields; optional fields are `None`.
1530    #[must_use]
1531    pub fn new(message: String, url: String) -> Self {
1532        Self {
1533            message,
1534            mode: Default::default(),
1535            url,
1536        }
1537    }
1538}
1539/// The result returned by the client for an `ElicitRequestelicitation/create` request.
1540#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1541pub struct ElicitResult {
1542    /// The user action in response to the elicitation.
1543    /// - `"accept"`: User submitted the form/confirmed the action
1544    /// - `"decline"`: User explicitly declined the action
1545    /// - `"cancel"`: User dismissed without making an explicit choice
1546    #[serde(rename = "action")]
1547    pub action: ElicitResultAction,
1548    /// The submitted form data, only present when action is `"accept"` and mode was `"form"`.
1549    /// Contains values matching the requested schema.
1550    /// Omitted for out-of-band mode responses.
1551    #[serde(rename = "content", default, skip_serializing_if = "Option::is_none")]
1552    pub content: Option<std::collections::BTreeMap<String, ElicitResultContentValue>>,
1553}
1554impl ElicitResult {
1555    /// Creates a value from its required fields; optional fields are `None`.
1556    #[must_use]
1557    pub fn new(action: ElicitResultAction) -> Self {
1558        Self {
1559            action,
1560            content: None,
1561        }
1562    }
1563}
1564/// The user action in response to the elicitation.
1565/// - `"accept"`: User submitted the form/confirmed the action
1566/// - `"decline"`: User explicitly declined the action
1567/// - `"cancel"`: User dismissed without making an explicit choice
1568#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1569pub enum ElicitResultAction {
1570    /// `"accept"`
1571    #[serde(rename = "accept")]
1572    Accept,
1573    /// `"cancel"`
1574    #[serde(rename = "cancel")]
1575    Cancel,
1576    /// `"decline"`
1577    #[serde(rename = "decline")]
1578    Decline,
1579}
1580impl ElicitResultAction {
1581    /// The wire representation of this value.
1582    #[must_use]
1583    pub const fn as_str(self) -> &'static str {
1584        match self {
1585            Self::Accept => "accept",
1586            Self::Cancel => "cancel",
1587            Self::Decline => "decline",
1588        }
1589    }
1590}
1591#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1592#[serde(untagged)]
1593pub enum ElicitResultContentValue {
1594    /// An inline variant.
1595    List(Vec<String>),
1596    /// The [`ElicitResultContentValueScalar`] variant.
1597    Scalar(ElicitResultContentValueScalar),
1598}
1599impl From<Vec<String>> for ElicitResultContentValue {
1600    fn from(v: Vec<String>) -> Self {
1601        Self::List(v)
1602    }
1603}
1604impl From<ElicitResultContentValueScalar> for ElicitResultContentValue {
1605    fn from(v: ElicitResultContentValueScalar) -> Self {
1606        Self::Scalar(v)
1607    }
1608}
1609#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
1610#[serde(untagged)]
1611pub enum ElicitResultContentValueScalar {
1612    /// A string value.
1613    String(String),
1614    /// An integer value.
1615    Integer(i64),
1616    /// A boolean value.
1617    Boolean(bool),
1618}
1619impl From<String> for ElicitResultContentValueScalar {
1620    fn from(v: String) -> Self {
1621        Self::String(v)
1622    }
1623}
1624impl From<&str> for ElicitResultContentValueScalar {
1625    fn from(v: &str) -> Self {
1626        Self::String(v.to_owned())
1627    }
1628}
1629impl From<i64> for ElicitResultContentValueScalar {
1630    fn from(v: i64) -> Self {
1631        Self::Integer(v)
1632    }
1633}
1634impl From<bool> for ElicitResultContentValueScalar {
1635    fn from(v: bool) -> Self {
1636        Self::Boolean(v)
1637    }
1638}
1639impl<'de> Deserialize<'de> for ElicitResultContentValueScalar {
1640    fn deserialize<D: serde::Deserializer<'de>>(
1641        deserializer: D,
1642    ) -> ::core::result::Result<Self, D::Error> {
1643        struct Visitor;
1644        impl serde::de::Visitor<'_> for Visitor {
1645            type Value = ElicitResultContentValueScalar;
1646            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1647                f.write_str("a string or an integer or a boolean")
1648            }
1649            fn visit_str<E: serde::de::Error>(
1650                self,
1651                v: &str,
1652            ) -> ::core::result::Result<Self::Value, E> {
1653                Ok(ElicitResultContentValueScalar::String(v.to_owned()))
1654            }
1655            fn visit_string<E: serde::de::Error>(
1656                self,
1657                v: String,
1658            ) -> ::core::result::Result<Self::Value, E> {
1659                Ok(ElicitResultContentValueScalar::String(v))
1660            }
1661            fn visit_i64<E: serde::de::Error>(
1662                self,
1663                v: i64,
1664            ) -> ::core::result::Result<Self::Value, E> {
1665                Ok(ElicitResultContentValueScalar::Integer(v))
1666            }
1667            fn visit_u64<E: serde::de::Error>(
1668                self,
1669                v: u64,
1670            ) -> ::core::result::Result<Self::Value, E> {
1671                i64::try_from(v)
1672                    .map(ElicitResultContentValueScalar::Integer)
1673                    .map_err(|_| E::invalid_value(serde::de::Unexpected::Unsigned(v), &self))
1674            }
1675            #[allow(clippy::cast_possible_truncation, clippy::float_cmp)]
1676            fn visit_f64<E: serde::de::Error>(
1677                self,
1678                v: f64,
1679            ) -> ::core::result::Result<Self::Value, E> {
1680                const MAX_SAFE: f64 = 9_007_199_254_740_991.0;
1681                if v.fract() == 0.0 && (-MAX_SAFE..=MAX_SAFE).contains(&v) {
1682                    Ok(ElicitResultContentValueScalar::Integer(v as i64))
1683                } else {
1684                    Err(E::invalid_type(serde::de::Unexpected::Float(v), &self))
1685                }
1686            }
1687            fn visit_bool<E: serde::de::Error>(
1688                self,
1689                v: bool,
1690            ) -> ::core::result::Result<Self::Value, E> {
1691                Ok(ElicitResultContentValueScalar::Boolean(v))
1692            }
1693        }
1694        deserializer.deserialize_any(Visitor)
1695    }
1696}
1697/// The constant `"elicitation/create"`.
1698#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
1699pub enum ElicitationCreateMethod {
1700    /// The constant `"elicitation/create"`.
1701    #[default]
1702    #[serde(rename = "elicitation/create")]
1703    ElicitationCreate,
1704}
1705impl ElicitationCreateMethod {
1706    /// The wire representation of this constant.
1707    pub const VALUE: &'static str = "elicitation/create";
1708}
1709/// The contents of a resource, embedded into a prompt or tool call result.
1710///
1711/// It is up to the client how best to render embedded resources for the benefit
1712/// of the LLM and/or the user.
1713#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1714pub struct EmbeddedResource {
1715    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
1716    pub meta: Option<MetaObject>,
1717    /// Optional annotations for the client.
1718    #[serde(
1719        rename = "annotations",
1720        default,
1721        skip_serializing_if = "Option::is_none"
1722    )]
1723    pub annotations: Option<Annotations>,
1724    #[serde(rename = "resource")]
1725    pub resource: EmbeddedResourceResource,
1726    #[serde(rename = "type")]
1727    pub r#type: ResourceType,
1728}
1729impl EmbeddedResource {
1730    /// Creates a value from its required fields; optional fields are `None`.
1731    #[must_use]
1732    pub fn new(resource: EmbeddedResourceResource) -> Self {
1733        Self {
1734            meta: None,
1735            annotations: None,
1736            resource,
1737            r#type: Default::default(),
1738        }
1739    }
1740}
1741#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1742#[serde(untagged)]
1743pub enum EmbeddedResourceResource {
1744    /// The [`TextResourceContents`] variant.
1745    Text(TextResourceContents),
1746    /// The [`BlobResourceContents`] variant.
1747    Blob(BlobResourceContents),
1748}
1749impl From<TextResourceContents> for EmbeddedResourceResource {
1750    fn from(v: TextResourceContents) -> Self {
1751        Self::Text(v)
1752    }
1753}
1754impl From<BlobResourceContents> for EmbeddedResourceResource {
1755    fn from(v: BlobResourceContents) -> Self {
1756        Self::Blob(v)
1757    }
1758}
1759/// Common result fields.
1760pub type EmptyResult = Result;
1761#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1762#[serde(untagged)]
1763pub enum EnumSchema {
1764    /// The [`UntitledSingleSelectEnumSchema`] variant.
1765    UntitledSingleSelect(UntitledSingleSelectEnumSchema),
1766    /// The [`TitledSingleSelectEnumSchema`] variant.
1767    TitledSingleSelect(TitledSingleSelectEnumSchema),
1768    /// The [`UntitledMultiSelectEnumSchema`] variant.
1769    UntitledMultiSelect(UntitledMultiSelectEnumSchema),
1770    /// The [`TitledMultiSelectEnumSchema`] variant.
1771    TitledMultiSelect(TitledMultiSelectEnumSchema),
1772    /// The [`LegacyTitledEnumSchema`] variant.
1773    LegacyTitled(LegacyTitledEnumSchema),
1774}
1775impl From<UntitledSingleSelectEnumSchema> for EnumSchema {
1776    fn from(v: UntitledSingleSelectEnumSchema) -> Self {
1777        Self::UntitledSingleSelect(v)
1778    }
1779}
1780impl From<TitledSingleSelectEnumSchema> for EnumSchema {
1781    fn from(v: TitledSingleSelectEnumSchema) -> Self {
1782        Self::TitledSingleSelect(v)
1783    }
1784}
1785impl From<UntitledMultiSelectEnumSchema> for EnumSchema {
1786    fn from(v: UntitledMultiSelectEnumSchema) -> Self {
1787        Self::UntitledMultiSelect(v)
1788    }
1789}
1790impl From<TitledMultiSelectEnumSchema> for EnumSchema {
1791    fn from(v: TitledMultiSelectEnumSchema) -> Self {
1792        Self::TitledMultiSelect(v)
1793    }
1794}
1795impl From<LegacyTitledEnumSchema> for EnumSchema {
1796    fn from(v: LegacyTitledEnumSchema) -> Self {
1797        Self::LegacyTitled(v)
1798    }
1799}
1800#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1801pub struct Error {
1802    /// The error type that occurred.
1803    #[serde(rename = "code")]
1804    pub code: i64,
1805    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
1806    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
1807    pub data: Option<serde_json::Value>,
1808    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
1809    #[serde(rename = "message")]
1810    pub message: String,
1811}
1812impl Error {
1813    /// Creates a value from its required fields; optional fields are `None`.
1814    #[must_use]
1815    pub fn new(code: i64, message: String) -> Self {
1816        Self {
1817            code,
1818            data: None,
1819            message,
1820        }
1821    }
1822}
1823/// The constant `"form"`.
1824#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
1825pub enum FormMode {
1826    /// The constant `"form"`.
1827    #[default]
1828    #[serde(rename = "form")]
1829    Form,
1830}
1831impl FormMode {
1832    /// The wire representation of this constant.
1833    pub const VALUE: &'static str = "form";
1834}
1835/// Used by the client to get a prompt provided by the server.
1836#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1837pub struct GetPromptRequest {
1838    #[serde(rename = "id")]
1839    pub id: RequestId,
1840    #[serde(rename = "jsonrpc")]
1841    pub jsonrpc: JsonRpcVersion,
1842    #[serde(rename = "method")]
1843    pub method: PromptsGetMethod,
1844    #[serde(rename = "params")]
1845    pub params: GetPromptRequestParams,
1846}
1847impl GetPromptRequest {
1848    /// Creates a value from its required fields; optional fields are `None`.
1849    #[must_use]
1850    pub fn new(id: RequestId, params: GetPromptRequestParams) -> Self {
1851        Self {
1852            id,
1853            jsonrpc: Default::default(),
1854            method: Default::default(),
1855            params,
1856        }
1857    }
1858}
1859/// Parameters for a `prompts/get` request.
1860#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1861pub struct GetPromptRequestParams {
1862    #[serde(rename = "_meta")]
1863    pub meta: RequestMetaObject,
1864    /// Arguments to use for templating the prompt.
1865    #[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
1866    pub arguments: Option<std::collections::BTreeMap<String, String>>,
1867    #[serde(
1868        rename = "inputResponses",
1869        default,
1870        skip_serializing_if = "Option::is_none"
1871    )]
1872    pub input_responses: Option<InputResponses>,
1873    /// The name of the prompt or prompt template.
1874    #[serde(rename = "name")]
1875    pub name: String,
1876    #[serde(
1877        rename = "requestState",
1878        default,
1879        skip_serializing_if = "Option::is_none"
1880    )]
1881    pub request_state: Option<String>,
1882}
1883impl GetPromptRequestParams {
1884    /// Creates a value from its required fields; optional fields are `None`.
1885    #[must_use]
1886    pub fn new(meta: RequestMetaObject, name: String) -> Self {
1887        Self {
1888            meta,
1889            arguments: None,
1890            input_responses: None,
1891            name,
1892            request_state: None,
1893        }
1894    }
1895}
1896/// The result returned by the server for a `GetPromptRequestprompts/get` request.
1897#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1898pub struct GetPromptResult {
1899    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
1900    pub meta: Option<ResultMetaObject>,
1901    /// An optional description for the prompt.
1902    #[serde(
1903        rename = "description",
1904        default,
1905        skip_serializing_if = "Option::is_none"
1906    )]
1907    pub description: Option<String>,
1908    #[serde(rename = "messages")]
1909    pub messages: Vec<PromptMessage>,
1910    /// Indicates the type of the result, which allows the client to determine
1911    /// how to parse the result object.
1912    ///
1913    /// Servers implementing this protocol version MUST include this field.
1914    /// For backward compatibility, when a client receives a result from a
1915    /// server implementing an earlier protocol version (which does not include
1916    /// `resultType`), the client MUST treat the absent field as `"complete"`.
1917    #[serde(rename = "resultType")]
1918    pub result_type: String,
1919}
1920impl GetPromptResult {
1921    /// Creates a value from its required fields; optional fields are `None`.
1922    #[must_use]
1923    pub fn new(messages: Vec<PromptMessage>, result_type: String) -> Self {
1924        Self {
1925            meta: None,
1926            description: None,
1927            messages,
1928            result_type,
1929        }
1930    }
1931}
1932/// A successful response from the server for a `GetPromptRequestprompts/get` request.
1933#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1934pub struct GetPromptResultResponse {
1935    #[serde(rename = "id")]
1936    pub id: RequestId,
1937    #[serde(rename = "jsonrpc")]
1938    pub jsonrpc: JsonRpcVersion,
1939    #[serde(rename = "result")]
1940    pub result: GetPromptResultResponseResult,
1941}
1942impl GetPromptResultResponse {
1943    /// Creates a value from its required fields; optional fields are `None`.
1944    #[must_use]
1945    pub fn new(id: RequestId, result: GetPromptResultResponseResult) -> Self {
1946        Self {
1947            id,
1948            jsonrpc: Default::default(),
1949            result,
1950        }
1951    }
1952}
1953#[derive(Debug, Clone, PartialEq, Serialize)]
1954#[serde(untagged)]
1955pub enum GetPromptResultResponseResult {
1956    /// The [`InputRequiredResult`] variant.
1957    InputRequired(InputRequiredResult),
1958    /// The [`GetPromptResult`] variant.
1959    GetPrompt(GetPromptResult),
1960}
1961impl From<InputRequiredResult> for GetPromptResultResponseResult {
1962    fn from(v: InputRequiredResult) -> Self {
1963        Self::InputRequired(v)
1964    }
1965}
1966impl From<GetPromptResult> for GetPromptResultResponseResult {
1967    fn from(v: GetPromptResult) -> Self {
1968        Self::GetPrompt(v)
1969    }
1970}
1971impl<'de> Deserialize<'de> for GetPromptResultResponseResult {
1972    fn deserialize<D: serde::Deserializer<'de>>(
1973        deserializer: D,
1974    ) -> ::core::result::Result<Self, D::Error> {
1975        use serde::de::Error as _;
1976        let value = serde_json::Value::deserialize(deserializer)?;
1977        let tag = value
1978            .get("resultType")
1979            .and_then(serde_json::Value::as_str)
1980            .map(str::to_owned);
1981        match tag.as_deref() {
1982            Some("input_required") => serde_json::from_value(value)
1983                .map(Self::InputRequired)
1984                .map_err(D::Error::custom),
1985            _ => serde_json::from_value(value)
1986                .map(Self::GetPrompt)
1987                .map_err(D::Error::custom),
1988        }
1989    }
1990}
1991/// Returned when a server rejects a request because the values in the HTTP
1992/// headers do not match the corresponding values in the request body, or
1993/// because required headers are missing or malformed. For HTTP, the response
1994/// status code MUST be `400 Bad Request`.
1995#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1996pub struct HeaderMismatchError {
1997    #[serde(rename = "error")]
1998    pub error: HeaderMismatchErrorObject,
1999    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2000    pub id: Option<RequestId>,
2001    #[serde(rename = "jsonrpc")]
2002    pub jsonrpc: JsonRpcVersion,
2003}
2004impl HeaderMismatchError {
2005    /// Creates a value from its required fields; optional fields are `None`.
2006    #[must_use]
2007    pub fn new(error: HeaderMismatchErrorObject) -> Self {
2008        Self {
2009            error,
2010            id: None,
2011            jsonrpc: Default::default(),
2012        }
2013    }
2014}
2015#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2016pub struct HeaderMismatchErrorObject {
2017    #[serde(rename = "code")]
2018    pub code: i64,
2019    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
2020    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2021    pub data: Option<serde_json::Value>,
2022    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
2023    #[serde(rename = "message")]
2024    pub message: String,
2025}
2026impl HeaderMismatchErrorObject {
2027    /// Creates a value from its required fields; optional fields are `None`.
2028    #[must_use]
2029    pub fn new(code: i64, message: String) -> Self {
2030        Self {
2031            code,
2032            data: None,
2033            message,
2034        }
2035    }
2036}
2037/// An optionally-sized icon that can be displayed in a user interface.
2038#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2039pub struct Icon {
2040    /// Optional MIME type override if the source MIME type is missing or generic.
2041    /// For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`.
2042    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
2043    pub mime_type: Option<String>,
2044    /// Optional array of strings that specify sizes at which the icon can be used.
2045    /// Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
2046    ///
2047    /// If not provided, the client should assume that the icon can be used at any size.
2048    #[serde(rename = "sizes", default, skip_serializing_if = "Option::is_none")]
2049    pub sizes: Option<Vec<String>>,
2050    /// A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a
2051    /// `data:` URI with Base64-encoded image data.
2052    ///
2053    /// Consumers SHOULD take steps to ensure URLs serving icons are from the
2054    /// same domain as the client/server or a trusted domain.
2055    ///
2056    /// Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain
2057    /// executable JavaScript.
2058    #[serde(rename = "src")]
2059    pub src: String,
2060    /// Optional specifier for the theme this icon is designed for. `"light"` indicates
2061    /// the icon is designed to be used with a light background, and `"dark"` indicates
2062    /// the icon is designed to be used with a dark background.
2063    ///
2064    /// If not provided, the client should assume the icon can be used with any theme.
2065    #[serde(rename = "theme", default, skip_serializing_if = "Option::is_none")]
2066    pub theme: Option<IconTheme>,
2067}
2068impl Icon {
2069    /// Creates a value from its required fields; optional fields are `None`.
2070    #[must_use]
2071    pub fn new(src: String) -> Self {
2072        Self {
2073            mime_type: None,
2074            sizes: None,
2075            src,
2076            theme: None,
2077        }
2078    }
2079}
2080/// Optional specifier for the theme this icon is designed for. `"light"` indicates
2081/// the icon is designed to be used with a light background, and `"dark"` indicates
2082/// the icon is designed to be used with a dark background.
2083///
2084/// If not provided, the client should assume the icon can be used with any theme.
2085#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
2086pub enum IconTheme {
2087    /// `"dark"`
2088    #[serde(rename = "dark")]
2089    Dark,
2090    /// `"light"`
2091    #[serde(rename = "light")]
2092    Light,
2093}
2094impl IconTheme {
2095    /// The wire representation of this value.
2096    #[must_use]
2097    pub const fn as_str(self) -> &'static str {
2098        match self {
2099            Self::Dark => "dark",
2100            Self::Light => "light",
2101        }
2102    }
2103}
2104/// Base interface to add `icons` property.
2105#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
2106pub struct Icons {
2107    /// Optional set of sized icons that the client can display in a user interface.
2108    ///
2109    /// Clients that support rendering icons MUST support at least the following MIME types:
2110    /// - `image/png` - PNG images (safe, universal compatibility)
2111    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
2112    ///
2113    /// Clients that support rendering icons SHOULD also support:
2114    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
2115    /// - `image/webp` - WebP images (modern, efficient format)
2116    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
2117    pub icons: Option<Vec<Icon>>,
2118}
2119/// An image provided to or from an LLM.
2120#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2121pub struct ImageContent {
2122    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
2123    pub meta: Option<MetaObject>,
2124    /// Optional annotations for the client.
2125    #[serde(
2126        rename = "annotations",
2127        default,
2128        skip_serializing_if = "Option::is_none"
2129    )]
2130    pub annotations: Option<Annotations>,
2131    /// The base64-encoded image data.
2132    #[serde(rename = "data")]
2133    pub data: String,
2134    /// The MIME type of the image. Different providers may support different image types.
2135    #[serde(rename = "mimeType")]
2136    pub mime_type: String,
2137    #[serde(rename = "type")]
2138    pub r#type: ImageType,
2139}
2140impl ImageContent {
2141    /// Creates a value from its required fields; optional fields are `None`.
2142    #[must_use]
2143    pub fn new(data: String, mime_type: String) -> Self {
2144        Self {
2145            meta: None,
2146            annotations: None,
2147            data,
2148            mime_type,
2149            r#type: Default::default(),
2150        }
2151    }
2152}
2153/// The constant `"image"`.
2154#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
2155pub enum ImageType {
2156    /// The constant `"image"`.
2157    #[default]
2158    #[serde(rename = "image")]
2159    Image,
2160}
2161impl ImageType {
2162    /// The wire representation of this constant.
2163    pub const VALUE: &'static str = "image";
2164}
2165/// Describes the MCP implementation.
2166#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2167pub struct Implementation {
2168    /// An optional human-readable description of what this implementation does.
2169    ///
2170    /// This can be used by clients or servers to provide context about their purpose
2171    /// and capabilities. For example, a server might describe the types of resources
2172    /// or tools it provides, while a client might describe its intended use case.
2173    #[serde(
2174        rename = "description",
2175        default,
2176        skip_serializing_if = "Option::is_none"
2177    )]
2178    pub description: Option<String>,
2179    /// Optional set of sized icons that the client can display in a user interface.
2180    ///
2181    /// Clients that support rendering icons MUST support at least the following MIME types:
2182    /// - `image/png` - PNG images (safe, universal compatibility)
2183    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
2184    ///
2185    /// Clients that support rendering icons SHOULD also support:
2186    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
2187    /// - `image/webp` - WebP images (modern, efficient format)
2188    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
2189    pub icons: Option<Vec<Icon>>,
2190    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
2191    #[serde(rename = "name")]
2192    pub name: String,
2193    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
2194    /// even by those unfamiliar with domain-specific terminology.
2195    ///
2196    /// If not provided, the name should be used for display (except for `Tool`,
2197    /// where `annotations.title` should be given precedence over using `name`,
2198    /// if present).
2199    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
2200    pub title: Option<String>,
2201    /// The version of this implementation.
2202    #[serde(rename = "version")]
2203    pub version: String,
2204    /// An optional URL of the website for this implementation.
2205    #[serde(
2206        rename = "websiteUrl",
2207        default,
2208        skip_serializing_if = "Option::is_none"
2209    )]
2210    pub website_url: Option<String>,
2211}
2212impl Implementation {
2213    /// Creates a value from its required fields; optional fields are `None`.
2214    #[must_use]
2215    pub fn new(name: String, version: String) -> Self {
2216        Self {
2217            description: None,
2218            icons: None,
2219            name,
2220            title: None,
2221            version,
2222            website_url: None,
2223        }
2224    }
2225}
2226#[derive(Debug, Clone, PartialEq, Serialize)]
2227#[serde(untagged)]
2228pub enum InputRequest {
2229    /// The [`CreateMessageRequest`] variant.
2230    CreateMessage(CreateMessageRequest),
2231    /// The [`ListRootsRequest`] variant.
2232    ListRoots(ListRootsRequest),
2233    /// The [`ElicitRequest`] variant.
2234    Elicit(ElicitRequest),
2235}
2236impl From<CreateMessageRequest> for InputRequest {
2237    fn from(v: CreateMessageRequest) -> Self {
2238        Self::CreateMessage(v)
2239    }
2240}
2241impl From<ListRootsRequest> for InputRequest {
2242    fn from(v: ListRootsRequest) -> Self {
2243        Self::ListRoots(v)
2244    }
2245}
2246impl From<ElicitRequest> for InputRequest {
2247    fn from(v: ElicitRequest) -> Self {
2248        Self::Elicit(v)
2249    }
2250}
2251impl<'de> Deserialize<'de> for InputRequest {
2252    fn deserialize<D: serde::Deserializer<'de>>(
2253        deserializer: D,
2254    ) -> ::core::result::Result<Self, D::Error> {
2255        use serde::de::Error as _;
2256        let value = serde_json::Value::deserialize(deserializer)?;
2257        let tag = value
2258            .get("method")
2259            .and_then(serde_json::Value::as_str)
2260            .map(str::to_owned);
2261        match tag.as_deref() {
2262            Some("sampling/createMessage") => serde_json::from_value(value)
2263                .map(Self::CreateMessage)
2264                .map_err(D::Error::custom),
2265            Some("roots/list") => serde_json::from_value(value)
2266                .map(Self::ListRoots)
2267                .map_err(D::Error::custom),
2268            Some("elicitation/create") => serde_json::from_value(value)
2269                .map(Self::Elicit)
2270                .map_err(D::Error::custom),
2271            None => Err(D::Error::missing_field("method")),
2272            Some(other) => Err(D::Error::unknown_variant(
2273                other,
2274                &["sampling/createMessage", "roots/list", "elicitation/create"],
2275            )),
2276        }
2277    }
2278}
2279/// A map of server-initiated requests that the client must fulfill.
2280/// Keys are server-assigned identifiers; values are the request objects.
2281pub type InputRequests = std::collections::BTreeMap<String, InputRequest>;
2282/// An InputRequiredResult sent by the server to indicate that additional input is needed
2283/// before the request can be completed.
2284///
2285/// At least one of `inputRequests` or `requestState` MUST be present.
2286#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2287pub struct InputRequiredResult {
2288    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
2289    pub meta: Option<ResultMetaObject>,
2290    #[serde(
2291        rename = "inputRequests",
2292        default,
2293        skip_serializing_if = "Option::is_none"
2294    )]
2295    pub input_requests: Option<InputRequests>,
2296    #[serde(
2297        rename = "requestState",
2298        default,
2299        skip_serializing_if = "Option::is_none"
2300    )]
2301    pub request_state: Option<String>,
2302    /// Indicates the type of the result, which allows the client to determine
2303    /// how to parse the result object.
2304    ///
2305    /// Servers implementing this protocol version MUST include this field.
2306    /// For backward compatibility, when a client receives a result from a
2307    /// server implementing an earlier protocol version (which does not include
2308    /// `resultType`), the client MUST treat the absent field as `"complete"`.
2309    #[serde(rename = "resultType")]
2310    pub result_type: String,
2311}
2312impl InputRequiredResult {
2313    /// Creates a value from its required fields; optional fields are `None`.
2314    #[must_use]
2315    pub fn new(result_type: String) -> Self {
2316        Self {
2317            meta: None,
2318            input_requests: None,
2319            request_state: None,
2320            result_type,
2321        }
2322    }
2323}
2324#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2325#[serde(untagged)]
2326pub enum InputResponse {
2327    /// The [`CreateMessageResult`] variant.
2328    CreateMessage(CreateMessageResult),
2329    /// The [`ListRootsResult`] variant.
2330    ListRoots(ListRootsResult),
2331    /// The [`ElicitResult`] variant.
2332    Elicit(ElicitResult),
2333}
2334impl From<CreateMessageResult> for InputResponse {
2335    fn from(v: CreateMessageResult) -> Self {
2336        Self::CreateMessage(v)
2337    }
2338}
2339impl From<ListRootsResult> for InputResponse {
2340    fn from(v: ListRootsResult) -> Self {
2341        Self::ListRoots(v)
2342    }
2343}
2344impl From<ElicitResult> for InputResponse {
2345    fn from(v: ElicitResult) -> Self {
2346        Self::Elicit(v)
2347    }
2348}
2349#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2350pub struct InputResponseRequestParams {
2351    #[serde(rename = "_meta")]
2352    pub meta: RequestMetaObject,
2353    #[serde(
2354        rename = "inputResponses",
2355        default,
2356        skip_serializing_if = "Option::is_none"
2357    )]
2358    pub input_responses: Option<InputResponses>,
2359    #[serde(
2360        rename = "requestState",
2361        default,
2362        skip_serializing_if = "Option::is_none"
2363    )]
2364    pub request_state: Option<String>,
2365}
2366impl InputResponseRequestParams {
2367    /// Creates a value from its required fields; optional fields are `None`.
2368    #[must_use]
2369    pub fn new(meta: RequestMetaObject) -> Self {
2370        Self {
2371            meta,
2372            input_responses: None,
2373            request_state: None,
2374        }
2375    }
2376}
2377/// A map of client responses to server-initiated requests.
2378/// Keys correspond to the keys in the `InputRequests` map;
2379/// values are the client's result for each request.
2380pub type InputResponses = std::collections::BTreeMap<String, InputResponse>;
2381/// A JSON-RPC error indicating that an internal error occurred on the receiver. This error is returned when the receiver encounters an unexpected condition that prevents it from fulfilling the request.
2382#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2383pub struct InternalError {
2384    /// The error type that occurred.
2385    #[serde(rename = "code")]
2386    pub code: i64,
2387    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
2388    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2389    pub data: Option<serde_json::Value>,
2390    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
2391    #[serde(rename = "message")]
2392    pub message: String,
2393}
2394impl InternalError {
2395    /// Creates a value from its required fields; optional fields are `None`.
2396    #[must_use]
2397    pub fn new(code: i64, message: String) -> Self {
2398        Self {
2399            code,
2400            data: None,
2401            message,
2402        }
2403    }
2404}
2405/// A JSON-RPC error indicating that the method parameters are invalid or malformed.
2406///
2407/// In MCP, this error is returned in various contexts when request parameters fail validation:
2408///
2409/// - **Tools**: Unknown tool name or invalid tool arguments
2410/// - **Prompts**: Unknown prompt name or missing required arguments
2411/// - **Pagination**: Invalid or expired cursor values
2412/// - **Logging**: Invalid log level
2413/// - **Elicitation**: Server requests an elicitation mode not declared in client capabilities
2414/// - **Sampling**: Missing tool result or tool results mixed with other content
2415#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2416pub struct InvalidParamsError {
2417    /// The error type that occurred.
2418    #[serde(rename = "code")]
2419    pub code: i64,
2420    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
2421    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2422    pub data: Option<serde_json::Value>,
2423    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
2424    #[serde(rename = "message")]
2425    pub message: String,
2426}
2427impl InvalidParamsError {
2428    /// Creates a value from its required fields; optional fields are `None`.
2429    #[must_use]
2430    pub fn new(code: i64, message: String) -> Self {
2431        Self {
2432            code,
2433            data: None,
2434            message,
2435        }
2436    }
2437}
2438/// A JSON-RPC error indicating that the request is not a valid request object. This error is returned when the message structure does not conform to the JSON-RPC 2.0 specification requirements for a request (e.g., missing required fields like `jsonrpc` or `method`, or using invalid types for these fields).
2439#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2440pub struct InvalidRequestError {
2441    /// The error type that occurred.
2442    #[serde(rename = "code")]
2443    pub code: i64,
2444    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
2445    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2446    pub data: Option<serde_json::Value>,
2447    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
2448    #[serde(rename = "message")]
2449    pub message: String,
2450}
2451impl InvalidRequestError {
2452    /// Creates a value from its required fields; optional fields are `None`.
2453    #[must_use]
2454    pub fn new(code: i64, message: String) -> Self {
2455        Self {
2456            code,
2457            data: None,
2458            message,
2459        }
2460    }
2461}
2462/// A response to a request that indicates an error occurred.
2463#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2464pub struct JsonRpcErrorResponse {
2465    #[serde(rename = "error")]
2466    pub error: Error,
2467    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2468    pub id: Option<RequestId>,
2469    #[serde(rename = "jsonrpc")]
2470    pub jsonrpc: JsonRpcVersion,
2471}
2472impl JsonRpcErrorResponse {
2473    /// Creates a value from its required fields; optional fields are `None`.
2474    #[must_use]
2475    pub fn new(error: Error) -> Self {
2476        Self {
2477            error,
2478            id: None,
2479            jsonrpc: Default::default(),
2480        }
2481    }
2482}
2483/// Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
2484#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2485#[serde(untagged)]
2486pub enum JsonRpcMessage {
2487    /// The [`JsonRpcRequest`] variant.
2488    JsonRpcRequest(JsonRpcRequest),
2489    /// The [`JsonRpcNotification`] variant.
2490    JsonRpcNotification(JsonRpcNotification),
2491    /// The [`JsonRpcResultResponse`] variant.
2492    JsonRpcResultResponse(JsonRpcResultResponse),
2493    /// The [`JsonRpcErrorResponse`] variant.
2494    JsonRpcErrorResponse(JsonRpcErrorResponse),
2495}
2496impl From<JsonRpcRequest> for JsonRpcMessage {
2497    fn from(v: JsonRpcRequest) -> Self {
2498        Self::JsonRpcRequest(v)
2499    }
2500}
2501impl From<JsonRpcNotification> for JsonRpcMessage {
2502    fn from(v: JsonRpcNotification) -> Self {
2503        Self::JsonRpcNotification(v)
2504    }
2505}
2506impl From<JsonRpcResultResponse> for JsonRpcMessage {
2507    fn from(v: JsonRpcResultResponse) -> Self {
2508        Self::JsonRpcResultResponse(v)
2509    }
2510}
2511impl From<JsonRpcErrorResponse> for JsonRpcMessage {
2512    fn from(v: JsonRpcErrorResponse) -> Self {
2513        Self::JsonRpcErrorResponse(v)
2514    }
2515}
2516/// A notification which does not expect a response.
2517#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2518pub struct JsonRpcNotification {
2519    #[serde(rename = "jsonrpc")]
2520    pub jsonrpc: JsonRpcVersion,
2521    #[serde(rename = "method")]
2522    pub method: String,
2523    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
2524    pub params: Option<serde_json::Map<String, serde_json::Value>>,
2525}
2526impl JsonRpcNotification {
2527    /// Creates a value from its required fields; optional fields are `None`.
2528    #[must_use]
2529    pub fn new(method: String) -> Self {
2530        Self {
2531            jsonrpc: Default::default(),
2532            method,
2533            params: None,
2534        }
2535    }
2536}
2537/// A request that expects a response.
2538#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2539pub struct JsonRpcRequest {
2540    #[serde(rename = "id")]
2541    pub id: RequestId,
2542    #[serde(rename = "jsonrpc")]
2543    pub jsonrpc: JsonRpcVersion,
2544    #[serde(rename = "method")]
2545    pub method: String,
2546    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
2547    pub params: Option<serde_json::Map<String, serde_json::Value>>,
2548}
2549impl JsonRpcRequest {
2550    /// Creates a value from its required fields; optional fields are `None`.
2551    #[must_use]
2552    pub fn new(id: RequestId, method: String) -> Self {
2553        Self {
2554            id,
2555            jsonrpc: Default::default(),
2556            method,
2557            params: None,
2558        }
2559    }
2560}
2561/// A response to a request, containing either the result or error.
2562#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2563#[serde(untagged)]
2564pub enum JsonRpcResponse {
2565    /// The [`JsonRpcResultResponse`] variant.
2566    JsonRpcResult(JsonRpcResultResponse),
2567    /// The [`JsonRpcErrorResponse`] variant.
2568    JsonRpcError(JsonRpcErrorResponse),
2569}
2570impl From<JsonRpcResultResponse> for JsonRpcResponse {
2571    fn from(v: JsonRpcResultResponse) -> Self {
2572        Self::JsonRpcResult(v)
2573    }
2574}
2575impl From<JsonRpcErrorResponse> for JsonRpcResponse {
2576    fn from(v: JsonRpcErrorResponse) -> Self {
2577        Self::JsonRpcError(v)
2578    }
2579}
2580/// A successful (non-error) response to a request.
2581#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2582pub struct JsonRpcResultResponse {
2583    #[serde(rename = "id")]
2584    pub id: RequestId,
2585    #[serde(rename = "jsonrpc")]
2586    pub jsonrpc: JsonRpcVersion,
2587    #[serde(rename = "result")]
2588    pub result: Result,
2589}
2590impl JsonRpcResultResponse {
2591    /// Creates a value from its required fields; optional fields are `None`.
2592    #[must_use]
2593    pub fn new(id: RequestId, result: Result) -> Self {
2594        Self {
2595            id,
2596            jsonrpc: Default::default(),
2597            result,
2598        }
2599    }
2600}
2601/// The constant `"2.0"`.
2602#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
2603pub enum JsonRpcVersion {
2604    /// The constant `"2.0"`.
2605    #[default]
2606    #[serde(rename = "2.0")]
2607    V20,
2608}
2609impl JsonRpcVersion {
2610    /// The wire representation of this constant.
2611    pub const VALUE: &'static str = "2.0";
2612}
2613/// Use `TitledSingleSelectEnumSchema` instead.
2614/// This interface will be removed in a future version.
2615#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2616pub struct LegacyTitledEnumSchema {
2617    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
2618    pub default: Option<String>,
2619    #[serde(
2620        rename = "description",
2621        default,
2622        skip_serializing_if = "Option::is_none"
2623    )]
2624    pub description: Option<String>,
2625    #[serde(rename = "enum")]
2626    pub r#enum: Vec<String>,
2627    /// (Legacy) Display names for enum values.
2628    /// Non-standard according to JSON schema 2020-12.
2629    #[serde(rename = "enumNames", default, skip_serializing_if = "Option::is_none")]
2630    pub enum_names: Option<Vec<String>>,
2631    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
2632    pub title: Option<String>,
2633    #[serde(rename = "type")]
2634    pub r#type: StringType,
2635}
2636impl LegacyTitledEnumSchema {
2637    /// Creates a value from its required fields; optional fields are `None`.
2638    #[must_use]
2639    pub fn new(r#enum: Vec<String>) -> Self {
2640        Self {
2641            default: None,
2642            description: None,
2643            r#enum,
2644            enum_names: None,
2645            title: None,
2646            r#type: Default::default(),
2647        }
2648    }
2649}
2650/// Sent from the client to request a list of prompts and prompt templates the server has.
2651#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2652pub struct ListPromptsRequest {
2653    #[serde(rename = "id")]
2654    pub id: RequestId,
2655    #[serde(rename = "jsonrpc")]
2656    pub jsonrpc: JsonRpcVersion,
2657    #[serde(rename = "method")]
2658    pub method: PromptsListMethod,
2659    #[serde(rename = "params")]
2660    pub params: PaginatedRequestParams,
2661}
2662impl ListPromptsRequest {
2663    /// Creates a value from its required fields; optional fields are `None`.
2664    #[must_use]
2665    pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
2666        Self {
2667            id,
2668            jsonrpc: Default::default(),
2669            method: Default::default(),
2670            params,
2671        }
2672    }
2673}
2674/// The result returned by the server for a `ListPromptsRequestprompts/list` request.
2675#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2676pub struct ListPromptsResult {
2677    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
2678    pub meta: Option<ResultMetaObject>,
2679    /// Indicates the intended scope of the cached response, analogous to HTTP
2680    /// `Cache-Control: public` vs `Cache-Control: private`.
2681    ///
2682    /// - `"public"`: The response does not contain user-specific data. Any
2683    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
2684    ///  the response and serve it across authorization contexts.
2685    /// - `"private"`: The response MAY be cached and reused only within the
2686    ///  same authorization context. Caches MUST NOT be shared across
2687    ///  authorization contexts (e.g., a different access token requires a
2688    ///  different cache).
2689    #[serde(rename = "cacheScope")]
2690    pub cache_scope: CacheScope,
2691    /// An opaque token representing the pagination position after the last returned result.
2692    /// If present, there may be more results available.
2693    #[serde(
2694        rename = "nextCursor",
2695        default,
2696        skip_serializing_if = "Option::is_none"
2697    )]
2698    pub next_cursor: Option<String>,
2699    #[serde(rename = "prompts")]
2700    pub prompts: Vec<Prompt>,
2701    /// Indicates the type of the result, which allows the client to determine
2702    /// how to parse the result object.
2703    ///
2704    /// Servers implementing this protocol version MUST include this field.
2705    /// For backward compatibility, when a client receives a result from a
2706    /// server implementing an earlier protocol version (which does not include
2707    /// `resultType`), the client MUST treat the absent field as `"complete"`.
2708    #[serde(rename = "resultType")]
2709    pub result_type: String,
2710    /// A hint from the server indicating how long (in milliseconds) the
2711    /// client MAY cache this response before re-fetching. Semantics are
2712    /// analogous to HTTP Cache-Control max-age.
2713    ///
2714    /// - If 0, The response SHOULD be considered immediately stale,
2715    ///  The client MAY re-fetch every time the result is needed.
2716    /// - If positive, the client SHOULD consider the result fresh for this many
2717    ///  milliseconds after receiving the response.
2718    #[serde(rename = "ttlMs")]
2719    pub ttl_ms: u64,
2720}
2721impl ListPromptsResult {
2722    /// Creates a value from its required fields; optional fields are `None`.
2723    #[must_use]
2724    pub fn new(
2725        cache_scope: CacheScope,
2726        prompts: Vec<Prompt>,
2727        result_type: String,
2728        ttl_ms: u64,
2729    ) -> Self {
2730        Self {
2731            meta: None,
2732            cache_scope,
2733            next_cursor: None,
2734            prompts,
2735            result_type,
2736            ttl_ms,
2737        }
2738    }
2739}
2740/// A successful response from the server for a `ListPromptsRequestprompts/list` request.
2741#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2742pub struct ListPromptsResultResponse {
2743    #[serde(rename = "id")]
2744    pub id: RequestId,
2745    #[serde(rename = "jsonrpc")]
2746    pub jsonrpc: JsonRpcVersion,
2747    #[serde(rename = "result")]
2748    pub result: ListPromptsResult,
2749}
2750impl ListPromptsResultResponse {
2751    /// Creates a value from its required fields; optional fields are `None`.
2752    #[must_use]
2753    pub fn new(id: RequestId, result: ListPromptsResult) -> Self {
2754        Self {
2755            id,
2756            jsonrpc: Default::default(),
2757            result,
2758        }
2759    }
2760}
2761/// Sent from the client to request a list of resource templates the server has.
2762#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2763pub struct ListResourceTemplatesRequest {
2764    #[serde(rename = "id")]
2765    pub id: RequestId,
2766    #[serde(rename = "jsonrpc")]
2767    pub jsonrpc: JsonRpcVersion,
2768    #[serde(rename = "method")]
2769    pub method: ResourcesTemplatesListMethod,
2770    #[serde(rename = "params")]
2771    pub params: PaginatedRequestParams,
2772}
2773impl ListResourceTemplatesRequest {
2774    /// Creates a value from its required fields; optional fields are `None`.
2775    #[must_use]
2776    pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
2777        Self {
2778            id,
2779            jsonrpc: Default::default(),
2780            method: Default::default(),
2781            params,
2782        }
2783    }
2784}
2785/// The result returned by the server for a `ListResourceTemplatesRequestresources/templates/list` request.
2786#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2787pub struct ListResourceTemplatesResult {
2788    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
2789    pub meta: Option<ResultMetaObject>,
2790    /// Indicates the intended scope of the cached response, analogous to HTTP
2791    /// `Cache-Control: public` vs `Cache-Control: private`.
2792    ///
2793    /// - `"public"`: The response does not contain user-specific data. Any
2794    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
2795    ///  the response and serve it across authorization contexts.
2796    /// - `"private"`: The response MAY be cached and reused only within the
2797    ///  same authorization context. Caches MUST NOT be shared across
2798    ///  authorization contexts (e.g., a different access token requires a
2799    ///  different cache).
2800    #[serde(rename = "cacheScope")]
2801    pub cache_scope: CacheScope,
2802    /// An opaque token representing the pagination position after the last returned result.
2803    /// If present, there may be more results available.
2804    #[serde(
2805        rename = "nextCursor",
2806        default,
2807        skip_serializing_if = "Option::is_none"
2808    )]
2809    pub next_cursor: Option<String>,
2810    #[serde(rename = "resourceTemplates")]
2811    pub resource_templates: Vec<ResourceTemplate>,
2812    /// Indicates the type of the result, which allows the client to determine
2813    /// how to parse the result object.
2814    ///
2815    /// Servers implementing this protocol version MUST include this field.
2816    /// For backward compatibility, when a client receives a result from a
2817    /// server implementing an earlier protocol version (which does not include
2818    /// `resultType`), the client MUST treat the absent field as `"complete"`.
2819    #[serde(rename = "resultType")]
2820    pub result_type: String,
2821    /// A hint from the server indicating how long (in milliseconds) the
2822    /// client MAY cache this response before re-fetching. Semantics are
2823    /// analogous to HTTP Cache-Control max-age.
2824    ///
2825    /// - If 0, The response SHOULD be considered immediately stale,
2826    ///  The client MAY re-fetch every time the result is needed.
2827    /// - If positive, the client SHOULD consider the result fresh for this many
2828    ///  milliseconds after receiving the response.
2829    #[serde(rename = "ttlMs")]
2830    pub ttl_ms: u64,
2831}
2832impl ListResourceTemplatesResult {
2833    /// Creates a value from its required fields; optional fields are `None`.
2834    #[must_use]
2835    pub fn new(
2836        cache_scope: CacheScope,
2837        resource_templates: Vec<ResourceTemplate>,
2838        result_type: String,
2839        ttl_ms: u64,
2840    ) -> Self {
2841        Self {
2842            meta: None,
2843            cache_scope,
2844            next_cursor: None,
2845            resource_templates,
2846            result_type,
2847            ttl_ms,
2848        }
2849    }
2850}
2851/// A successful response from the server for a `ListResourceTemplatesRequestresources/templates/list` request.
2852#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2853pub struct ListResourceTemplatesResultResponse {
2854    #[serde(rename = "id")]
2855    pub id: RequestId,
2856    #[serde(rename = "jsonrpc")]
2857    pub jsonrpc: JsonRpcVersion,
2858    #[serde(rename = "result")]
2859    pub result: ListResourceTemplatesResult,
2860}
2861impl ListResourceTemplatesResultResponse {
2862    /// Creates a value from its required fields; optional fields are `None`.
2863    #[must_use]
2864    pub fn new(id: RequestId, result: ListResourceTemplatesResult) -> Self {
2865        Self {
2866            id,
2867            jsonrpc: Default::default(),
2868            result,
2869        }
2870    }
2871}
2872/// Sent from the client to request a list of resources the server has.
2873#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2874pub struct ListResourcesRequest {
2875    #[serde(rename = "id")]
2876    pub id: RequestId,
2877    #[serde(rename = "jsonrpc")]
2878    pub jsonrpc: JsonRpcVersion,
2879    #[serde(rename = "method")]
2880    pub method: ResourcesListMethod,
2881    #[serde(rename = "params")]
2882    pub params: PaginatedRequestParams,
2883}
2884impl ListResourcesRequest {
2885    /// Creates a value from its required fields; optional fields are `None`.
2886    #[must_use]
2887    pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
2888        Self {
2889            id,
2890            jsonrpc: Default::default(),
2891            method: Default::default(),
2892            params,
2893        }
2894    }
2895}
2896/// The result returned by the server for a `ListResourcesRequestresources/list` request.
2897#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2898pub struct ListResourcesResult {
2899    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
2900    pub meta: Option<ResultMetaObject>,
2901    /// Indicates the intended scope of the cached response, analogous to HTTP
2902    /// `Cache-Control: public` vs `Cache-Control: private`.
2903    ///
2904    /// - `"public"`: The response does not contain user-specific data. Any
2905    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
2906    ///  the response and serve it across authorization contexts.
2907    /// - `"private"`: The response MAY be cached and reused only within the
2908    ///  same authorization context. Caches MUST NOT be shared across
2909    ///  authorization contexts (e.g., a different access token requires a
2910    ///  different cache).
2911    #[serde(rename = "cacheScope")]
2912    pub cache_scope: CacheScope,
2913    /// An opaque token representing the pagination position after the last returned result.
2914    /// If present, there may be more results available.
2915    #[serde(
2916        rename = "nextCursor",
2917        default,
2918        skip_serializing_if = "Option::is_none"
2919    )]
2920    pub next_cursor: Option<String>,
2921    #[serde(rename = "resources")]
2922    pub resources: Vec<Resource>,
2923    /// Indicates the type of the result, which allows the client to determine
2924    /// how to parse the result object.
2925    ///
2926    /// Servers implementing this protocol version MUST include this field.
2927    /// For backward compatibility, when a client receives a result from a
2928    /// server implementing an earlier protocol version (which does not include
2929    /// `resultType`), the client MUST treat the absent field as `"complete"`.
2930    #[serde(rename = "resultType")]
2931    pub result_type: String,
2932    /// A hint from the server indicating how long (in milliseconds) the
2933    /// client MAY cache this response before re-fetching. Semantics are
2934    /// analogous to HTTP Cache-Control max-age.
2935    ///
2936    /// - If 0, The response SHOULD be considered immediately stale,
2937    ///  The client MAY re-fetch every time the result is needed.
2938    /// - If positive, the client SHOULD consider the result fresh for this many
2939    ///  milliseconds after receiving the response.
2940    #[serde(rename = "ttlMs")]
2941    pub ttl_ms: u64,
2942}
2943impl ListResourcesResult {
2944    /// Creates a value from its required fields; optional fields are `None`.
2945    #[must_use]
2946    pub fn new(
2947        cache_scope: CacheScope,
2948        resources: Vec<Resource>,
2949        result_type: String,
2950        ttl_ms: u64,
2951    ) -> Self {
2952        Self {
2953            meta: None,
2954            cache_scope,
2955            next_cursor: None,
2956            resources,
2957            result_type,
2958            ttl_ms,
2959        }
2960    }
2961}
2962/// A successful response from the server for a `ListResourcesRequestresources/list` request.
2963#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2964pub struct ListResourcesResultResponse {
2965    #[serde(rename = "id")]
2966    pub id: RequestId,
2967    #[serde(rename = "jsonrpc")]
2968    pub jsonrpc: JsonRpcVersion,
2969    #[serde(rename = "result")]
2970    pub result: ListResourcesResult,
2971}
2972impl ListResourcesResultResponse {
2973    /// Creates a value from its required fields; optional fields are `None`.
2974    #[must_use]
2975    pub fn new(id: RequestId, result: ListResourcesResult) -> Self {
2976        Self {
2977            id,
2978            jsonrpc: Default::default(),
2979            result,
2980        }
2981    }
2982}
2983/// Sent from the server to request a list of root URIs from the client. Roots allow
2984/// servers to ask for specific directories or files to operate on. A common example
2985/// for roots is providing a set of repositories or directories a server should operate
2986/// on.
2987///
2988/// This request is typically used when the server needs to understand the file system
2989/// structure or access specific locations that the client has permission to read from.
2990#[deprecated(
2991    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
2992)]
2993#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
2994pub struct ListRootsRequest {
2995    #[serde(rename = "method")]
2996    pub method: RootsListMethod,
2997    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
2998    pub params: Option<ListRootsRequestParams>,
2999}
3000#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3001pub struct ListRootsRequestParams {
3002    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3003    pub meta: Option<MetaObject>,
3004}
3005/// The result returned by the client for a `ListRootsRequestroots/list` request.
3006/// This result contains an array of `Root` objects, each representing a root directory
3007/// or file that the server can operate on.
3008#[deprecated(
3009    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3010)]
3011#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3012pub struct ListRootsResult {
3013    #[serde(rename = "roots")]
3014    pub roots: Vec<Root>,
3015}
3016impl ListRootsResult {
3017    /// Creates a value from its required fields; optional fields are `None`.
3018    #[must_use]
3019    pub fn new(roots: Vec<Root>) -> Self {
3020        Self { roots }
3021    }
3022}
3023/// Sent from the client to request a list of tools the server has.
3024#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3025pub struct ListToolsRequest {
3026    #[serde(rename = "id")]
3027    pub id: RequestId,
3028    #[serde(rename = "jsonrpc")]
3029    pub jsonrpc: JsonRpcVersion,
3030    #[serde(rename = "method")]
3031    pub method: ToolsListMethod,
3032    #[serde(rename = "params")]
3033    pub params: PaginatedRequestParams,
3034}
3035impl ListToolsRequest {
3036    /// Creates a value from its required fields; optional fields are `None`.
3037    #[must_use]
3038    pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
3039        Self {
3040            id,
3041            jsonrpc: Default::default(),
3042            method: Default::default(),
3043            params,
3044        }
3045    }
3046}
3047/// The result returned by the server for a `ListToolsRequesttools/list` request.
3048#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3049pub struct ListToolsResult {
3050    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3051    pub meta: Option<ResultMetaObject>,
3052    /// Indicates the intended scope of the cached response, analogous to HTTP
3053    /// `Cache-Control: public` vs `Cache-Control: private`.
3054    ///
3055    /// - `"public"`: The response does not contain user-specific data. Any
3056    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
3057    ///  the response and serve it across authorization contexts.
3058    /// - `"private"`: The response MAY be cached and reused only within the
3059    ///  same authorization context. Caches MUST NOT be shared across
3060    ///  authorization contexts (e.g., a different access token requires a
3061    ///  different cache).
3062    #[serde(rename = "cacheScope")]
3063    pub cache_scope: CacheScope,
3064    /// An opaque token representing the pagination position after the last returned result.
3065    /// If present, there may be more results available.
3066    #[serde(
3067        rename = "nextCursor",
3068        default,
3069        skip_serializing_if = "Option::is_none"
3070    )]
3071    pub next_cursor: Option<String>,
3072    /// Indicates the type of the result, which allows the client to determine
3073    /// how to parse the result object.
3074    ///
3075    /// Servers implementing this protocol version MUST include this field.
3076    /// For backward compatibility, when a client receives a result from a
3077    /// server implementing an earlier protocol version (which does not include
3078    /// `resultType`), the client MUST treat the absent field as `"complete"`.
3079    #[serde(rename = "resultType")]
3080    pub result_type: String,
3081    #[serde(rename = "tools")]
3082    pub tools: Vec<Tool>,
3083    /// A hint from the server indicating how long (in milliseconds) the
3084    /// client MAY cache this response before re-fetching. Semantics are
3085    /// analogous to HTTP Cache-Control max-age.
3086    ///
3087    /// - If 0, The response SHOULD be considered immediately stale,
3088    ///  The client MAY re-fetch every time the result is needed.
3089    /// - If positive, the client SHOULD consider the result fresh for this many
3090    ///  milliseconds after receiving the response.
3091    #[serde(rename = "ttlMs")]
3092    pub ttl_ms: u64,
3093}
3094impl ListToolsResult {
3095    /// Creates a value from its required fields; optional fields are `None`.
3096    #[must_use]
3097    pub fn new(
3098        cache_scope: CacheScope,
3099        result_type: String,
3100        tools: Vec<Tool>,
3101        ttl_ms: u64,
3102    ) -> Self {
3103        Self {
3104            meta: None,
3105            cache_scope,
3106            next_cursor: None,
3107            result_type,
3108            tools,
3109            ttl_ms,
3110        }
3111    }
3112}
3113/// A successful response from the server for a `ListToolsRequesttools/list` request.
3114#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3115pub struct ListToolsResultResponse {
3116    #[serde(rename = "id")]
3117    pub id: RequestId,
3118    #[serde(rename = "jsonrpc")]
3119    pub jsonrpc: JsonRpcVersion,
3120    #[serde(rename = "result")]
3121    pub result: ListToolsResult,
3122}
3123impl ListToolsResultResponse {
3124    /// Creates a value from its required fields; optional fields are `None`.
3125    #[must_use]
3126    pub fn new(id: RequestId, result: ListToolsResult) -> Self {
3127        Self {
3128            id,
3129            jsonrpc: Default::default(),
3130            result,
3131        }
3132    }
3133}
3134/// The severity of a log message.
3135///
3136/// These map to syslog message severities, as specified in RFC-5424:
3137/// https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
3138#[deprecated(
3139    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3140)]
3141#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
3142pub enum LoggingLevel {
3143    /// `"alert"`
3144    #[serde(rename = "alert")]
3145    Alert,
3146    /// `"critical"`
3147    #[serde(rename = "critical")]
3148    Critical,
3149    /// `"debug"`
3150    #[serde(rename = "debug")]
3151    Debug,
3152    /// `"emergency"`
3153    #[serde(rename = "emergency")]
3154    Emergency,
3155    /// `"error"`
3156    #[serde(rename = "error")]
3157    Error,
3158    /// `"info"`
3159    #[serde(rename = "info")]
3160    Info,
3161    /// `"notice"`
3162    #[serde(rename = "notice")]
3163    Notice,
3164    /// `"warning"`
3165    #[serde(rename = "warning")]
3166    Warning,
3167}
3168#[deprecated(
3169    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3170)]
3171impl LoggingLevel {
3172    /// The wire representation of this value.
3173    #[must_use]
3174    pub const fn as_str(self) -> &'static str {
3175        match self {
3176            Self::Alert => "alert",
3177            Self::Critical => "critical",
3178            Self::Debug => "debug",
3179            Self::Emergency => "emergency",
3180            Self::Error => "error",
3181            Self::Info => "info",
3182            Self::Notice => "notice",
3183            Self::Warning => "warning",
3184        }
3185    }
3186}
3187/// JSONRPCNotification of a log message passed from server to client. The client opts in by setting `"io.modelcontextprotocol/logLevel"` in a request's `_meta`.
3188#[deprecated(
3189    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3190)]
3191#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3192pub struct LoggingMessageNotification {
3193    #[serde(rename = "jsonrpc")]
3194    pub jsonrpc: JsonRpcVersion,
3195    #[serde(rename = "method")]
3196    pub method: NotificationsMessageMethod,
3197    #[serde(rename = "params")]
3198    pub params: LoggingMessageNotificationParams,
3199}
3200impl LoggingMessageNotification {
3201    /// Creates a value from its required fields; optional fields are `None`.
3202    #[must_use]
3203    pub fn new(params: LoggingMessageNotificationParams) -> Self {
3204        Self {
3205            jsonrpc: Default::default(),
3206            method: Default::default(),
3207            params,
3208        }
3209    }
3210}
3211/// Parameters for a `notifications/message` notification.
3212#[deprecated(
3213    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3214)]
3215#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3216pub struct LoggingMessageNotificationParams {
3217    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3218    pub meta: Option<NotificationMetaObject>,
3219    /// The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
3220    #[serde(rename = "data")]
3221    pub data: serde_json::Value,
3222    /// The severity of this log message.
3223    #[serde(rename = "level")]
3224    pub level: LoggingLevel,
3225    /// An optional name of the logger issuing this message.
3226    #[serde(rename = "logger", default, skip_serializing_if = "Option::is_none")]
3227    pub logger: Option<String>,
3228}
3229impl LoggingMessageNotificationParams {
3230    /// Creates a value from its required fields; optional fields are `None`.
3231    #[must_use]
3232    pub fn new(data: serde_json::Value, level: LoggingLevel) -> Self {
3233        Self {
3234            meta: None,
3235            data,
3236            level,
3237            logger: None,
3238        }
3239    }
3240}
3241/// Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions.
3242///
3243/// Certain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions.
3244///
3245/// Valid keys have two segments:
3246///
3247/// **Prefix:**
3248/// - Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`).
3249/// - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`).
3250/// - Implementations SHOULD use reverse DNS notation (e.g., `com.example/` rather than `example.com/`).
3251/// - Any prefix where the second label is `modelcontextprotocol` or `mcp` is **reserved** for MCP use. For example: `io.modelcontextprotocol/`, `dev.mcp/`, `org.modelcontextprotocol.api/`, and `com.mcp.tools/` are all reserved. However, `com.example.mcp/` is NOT reserved, as the second label is `example`.
3252///
3253/// **Name:**
3254/// - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`).
3255/// - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`).
3256pub type MetaObject = serde_json::Map<String, serde_json::Value>;
3257/// A JSON-RPC error indicating that the requested method does not exist or is not available.
3258///
3259/// In MCP, a server returns this error when a client invokes a method the server does not implement — either a genuinely unknown method, or one gated behind a server capability the server did not advertise (e.g., calling `prompts/list` when the `prompts` capability was not advertised).
3260///
3261/// A request that requires a client capability the client did not declare is signalled instead by `MissingRequiredClientCapabilityError` (`-32021`).
3262#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3263pub struct MethodNotFoundError {
3264    /// The error type that occurred.
3265    #[serde(rename = "code")]
3266    pub code: i64,
3267    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
3268    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
3269    pub data: Option<serde_json::Value>,
3270    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
3271    #[serde(rename = "message")]
3272    pub message: String,
3273}
3274impl MethodNotFoundError {
3275    /// Creates a value from its required fields; optional fields are `None`.
3276    #[must_use]
3277    pub fn new(code: i64, message: String) -> Self {
3278        Self {
3279            code,
3280            data: None,
3281            message,
3282        }
3283    }
3284}
3285/// Returned when processing a request requires a capability the client did not
3286/// declare in `clientCapabilities`. For HTTP, the response status code MUST be
3287/// `400 Bad Request`.
3288#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3289pub struct MissingRequiredClientCapabilityError {
3290    #[serde(rename = "error")]
3291    pub error: MissingRequiredClientCapabilityErrorObject,
3292    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
3293    pub id: Option<RequestId>,
3294    #[serde(rename = "jsonrpc")]
3295    pub jsonrpc: JsonRpcVersion,
3296}
3297impl MissingRequiredClientCapabilityError {
3298    /// Creates a value from its required fields; optional fields are `None`.
3299    #[must_use]
3300    pub fn new(error: MissingRequiredClientCapabilityErrorObject) -> Self {
3301        Self {
3302            error,
3303            id: None,
3304            jsonrpc: Default::default(),
3305        }
3306    }
3307}
3308#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3309pub struct MissingRequiredClientCapabilityErrorData {
3310    /// The capabilities the server requires from the client to process this request.
3311    #[serde(rename = "requiredCapabilities")]
3312    pub required_capabilities: ClientCapabilities,
3313}
3314impl MissingRequiredClientCapabilityErrorData {
3315    /// Creates a value from its required fields; optional fields are `None`.
3316    #[must_use]
3317    pub fn new(required_capabilities: ClientCapabilities) -> Self {
3318        Self {
3319            required_capabilities,
3320        }
3321    }
3322}
3323#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3324pub struct MissingRequiredClientCapabilityErrorObject {
3325    #[serde(rename = "code")]
3326    pub code: i64,
3327    #[serde(rename = "data")]
3328    pub data: MissingRequiredClientCapabilityErrorData,
3329    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
3330    #[serde(rename = "message")]
3331    pub message: String,
3332}
3333impl MissingRequiredClientCapabilityErrorObject {
3334    /// Creates a value from its required fields; optional fields are `None`.
3335    #[must_use]
3336    pub fn new(code: i64, data: MissingRequiredClientCapabilityErrorData, message: String) -> Self {
3337        Self {
3338            code,
3339            data,
3340            message,
3341        }
3342    }
3343}
3344/// Hints to use for model selection.
3345///
3346/// Keys not declared here are currently left unspecified by the spec and are up
3347/// to the client to interpret.
3348#[deprecated(
3349    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3350)]
3351#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3352pub struct ModelHint {
3353    /// A hint for a model name.
3354    ///
3355    /// The client SHOULD treat this as a substring of a model name; for example:
3356    /// - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`
3357    /// - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.
3358    /// - `claude` should match any Claude model
3359    ///
3360    /// 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:
3361    /// - `gemini-1.5-flash` could match `claude-3-haiku-20240307`
3362    #[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
3363    pub name: Option<String>,
3364}
3365/// The server's preferences for model selection, requested of the client during sampling.
3366///
3367/// Because LLMs can vary along multiple dimensions, choosing the "best" model is
3368/// rarely straightforward.  Different models excel in different areas—some are
3369/// faster but less capable, others are more capable but more expensive, and so
3370/// on. This interface allows servers to express their priorities across multiple
3371/// dimensions to help clients make an appropriate selection for their use case.
3372///
3373/// These preferences are always advisory. The client MAY ignore them. It is also
3374/// up to the client to decide how to interpret these preferences and how to
3375/// balance them against other considerations.
3376#[deprecated(
3377    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
3378)]
3379#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3380pub struct ModelPreferences {
3381    /// How much to prioritize cost when selecting a model. A value of 0 means cost
3382    /// is not important, while a value of 1 means cost is the most important
3383    /// factor.
3384    #[serde(
3385        rename = "costPriority",
3386        default,
3387        skip_serializing_if = "Option::is_none"
3388    )]
3389    pub cost_priority: Option<f64>,
3390    /// Optional hints to use for model selection.
3391    ///
3392    /// If multiple hints are specified, the client MUST evaluate them in order
3393    /// (such that the first match is taken).
3394    ///
3395    /// The client SHOULD prioritize these hints over the numeric priorities, but
3396    /// MAY still use the priorities to select from ambiguous matches.
3397    #[serde(rename = "hints", default, skip_serializing_if = "Option::is_none")]
3398    pub hints: Option<Vec<ModelHint>>,
3399    /// How much to prioritize intelligence and capabilities when selecting a
3400    /// model. A value of 0 means intelligence is not important, while a value of 1
3401    /// means intelligence is the most important factor.
3402    #[serde(
3403        rename = "intelligencePriority",
3404        default,
3405        skip_serializing_if = "Option::is_none"
3406    )]
3407    pub intelligence_priority: Option<f64>,
3408    /// How much to prioritize sampling speed (latency) when selecting a model. A
3409    /// value of 0 means speed is not important, while a value of 1 means speed is
3410    /// the most important factor.
3411    #[serde(
3412        rename = "speedPriority",
3413        default,
3414        skip_serializing_if = "Option::is_none"
3415    )]
3416    pub speed_priority: Option<f64>,
3417}
3418#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3419#[serde(untagged)]
3420pub enum MultiSelectEnumSchema {
3421    /// The [`UntitledMultiSelectEnumSchema`] variant.
3422    Untitled(UntitledMultiSelectEnumSchema),
3423    /// The [`TitledMultiSelectEnumSchema`] variant.
3424    Titled(TitledMultiSelectEnumSchema),
3425}
3426impl From<UntitledMultiSelectEnumSchema> for MultiSelectEnumSchema {
3427    fn from(v: UntitledMultiSelectEnumSchema) -> Self {
3428        Self::Untitled(v)
3429    }
3430}
3431impl From<TitledMultiSelectEnumSchema> for MultiSelectEnumSchema {
3432    fn from(v: TitledMultiSelectEnumSchema) -> Self {
3433        Self::Titled(v)
3434    }
3435}
3436#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3437pub struct Notification {
3438    #[serde(rename = "method")]
3439    pub method: String,
3440    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
3441    pub params: Option<serde_json::Map<String, serde_json::Value>>,
3442}
3443impl Notification {
3444    /// Creates a value from its required fields; optional fields are `None`.
3445    #[must_use]
3446    pub fn new(method: String) -> Self {
3447        Self {
3448            method,
3449            params: None,
3450        }
3451    }
3452}
3453/// Extends `MetaObject` with additional notification-specific fields. All key naming rules from `MetaObject` apply.
3454#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3455pub struct NotificationMetaObject {
3456    /// Identifies the subscription stream a notification was delivered on. The
3457    /// server MUST include this key on every notification delivered via a
3458    /// `SubscriptionsListenRequestsubscriptions/listen` stream, so the
3459    /// client can correlate the notification with the originating subscription.
3460    /// The key is absent on notifications not delivered via a subscription
3461    /// stream (e.g. progress notifications for an in-flight request), which is
3462    /// why it is optional here.
3463    ///
3464    /// The value is the JSON-RPC ID of the `subscriptions/listen` request that
3465    /// opened the stream.
3466    #[serde(
3467        rename = "io.modelcontextprotocol/subscriptionId",
3468        default,
3469        skip_serializing_if = "Option::is_none"
3470    )]
3471    pub subscription_id: Option<RequestId>,
3472    /// Additional properties not described by the schema.
3473    #[serde(flatten)]
3474    pub extra: serde_json::Map<String, serde_json::Value>,
3475}
3476/// Common params for any notification.
3477#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3478pub struct NotificationParams {
3479    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3480    pub meta: Option<NotificationMetaObject>,
3481}
3482/// The constant `"notifications/cancelled"`.
3483#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3484pub enum NotificationsCancelledMethod {
3485    /// The constant `"notifications/cancelled"`.
3486    #[default]
3487    #[serde(rename = "notifications/cancelled")]
3488    NotificationsCancelled,
3489}
3490impl NotificationsCancelledMethod {
3491    /// The wire representation of this constant.
3492    pub const VALUE: &'static str = "notifications/cancelled";
3493}
3494/// The constant `"notifications/message"`.
3495#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3496pub enum NotificationsMessageMethod {
3497    /// The constant `"notifications/message"`.
3498    #[default]
3499    #[serde(rename = "notifications/message")]
3500    NotificationsMessage,
3501}
3502impl NotificationsMessageMethod {
3503    /// The wire representation of this constant.
3504    pub const VALUE: &'static str = "notifications/message";
3505}
3506/// The constant `"notifications/progress"`.
3507#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3508pub enum NotificationsProgressMethod {
3509    /// The constant `"notifications/progress"`.
3510    #[default]
3511    #[serde(rename = "notifications/progress")]
3512    NotificationsProgress,
3513}
3514impl NotificationsProgressMethod {
3515    /// The wire representation of this constant.
3516    pub const VALUE: &'static str = "notifications/progress";
3517}
3518/// The constant `"notifications/prompts/list_changed"`.
3519#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3520pub enum NotificationsPromptsListChangedMethod {
3521    /// The constant `"notifications/prompts/list_changed"`.
3522    #[default]
3523    #[serde(rename = "notifications/prompts/list_changed")]
3524    NotificationsPromptsListChanged,
3525}
3526impl NotificationsPromptsListChangedMethod {
3527    /// The wire representation of this constant.
3528    pub const VALUE: &'static str = "notifications/prompts/list_changed";
3529}
3530/// The constant `"notifications/resources/list_changed"`.
3531#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3532pub enum NotificationsResourcesListChangedMethod {
3533    /// The constant `"notifications/resources/list_changed"`.
3534    #[default]
3535    #[serde(rename = "notifications/resources/list_changed")]
3536    NotificationsResourcesListChanged,
3537}
3538impl NotificationsResourcesListChangedMethod {
3539    /// The wire representation of this constant.
3540    pub const VALUE: &'static str = "notifications/resources/list_changed";
3541}
3542/// The constant `"notifications/resources/updated"`.
3543#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3544pub enum NotificationsResourcesUpdatedMethod {
3545    /// The constant `"notifications/resources/updated"`.
3546    #[default]
3547    #[serde(rename = "notifications/resources/updated")]
3548    NotificationsResourcesUpdated,
3549}
3550impl NotificationsResourcesUpdatedMethod {
3551    /// The wire representation of this constant.
3552    pub const VALUE: &'static str = "notifications/resources/updated";
3553}
3554/// The constant `"notifications/subscriptions/acknowledged"`.
3555#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3556pub enum NotificationsSubscriptionsAcknowledgedMethod {
3557    /// The constant `"notifications/subscriptions/acknowledged"`.
3558    #[default]
3559    #[serde(rename = "notifications/subscriptions/acknowledged")]
3560    NotificationsSubscriptionsAcknowledged,
3561}
3562impl NotificationsSubscriptionsAcknowledgedMethod {
3563    /// The wire representation of this constant.
3564    pub const VALUE: &'static str = "notifications/subscriptions/acknowledged";
3565}
3566/// The constant `"notifications/tools/list_changed"`.
3567#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3568pub enum NotificationsToolsListChangedMethod {
3569    /// The constant `"notifications/tools/list_changed"`.
3570    #[default]
3571    #[serde(rename = "notifications/tools/list_changed")]
3572    NotificationsToolsListChanged,
3573}
3574impl NotificationsToolsListChangedMethod {
3575    /// The wire representation of this constant.
3576    pub const VALUE: &'static str = "notifications/tools/list_changed";
3577}
3578#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3579pub struct NumberSchema {
3580    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
3581    pub default: Option<f64>,
3582    #[serde(
3583        rename = "description",
3584        default,
3585        skip_serializing_if = "Option::is_none"
3586    )]
3587    pub description: Option<String>,
3588    #[serde(rename = "maximum", default, skip_serializing_if = "Option::is_none")]
3589    pub maximum: Option<f64>,
3590    #[serde(rename = "minimum", default, skip_serializing_if = "Option::is_none")]
3591    pub minimum: Option<f64>,
3592    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
3593    pub title: Option<String>,
3594    #[serde(rename = "type")]
3595    pub r#type: NumberSchemaType,
3596}
3597impl NumberSchema {
3598    /// Creates a value from its required fields; optional fields are `None`.
3599    #[must_use]
3600    pub fn new(r#type: NumberSchemaType) -> Self {
3601        Self {
3602            default: None,
3603            description: None,
3604            maximum: None,
3605            minimum: None,
3606            title: None,
3607            r#type,
3608        }
3609    }
3610}
3611#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
3612pub enum NumberSchemaType {
3613    /// `"integer"`
3614    #[serde(rename = "integer")]
3615    Integer,
3616    /// `"number"`
3617    #[serde(rename = "number")]
3618    Number,
3619}
3620impl NumberSchemaType {
3621    /// The wire representation of this value.
3622    #[must_use]
3623    pub const fn as_str(self) -> &'static str {
3624        match self {
3625            Self::Integer => "integer",
3626            Self::Number => "number",
3627        }
3628    }
3629}
3630/// The constant `"object"`.
3631#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3632pub enum ObjectType {
3633    /// The constant `"object"`.
3634    #[default]
3635    #[serde(rename = "object")]
3636    Object,
3637}
3638impl ObjectType {
3639    /// The wire representation of this constant.
3640    pub const VALUE: &'static str = "object";
3641}
3642#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3643pub struct PaginatedRequest {
3644    #[serde(rename = "id")]
3645    pub id: RequestId,
3646    #[serde(rename = "jsonrpc")]
3647    pub jsonrpc: JsonRpcVersion,
3648    #[serde(rename = "method")]
3649    pub method: String,
3650    #[serde(rename = "params")]
3651    pub params: PaginatedRequestParams,
3652}
3653impl PaginatedRequest {
3654    /// Creates a value from its required fields; optional fields are `None`.
3655    #[must_use]
3656    pub fn new(id: RequestId, method: String, params: PaginatedRequestParams) -> Self {
3657        Self {
3658            id,
3659            jsonrpc: Default::default(),
3660            method,
3661            params,
3662        }
3663    }
3664}
3665/// Common params for paginated requests.
3666#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3667pub struct PaginatedRequestParams {
3668    #[serde(rename = "_meta")]
3669    pub meta: RequestMetaObject,
3670    /// An opaque token representing the current pagination position.
3671    /// If provided, the server should return results starting after this cursor.
3672    #[serde(rename = "cursor", default, skip_serializing_if = "Option::is_none")]
3673    pub cursor: Option<String>,
3674}
3675impl PaginatedRequestParams {
3676    /// Creates a value from its required fields; optional fields are `None`.
3677    #[must_use]
3678    pub fn new(meta: RequestMetaObject) -> Self {
3679        Self { meta, cursor: None }
3680    }
3681}
3682#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3683pub struct PaginatedResult {
3684    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3685    pub meta: Option<ResultMetaObject>,
3686    /// An opaque token representing the pagination position after the last returned result.
3687    /// If present, there may be more results available.
3688    #[serde(
3689        rename = "nextCursor",
3690        default,
3691        skip_serializing_if = "Option::is_none"
3692    )]
3693    pub next_cursor: Option<String>,
3694    /// Indicates the type of the result, which allows the client to determine
3695    /// how to parse the result object.
3696    ///
3697    /// Servers implementing this protocol version MUST include this field.
3698    /// For backward compatibility, when a client receives a result from a
3699    /// server implementing an earlier protocol version (which does not include
3700    /// `resultType`), the client MUST treat the absent field as `"complete"`.
3701    #[serde(rename = "resultType")]
3702    pub result_type: String,
3703}
3704impl PaginatedResult {
3705    /// Creates a value from its required fields; optional fields are `None`.
3706    #[must_use]
3707    pub fn new(result_type: String) -> Self {
3708        Self {
3709            meta: None,
3710            next_cursor: None,
3711            result_type,
3712        }
3713    }
3714}
3715/// A JSON-RPC error indicating that invalid JSON was received by the server. This error is returned when the server cannot parse the JSON text of a message.
3716#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3717pub struct ParseError {
3718    /// The error type that occurred.
3719    #[serde(rename = "code")]
3720    pub code: i64,
3721    /// Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
3722    #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
3723    pub data: Option<serde_json::Value>,
3724    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
3725    #[serde(rename = "message")]
3726    pub message: String,
3727}
3728impl ParseError {
3729    /// Creates a value from its required fields; optional fields are `None`.
3730    #[must_use]
3731    pub fn new(code: i64, message: String) -> Self {
3732        Self {
3733            code,
3734            data: None,
3735            message,
3736        }
3737    }
3738}
3739/// Restricted schema definitions that only allow primitive types
3740/// without nested objects or arrays.
3741#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3742#[serde(untagged)]
3743pub enum PrimitiveSchemaDefinition {
3744    /// The [`StringSchema`] variant.
3745    String(StringSchema),
3746    /// The [`NumberSchema`] variant.
3747    Number(NumberSchema),
3748    /// The [`BooleanSchema`] variant.
3749    Boolean(BooleanSchema),
3750    /// The [`UntitledSingleSelectEnumSchema`] variant.
3751    UntitledSingleSelectEnum(UntitledSingleSelectEnumSchema),
3752    /// The [`TitledSingleSelectEnumSchema`] variant.
3753    TitledSingleSelectEnum(TitledSingleSelectEnumSchema),
3754    /// The [`UntitledMultiSelectEnumSchema`] variant.
3755    UntitledMultiSelectEnum(UntitledMultiSelectEnumSchema),
3756    /// The [`TitledMultiSelectEnumSchema`] variant.
3757    TitledMultiSelectEnum(TitledMultiSelectEnumSchema),
3758    /// The [`LegacyTitledEnumSchema`] variant.
3759    LegacyTitledEnum(LegacyTitledEnumSchema),
3760}
3761impl From<StringSchema> for PrimitiveSchemaDefinition {
3762    fn from(v: StringSchema) -> Self {
3763        Self::String(v)
3764    }
3765}
3766impl From<NumberSchema> for PrimitiveSchemaDefinition {
3767    fn from(v: NumberSchema) -> Self {
3768        Self::Number(v)
3769    }
3770}
3771impl From<BooleanSchema> for PrimitiveSchemaDefinition {
3772    fn from(v: BooleanSchema) -> Self {
3773        Self::Boolean(v)
3774    }
3775}
3776impl From<UntitledSingleSelectEnumSchema> for PrimitiveSchemaDefinition {
3777    fn from(v: UntitledSingleSelectEnumSchema) -> Self {
3778        Self::UntitledSingleSelectEnum(v)
3779    }
3780}
3781impl From<TitledSingleSelectEnumSchema> for PrimitiveSchemaDefinition {
3782    fn from(v: TitledSingleSelectEnumSchema) -> Self {
3783        Self::TitledSingleSelectEnum(v)
3784    }
3785}
3786impl From<UntitledMultiSelectEnumSchema> for PrimitiveSchemaDefinition {
3787    fn from(v: UntitledMultiSelectEnumSchema) -> Self {
3788        Self::UntitledMultiSelectEnum(v)
3789    }
3790}
3791impl From<TitledMultiSelectEnumSchema> for PrimitiveSchemaDefinition {
3792    fn from(v: TitledMultiSelectEnumSchema) -> Self {
3793        Self::TitledMultiSelectEnum(v)
3794    }
3795}
3796impl From<LegacyTitledEnumSchema> for PrimitiveSchemaDefinition {
3797    fn from(v: LegacyTitledEnumSchema) -> Self {
3798        Self::LegacyTitledEnum(v)
3799    }
3800}
3801/// An out-of-band notification used to inform the receiver of a progress update for a long-running request.
3802#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3803pub struct ProgressNotification {
3804    #[serde(rename = "jsonrpc")]
3805    pub jsonrpc: JsonRpcVersion,
3806    #[serde(rename = "method")]
3807    pub method: NotificationsProgressMethod,
3808    #[serde(rename = "params")]
3809    pub params: ProgressNotificationParams,
3810}
3811impl ProgressNotification {
3812    /// Creates a value from its required fields; optional fields are `None`.
3813    #[must_use]
3814    pub fn new(params: ProgressNotificationParams) -> Self {
3815        Self {
3816            jsonrpc: Default::default(),
3817            method: Default::default(),
3818            params,
3819        }
3820    }
3821}
3822/// Parameters for a `ProgressNotificationnotifications/progress` notification.
3823#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3824pub struct ProgressNotificationParams {
3825    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3826    pub meta: Option<NotificationMetaObject>,
3827    /// An optional message describing the current progress.
3828    #[serde(rename = "message", default, skip_serializing_if = "Option::is_none")]
3829    pub message: Option<String>,
3830    /// The progress thus far. This should increase every time progress is made, even if the total is unknown.
3831    #[serde(rename = "progress")]
3832    pub progress: f64,
3833    /// The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
3834    #[serde(rename = "progressToken")]
3835    pub progress_token: ProgressToken,
3836    /// Total number of items to process (or total progress required), if known.
3837    #[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
3838    pub total: Option<f64>,
3839}
3840impl ProgressNotificationParams {
3841    /// Creates a value from its required fields; optional fields are `None`.
3842    #[must_use]
3843    pub fn new(progress: f64, progress_token: ProgressToken) -> Self {
3844        Self {
3845            meta: None,
3846            message: None,
3847            progress,
3848            progress_token,
3849            total: None,
3850        }
3851    }
3852}
3853/// A progress token, used to associate progress notifications with the original request.
3854#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
3855#[serde(untagged)]
3856pub enum ProgressToken {
3857    /// A string value.
3858    String(String),
3859    /// An integer value.
3860    Integer(i64),
3861}
3862impl From<String> for ProgressToken {
3863    fn from(v: String) -> Self {
3864        Self::String(v)
3865    }
3866}
3867impl From<&str> for ProgressToken {
3868    fn from(v: &str) -> Self {
3869        Self::String(v.to_owned())
3870    }
3871}
3872impl From<i64> for ProgressToken {
3873    fn from(v: i64) -> Self {
3874        Self::Integer(v)
3875    }
3876}
3877impl<'de> Deserialize<'de> for ProgressToken {
3878    fn deserialize<D: serde::Deserializer<'de>>(
3879        deserializer: D,
3880    ) -> ::core::result::Result<Self, D::Error> {
3881        struct Visitor;
3882        impl serde::de::Visitor<'_> for Visitor {
3883            type Value = ProgressToken;
3884            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3885                f.write_str("a string or an integer")
3886            }
3887            fn visit_str<E: serde::de::Error>(
3888                self,
3889                v: &str,
3890            ) -> ::core::result::Result<Self::Value, E> {
3891                Ok(ProgressToken::String(v.to_owned()))
3892            }
3893            fn visit_string<E: serde::de::Error>(
3894                self,
3895                v: String,
3896            ) -> ::core::result::Result<Self::Value, E> {
3897                Ok(ProgressToken::String(v))
3898            }
3899            fn visit_i64<E: serde::de::Error>(
3900                self,
3901                v: i64,
3902            ) -> ::core::result::Result<Self::Value, E> {
3903                Ok(ProgressToken::Integer(v))
3904            }
3905            fn visit_u64<E: serde::de::Error>(
3906                self,
3907                v: u64,
3908            ) -> ::core::result::Result<Self::Value, E> {
3909                i64::try_from(v)
3910                    .map(ProgressToken::Integer)
3911                    .map_err(|_| E::invalid_value(serde::de::Unexpected::Unsigned(v), &self))
3912            }
3913            #[allow(clippy::cast_possible_truncation, clippy::float_cmp)]
3914            fn visit_f64<E: serde::de::Error>(
3915                self,
3916                v: f64,
3917            ) -> ::core::result::Result<Self::Value, E> {
3918                const MAX_SAFE: f64 = 9_007_199_254_740_991.0;
3919                if v.fract() == 0.0 && (-MAX_SAFE..=MAX_SAFE).contains(&v) {
3920                    Ok(ProgressToken::Integer(v as i64))
3921                } else {
3922                    Err(E::invalid_type(serde::de::Unexpected::Float(v), &self))
3923                }
3924            }
3925        }
3926        deserializer.deserialize_any(Visitor)
3927    }
3928}
3929/// A prompt or prompt template that the server offers.
3930#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3931pub struct Prompt {
3932    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
3933    pub meta: Option<MetaObject>,
3934    /// A list of arguments to use for templating the prompt.
3935    #[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
3936    pub arguments: Option<Vec<PromptArgument>>,
3937    /// An optional description of what this prompt provides
3938    #[serde(
3939        rename = "description",
3940        default,
3941        skip_serializing_if = "Option::is_none"
3942    )]
3943    pub description: Option<String>,
3944    /// Optional set of sized icons that the client can display in a user interface.
3945    ///
3946    /// Clients that support rendering icons MUST support at least the following MIME types:
3947    /// - `image/png` - PNG images (safe, universal compatibility)
3948    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
3949    ///
3950    /// Clients that support rendering icons SHOULD also support:
3951    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
3952    /// - `image/webp` - WebP images (modern, efficient format)
3953    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
3954    pub icons: Option<Vec<Icon>>,
3955    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
3956    #[serde(rename = "name")]
3957    pub name: String,
3958    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
3959    /// even by those unfamiliar with domain-specific terminology.
3960    ///
3961    /// If not provided, the name should be used for display (except for `Tool`,
3962    /// where `annotations.title` should be given precedence over using `name`,
3963    /// if present).
3964    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
3965    pub title: Option<String>,
3966}
3967impl Prompt {
3968    /// Creates a value from its required fields; optional fields are `None`.
3969    #[must_use]
3970    pub fn new(name: String) -> Self {
3971        Self {
3972            meta: None,
3973            arguments: None,
3974            description: None,
3975            icons: None,
3976            name,
3977            title: None,
3978        }
3979    }
3980}
3981/// Describes an argument that a prompt can accept.
3982#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3983pub struct PromptArgument {
3984    /// A human-readable description of the argument.
3985    #[serde(
3986        rename = "description",
3987        default,
3988        skip_serializing_if = "Option::is_none"
3989    )]
3990    pub description: Option<String>,
3991    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
3992    #[serde(rename = "name")]
3993    pub name: String,
3994    /// Whether this argument must be provided.
3995    #[serde(rename = "required", default, skip_serializing_if = "Option::is_none")]
3996    pub required: Option<bool>,
3997    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
3998    /// even by those unfamiliar with domain-specific terminology.
3999    ///
4000    /// If not provided, the name should be used for display (except for `Tool`,
4001    /// where `annotations.title` should be given precedence over using `name`,
4002    /// if present).
4003    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4004    pub title: Option<String>,
4005}
4006impl PromptArgument {
4007    /// Creates a value from its required fields; optional fields are `None`.
4008    #[must_use]
4009    pub fn new(name: String) -> Self {
4010        Self {
4011            description: None,
4012            name,
4013            required: None,
4014            title: None,
4015        }
4016    }
4017}
4018/// An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This is only delivered on a `SubscriptionsListenRequestsubscriptions/listen` stream when the client requested it via the `promptsListChanged` filter field.
4019#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
4020pub struct PromptListChangedNotification {
4021    #[serde(rename = "jsonrpc")]
4022    pub jsonrpc: JsonRpcVersion,
4023    #[serde(rename = "method")]
4024    pub method: NotificationsPromptsListChangedMethod,
4025    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
4026    pub params: Option<NotificationParams>,
4027}
4028/// Describes a message returned as part of a prompt.
4029///
4030/// This is similar to `SamplingMessage`, but also supports the embedding of
4031/// resources from the MCP server.
4032#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4033pub struct PromptMessage {
4034    #[serde(rename = "content")]
4035    pub content: ContentBlock,
4036    #[serde(rename = "role")]
4037    pub role: Role,
4038}
4039impl PromptMessage {
4040    /// Creates a value from its required fields; optional fields are `None`.
4041    #[must_use]
4042    pub fn new(content: ContentBlock, role: Role) -> Self {
4043        Self { content, role }
4044    }
4045}
4046/// Identifies a prompt.
4047#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4048pub struct PromptReference {
4049    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
4050    #[serde(rename = "name")]
4051    pub name: String,
4052    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
4053    /// even by those unfamiliar with domain-specific terminology.
4054    ///
4055    /// If not provided, the name should be used for display (except for `Tool`,
4056    /// where `annotations.title` should be given precedence over using `name`,
4057    /// if present).
4058    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4059    pub title: Option<String>,
4060    #[serde(rename = "type")]
4061    pub r#type: RefPromptType,
4062}
4063impl PromptReference {
4064    /// Creates a value from its required fields; optional fields are `None`.
4065    #[must_use]
4066    pub fn new(name: String) -> Self {
4067        Self {
4068            name,
4069            title: None,
4070            r#type: Default::default(),
4071        }
4072    }
4073}
4074/// The constant `"prompts/get"`.
4075#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4076pub enum PromptsGetMethod {
4077    /// The constant `"prompts/get"`.
4078    #[default]
4079    #[serde(rename = "prompts/get")]
4080    PromptsGet,
4081}
4082impl PromptsGetMethod {
4083    /// The wire representation of this constant.
4084    pub const VALUE: &'static str = "prompts/get";
4085}
4086/// The constant `"prompts/list"`.
4087#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4088pub enum PromptsListMethod {
4089    /// The constant `"prompts/list"`.
4090    #[default]
4091    #[serde(rename = "prompts/list")]
4092    PromptsList,
4093}
4094impl PromptsListMethod {
4095    /// The wire representation of this constant.
4096    pub const VALUE: &'static str = "prompts/list";
4097}
4098/// Sent from the client to the server, to read a specific resource URI.
4099#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4100pub struct ReadResourceRequest {
4101    #[serde(rename = "id")]
4102    pub id: RequestId,
4103    #[serde(rename = "jsonrpc")]
4104    pub jsonrpc: JsonRpcVersion,
4105    #[serde(rename = "method")]
4106    pub method: ResourcesReadMethod,
4107    #[serde(rename = "params")]
4108    pub params: ReadResourceRequestParams,
4109}
4110impl ReadResourceRequest {
4111    /// Creates a value from its required fields; optional fields are `None`.
4112    #[must_use]
4113    pub fn new(id: RequestId, params: ReadResourceRequestParams) -> Self {
4114        Self {
4115            id,
4116            jsonrpc: Default::default(),
4117            method: Default::default(),
4118            params,
4119        }
4120    }
4121}
4122/// Parameters for a `resources/read` request.
4123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4124pub struct ReadResourceRequestParams {
4125    #[serde(rename = "_meta")]
4126    pub meta: RequestMetaObject,
4127    #[serde(
4128        rename = "inputResponses",
4129        default,
4130        skip_serializing_if = "Option::is_none"
4131    )]
4132    pub input_responses: Option<InputResponses>,
4133    #[serde(
4134        rename = "requestState",
4135        default,
4136        skip_serializing_if = "Option::is_none"
4137    )]
4138    pub request_state: Option<String>,
4139    /// The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
4140    #[serde(rename = "uri")]
4141    pub uri: String,
4142}
4143impl ReadResourceRequestParams {
4144    /// Creates a value from its required fields; optional fields are `None`.
4145    #[must_use]
4146    pub fn new(meta: RequestMetaObject, uri: String) -> Self {
4147        Self {
4148            meta,
4149            input_responses: None,
4150            request_state: None,
4151            uri,
4152        }
4153    }
4154}
4155/// The result returned by the server for a `ReadResourceRequestresources/read` request.
4156#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4157pub struct ReadResourceResult {
4158    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4159    pub meta: Option<ResultMetaObject>,
4160    /// Indicates the intended scope of the cached response, analogous to HTTP
4161    /// `Cache-Control: public` vs `Cache-Control: private`.
4162    ///
4163    /// - `"public"`: The response does not contain user-specific data. Any
4164    ///  client or intermediary (e.g., shared gateway, caching proxy) MAY cache
4165    ///  the response and serve it across authorization contexts.
4166    /// - `"private"`: The response MAY be cached and reused only within the
4167    ///  same authorization context. Caches MUST NOT be shared across
4168    ///  authorization contexts (e.g., a different access token requires a
4169    ///  different cache).
4170    #[serde(rename = "cacheScope")]
4171    pub cache_scope: CacheScope,
4172    #[serde(rename = "contents")]
4173    pub contents: Vec<ReadResourceResultContentsItem>,
4174    /// Indicates the type of the result, which allows the client to determine
4175    /// how to parse the result object.
4176    ///
4177    /// Servers implementing this protocol version MUST include this field.
4178    /// For backward compatibility, when a client receives a result from a
4179    /// server implementing an earlier protocol version (which does not include
4180    /// `resultType`), the client MUST treat the absent field as `"complete"`.
4181    #[serde(rename = "resultType")]
4182    pub result_type: String,
4183    /// A hint from the server indicating how long (in milliseconds) the
4184    /// client MAY cache this response before re-fetching. Semantics are
4185    /// analogous to HTTP Cache-Control max-age.
4186    ///
4187    /// - If 0, The response SHOULD be considered immediately stale,
4188    ///  The client MAY re-fetch every time the result is needed.
4189    /// - If positive, the client SHOULD consider the result fresh for this many
4190    ///  milliseconds after receiving the response.
4191    #[serde(rename = "ttlMs")]
4192    pub ttl_ms: u64,
4193}
4194impl ReadResourceResult {
4195    /// Creates a value from its required fields; optional fields are `None`.
4196    #[must_use]
4197    pub fn new(
4198        cache_scope: CacheScope,
4199        contents: Vec<ReadResourceResultContentsItem>,
4200        result_type: String,
4201        ttl_ms: u64,
4202    ) -> Self {
4203        Self {
4204            meta: None,
4205            cache_scope,
4206            contents,
4207            result_type,
4208            ttl_ms,
4209        }
4210    }
4211}
4212#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4213#[serde(untagged)]
4214pub enum ReadResourceResultContentsItem {
4215    /// The [`TextResourceContents`] variant.
4216    Text(TextResourceContents),
4217    /// The [`BlobResourceContents`] variant.
4218    Blob(BlobResourceContents),
4219}
4220impl From<TextResourceContents> for ReadResourceResultContentsItem {
4221    fn from(v: TextResourceContents) -> Self {
4222        Self::Text(v)
4223    }
4224}
4225impl From<BlobResourceContents> for ReadResourceResultContentsItem {
4226    fn from(v: BlobResourceContents) -> Self {
4227        Self::Blob(v)
4228    }
4229}
4230/// A successful response from the server for a `ReadResourceRequestresources/read` request.
4231#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4232pub struct ReadResourceResultResponse {
4233    #[serde(rename = "id")]
4234    pub id: RequestId,
4235    #[serde(rename = "jsonrpc")]
4236    pub jsonrpc: JsonRpcVersion,
4237    #[serde(rename = "result")]
4238    pub result: ReadResourceResultResponseResult,
4239}
4240impl ReadResourceResultResponse {
4241    /// Creates a value from its required fields; optional fields are `None`.
4242    #[must_use]
4243    pub fn new(id: RequestId, result: ReadResourceResultResponseResult) -> Self {
4244        Self {
4245            id,
4246            jsonrpc: Default::default(),
4247            result,
4248        }
4249    }
4250}
4251#[derive(Debug, Clone, PartialEq, Serialize)]
4252#[serde(untagged)]
4253pub enum ReadResourceResultResponseResult {
4254    /// The [`InputRequiredResult`] variant.
4255    InputRequired(InputRequiredResult),
4256    /// The [`ReadResourceResult`] variant.
4257    ReadResource(ReadResourceResult),
4258}
4259impl From<InputRequiredResult> for ReadResourceResultResponseResult {
4260    fn from(v: InputRequiredResult) -> Self {
4261        Self::InputRequired(v)
4262    }
4263}
4264impl From<ReadResourceResult> for ReadResourceResultResponseResult {
4265    fn from(v: ReadResourceResult) -> Self {
4266        Self::ReadResource(v)
4267    }
4268}
4269impl<'de> Deserialize<'de> for ReadResourceResultResponseResult {
4270    fn deserialize<D: serde::Deserializer<'de>>(
4271        deserializer: D,
4272    ) -> ::core::result::Result<Self, D::Error> {
4273        use serde::de::Error as _;
4274        let value = serde_json::Value::deserialize(deserializer)?;
4275        let tag = value
4276            .get("resultType")
4277            .and_then(serde_json::Value::as_str)
4278            .map(str::to_owned);
4279        match tag.as_deref() {
4280            Some("input_required") => serde_json::from_value(value)
4281                .map(Self::InputRequired)
4282                .map_err(D::Error::custom),
4283            _ => serde_json::from_value(value)
4284                .map(Self::ReadResource)
4285                .map_err(D::Error::custom),
4286        }
4287    }
4288}
4289/// The constant `"ref/prompt"`.
4290#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4291pub enum RefPromptType {
4292    /// The constant `"ref/prompt"`.
4293    #[default]
4294    #[serde(rename = "ref/prompt")]
4295    RefPrompt,
4296}
4297impl RefPromptType {
4298    /// The wire representation of this constant.
4299    pub const VALUE: &'static str = "ref/prompt";
4300}
4301/// The constant `"ref/resource"`.
4302#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4303pub enum RefResourceType {
4304    /// The constant `"ref/resource"`.
4305    #[default]
4306    #[serde(rename = "ref/resource")]
4307    RefResource,
4308}
4309impl RefResourceType {
4310    /// The wire representation of this constant.
4311    pub const VALUE: &'static str = "ref/resource";
4312}
4313#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4314pub struct Request {
4315    #[serde(rename = "method")]
4316    pub method: String,
4317    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
4318    pub params: Option<serde_json::Map<String, serde_json::Value>>,
4319}
4320impl Request {
4321    /// Creates a value from its required fields; optional fields are `None`.
4322    #[must_use]
4323    pub fn new(method: String) -> Self {
4324        Self {
4325            method,
4326            params: None,
4327        }
4328    }
4329}
4330/// A uniquely identifying ID for a request in JSON-RPC.
4331#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
4332#[serde(untagged)]
4333pub enum RequestId {
4334    /// A string value.
4335    String(String),
4336    /// An integer value.
4337    Integer(i64),
4338}
4339impl From<String> for RequestId {
4340    fn from(v: String) -> Self {
4341        Self::String(v)
4342    }
4343}
4344impl From<&str> for RequestId {
4345    fn from(v: &str) -> Self {
4346        Self::String(v.to_owned())
4347    }
4348}
4349impl From<i64> for RequestId {
4350    fn from(v: i64) -> Self {
4351        Self::Integer(v)
4352    }
4353}
4354impl<'de> Deserialize<'de> for RequestId {
4355    fn deserialize<D: serde::Deserializer<'de>>(
4356        deserializer: D,
4357    ) -> ::core::result::Result<Self, D::Error> {
4358        struct Visitor;
4359        impl serde::de::Visitor<'_> for Visitor {
4360            type Value = RequestId;
4361            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4362                f.write_str("a string or an integer")
4363            }
4364            fn visit_str<E: serde::de::Error>(
4365                self,
4366                v: &str,
4367            ) -> ::core::result::Result<Self::Value, E> {
4368                Ok(RequestId::String(v.to_owned()))
4369            }
4370            fn visit_string<E: serde::de::Error>(
4371                self,
4372                v: String,
4373            ) -> ::core::result::Result<Self::Value, E> {
4374                Ok(RequestId::String(v))
4375            }
4376            fn visit_i64<E: serde::de::Error>(
4377                self,
4378                v: i64,
4379            ) -> ::core::result::Result<Self::Value, E> {
4380                Ok(RequestId::Integer(v))
4381            }
4382            fn visit_u64<E: serde::de::Error>(
4383                self,
4384                v: u64,
4385            ) -> ::core::result::Result<Self::Value, E> {
4386                i64::try_from(v)
4387                    .map(RequestId::Integer)
4388                    .map_err(|_| E::invalid_value(serde::de::Unexpected::Unsigned(v), &self))
4389            }
4390            #[allow(clippy::cast_possible_truncation, clippy::float_cmp)]
4391            fn visit_f64<E: serde::de::Error>(
4392                self,
4393                v: f64,
4394            ) -> ::core::result::Result<Self::Value, E> {
4395                const MAX_SAFE: f64 = 9_007_199_254_740_991.0;
4396                if v.fract() == 0.0 && (-MAX_SAFE..=MAX_SAFE).contains(&v) {
4397                    Ok(RequestId::Integer(v as i64))
4398                } else {
4399                    Err(E::invalid_type(serde::de::Unexpected::Float(v), &self))
4400                }
4401            }
4402        }
4403        deserializer.deserialize_any(Visitor)
4404    }
4405}
4406/// Extends `MetaObject` with additional request-specific fields. All key naming rules from `MetaObject` apply.
4407#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4408pub struct RequestMetaObject {
4409    /// The client's capabilities for this specific request. Required.
4410    ///
4411    /// Capabilities are declared per-request rather than once at initialization;
4412    /// an empty object means the client supports no optional capabilities.
4413    /// Servers MUST NOT infer capabilities from prior requests.
4414    #[serde(rename = "io.modelcontextprotocol/clientCapabilities")]
4415    pub client_capabilities: ClientCapabilities,
4416    /// Identifies the client software making the request. Clients SHOULD
4417    /// include this field on every request unless specifically configured not
4418    /// to do so.
4419    ///
4420    /// The `Implementation` schema requires `name` and `version`; other
4421    /// fields are optional.
4422    ///
4423    /// The value is self-reported by the client and is not verified by the
4424    /// protocol. It is intended for display, logging, and debugging. Servers
4425    /// SHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for
4426    /// security decisions.
4427    #[serde(
4428        rename = "io.modelcontextprotocol/clientInfo",
4429        default,
4430        skip_serializing_if = "Option::is_none"
4431    )]
4432    pub client_info: Option<Implementation>,
4433    /// The desired log level for this request. Optional.
4434    ///
4435    /// If absent, the server MUST NOT send any `LoggingMessageNotificationnotifications/message`
4436    /// notifications for this request. The client opts in to log messages by
4437    /// explicitly setting a level. Replaces the former `logging/setLevel` RPC.
4438    #[deprecated(
4439        note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
4440    )]
4441    #[serde(
4442        rename = "io.modelcontextprotocol/logLevel",
4443        default,
4444        skip_serializing_if = "Option::is_none"
4445    )]
4446    pub log_level: Option<LoggingLevel>,
4447    /// The MCP Protocol Version being used for this request. Required.
4448    ///
4449    /// For the HTTP transport, this value MUST match the `MCP-Protocol-Version`
4450    /// header; otherwise the server MUST return a `400 Bad Request`. If the
4451    /// server does not support the requested version, it MUST return an
4452    /// `UnsupportedProtocolVersionError`.
4453    #[serde(rename = "io.modelcontextprotocol/protocolVersion")]
4454    pub protocol_version: String,
4455    /// If specified, the caller is requesting out-of-band progress notifications for this request (as represented by `ProgressNotificationnotifications/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.
4456    #[serde(
4457        rename = "progressToken",
4458        default,
4459        skip_serializing_if = "Option::is_none"
4460    )]
4461    pub progress_token: Option<ProgressToken>,
4462    /// Additional properties not described by the schema.
4463    #[serde(flatten)]
4464    pub extra: serde_json::Map<String, serde_json::Value>,
4465}
4466impl RequestMetaObject {
4467    /// Creates a value from its required fields; optional fields are `None`.
4468    #[must_use]
4469    pub fn new(client_capabilities: ClientCapabilities, protocol_version: String) -> Self {
4470        Self {
4471            client_capabilities,
4472            client_info: None,
4473            log_level: None,
4474            protocol_version,
4475            progress_token: None,
4476            extra: serde_json::Map::new(),
4477        }
4478    }
4479}
4480/// Common params for any request.
4481#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4482pub struct RequestParams {
4483    #[serde(rename = "_meta")]
4484    pub meta: RequestMetaObject,
4485}
4486impl RequestParams {
4487    /// Creates a value from its required fields; optional fields are `None`.
4488    #[must_use]
4489    pub fn new(meta: RequestMetaObject) -> Self {
4490        Self { meta }
4491    }
4492}
4493/// A known resource that the server is capable of reading.
4494#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4495pub struct Resource {
4496    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4497    pub meta: Option<MetaObject>,
4498    /// Optional annotations for the client.
4499    #[serde(
4500        rename = "annotations",
4501        default,
4502        skip_serializing_if = "Option::is_none"
4503    )]
4504    pub annotations: Option<Annotations>,
4505    /// A description of what this resource represents.
4506    ///
4507    /// 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.
4508    #[serde(
4509        rename = "description",
4510        default,
4511        skip_serializing_if = "Option::is_none"
4512    )]
4513    pub description: Option<String>,
4514    /// Optional set of sized icons that the client can display in a user interface.
4515    ///
4516    /// Clients that support rendering icons MUST support at least the following MIME types:
4517    /// - `image/png` - PNG images (safe, universal compatibility)
4518    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
4519    ///
4520    /// Clients that support rendering icons SHOULD also support:
4521    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
4522    /// - `image/webp` - WebP images (modern, efficient format)
4523    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
4524    pub icons: Option<Vec<Icon>>,
4525    /// The MIME type of this resource, if known.
4526    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4527    pub mime_type: Option<String>,
4528    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
4529    #[serde(rename = "name")]
4530    pub name: String,
4531    /// The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
4532    ///
4533    /// This can be used by Hosts to display file sizes and estimate context window usage.
4534    #[serde(rename = "size", default, skip_serializing_if = "Option::is_none")]
4535    pub size: Option<i64>,
4536    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
4537    /// even by those unfamiliar with domain-specific terminology.
4538    ///
4539    /// If not provided, the name should be used for display (except for `Tool`,
4540    /// where `annotations.title` should be given precedence over using `name`,
4541    /// if present).
4542    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4543    pub title: Option<String>,
4544    /// The URI of this resource.
4545    #[serde(rename = "uri")]
4546    pub uri: String,
4547}
4548impl Resource {
4549    /// Creates a value from its required fields; optional fields are `None`.
4550    #[must_use]
4551    pub fn new(name: String, uri: String) -> Self {
4552        Self {
4553            meta: None,
4554            annotations: None,
4555            description: None,
4556            icons: None,
4557            mime_type: None,
4558            name,
4559            size: None,
4560            title: None,
4561            uri,
4562        }
4563    }
4564}
4565/// The contents of a specific resource or sub-resource.
4566#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4567pub struct ResourceContents {
4568    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4569    pub meta: Option<MetaObject>,
4570    /// The MIME type of this resource, if known.
4571    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4572    pub mime_type: Option<String>,
4573    /// The URI of this resource.
4574    #[serde(rename = "uri")]
4575    pub uri: String,
4576}
4577impl ResourceContents {
4578    /// Creates a value from its required fields; optional fields are `None`.
4579    #[must_use]
4580    pub fn new(uri: String) -> Self {
4581        Self {
4582            meta: None,
4583            mime_type: None,
4584            uri,
4585        }
4586    }
4587}
4588/// A resource that the server is capable of reading, included in a prompt or tool call result.
4589///
4590/// Note: resource links returned by tools are not guaranteed to appear in the results of `ListResourcesRequestresources/list` requests.
4591#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4592pub struct ResourceLink {
4593    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4594    pub meta: Option<MetaObject>,
4595    /// Optional annotations for the client.
4596    #[serde(
4597        rename = "annotations",
4598        default,
4599        skip_serializing_if = "Option::is_none"
4600    )]
4601    pub annotations: Option<Annotations>,
4602    /// A description of what this resource represents.
4603    ///
4604    /// 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.
4605    #[serde(
4606        rename = "description",
4607        default,
4608        skip_serializing_if = "Option::is_none"
4609    )]
4610    pub description: Option<String>,
4611    /// Optional set of sized icons that the client can display in a user interface.
4612    ///
4613    /// Clients that support rendering icons MUST support at least the following MIME types:
4614    /// - `image/png` - PNG images (safe, universal compatibility)
4615    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
4616    ///
4617    /// Clients that support rendering icons SHOULD also support:
4618    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
4619    /// - `image/webp` - WebP images (modern, efficient format)
4620    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
4621    pub icons: Option<Vec<Icon>>,
4622    /// The MIME type of this resource, if known.
4623    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4624    pub mime_type: Option<String>,
4625    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
4626    #[serde(rename = "name")]
4627    pub name: String,
4628    /// The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
4629    ///
4630    /// This can be used by Hosts to display file sizes and estimate context window usage.
4631    #[serde(rename = "size", default, skip_serializing_if = "Option::is_none")]
4632    pub size: Option<i64>,
4633    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
4634    /// even by those unfamiliar with domain-specific terminology.
4635    ///
4636    /// If not provided, the name should be used for display (except for `Tool`,
4637    /// where `annotations.title` should be given precedence over using `name`,
4638    /// if present).
4639    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4640    pub title: Option<String>,
4641    #[serde(rename = "type")]
4642    pub r#type: ResourceLinkType,
4643    /// The URI of this resource.
4644    #[serde(rename = "uri")]
4645    pub uri: String,
4646}
4647impl ResourceLink {
4648    /// Creates a value from its required fields; optional fields are `None`.
4649    #[must_use]
4650    pub fn new(name: String, uri: String) -> Self {
4651        Self {
4652            meta: None,
4653            annotations: None,
4654            description: None,
4655            icons: None,
4656            mime_type: None,
4657            name,
4658            size: None,
4659            title: None,
4660            r#type: Default::default(),
4661            uri,
4662        }
4663    }
4664}
4665/// The constant `"resource_link"`.
4666#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4667pub enum ResourceLinkType {
4668    /// The constant `"resource_link"`.
4669    #[default]
4670    #[serde(rename = "resource_link")]
4671    ResourceLink,
4672}
4673impl ResourceLinkType {
4674    /// The wire representation of this constant.
4675    pub const VALUE: &'static str = "resource_link";
4676}
4677/// An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This is only delivered on a `SubscriptionsListenRequestsubscriptions/listen` stream when the client requested it via the `resourcesListChanged` filter field.
4678#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
4679pub struct ResourceListChangedNotification {
4680    #[serde(rename = "jsonrpc")]
4681    pub jsonrpc: JsonRpcVersion,
4682    #[serde(rename = "method")]
4683    pub method: NotificationsResourcesListChangedMethod,
4684    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
4685    pub params: Option<NotificationParams>,
4686}
4687/// Common params for resource-related requests.
4688#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4689pub struct ResourceRequestParams {
4690    #[serde(rename = "_meta")]
4691    pub meta: RequestMetaObject,
4692    /// The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
4693    #[serde(rename = "uri")]
4694    pub uri: String,
4695}
4696impl ResourceRequestParams {
4697    /// Creates a value from its required fields; optional fields are `None`.
4698    #[must_use]
4699    pub fn new(meta: RequestMetaObject, uri: String) -> Self {
4700        Self { meta, uri }
4701    }
4702}
4703/// A template description for resources available on the server.
4704#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4705pub struct ResourceTemplate {
4706    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4707    pub meta: Option<MetaObject>,
4708    /// Optional annotations for the client.
4709    #[serde(
4710        rename = "annotations",
4711        default,
4712        skip_serializing_if = "Option::is_none"
4713    )]
4714    pub annotations: Option<Annotations>,
4715    /// A description of what this template is for.
4716    ///
4717    /// 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.
4718    #[serde(
4719        rename = "description",
4720        default,
4721        skip_serializing_if = "Option::is_none"
4722    )]
4723    pub description: Option<String>,
4724    /// Optional set of sized icons that the client can display in a user interface.
4725    ///
4726    /// Clients that support rendering icons MUST support at least the following MIME types:
4727    /// - `image/png` - PNG images (safe, universal compatibility)
4728    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
4729    ///
4730    /// Clients that support rendering icons SHOULD also support:
4731    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
4732    /// - `image/webp` - WebP images (modern, efficient format)
4733    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
4734    pub icons: Option<Vec<Icon>>,
4735    /// 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.
4736    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4737    pub mime_type: Option<String>,
4738    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
4739    #[serde(rename = "name")]
4740    pub name: String,
4741    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
4742    /// even by those unfamiliar with domain-specific terminology.
4743    ///
4744    /// If not provided, the name should be used for display (except for `Tool`,
4745    /// where `annotations.title` should be given precedence over using `name`,
4746    /// if present).
4747    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4748    pub title: Option<String>,
4749    /// A URI template (according to RFC 6570) that can be used to construct resource URIs.
4750    #[serde(rename = "uriTemplate")]
4751    pub uri_template: String,
4752}
4753impl ResourceTemplate {
4754    /// Creates a value from its required fields; optional fields are `None`.
4755    #[must_use]
4756    pub fn new(name: String, uri_template: String) -> Self {
4757        Self {
4758            meta: None,
4759            annotations: None,
4760            description: None,
4761            icons: None,
4762            mime_type: None,
4763            name,
4764            title: None,
4765            uri_template,
4766        }
4767    }
4768}
4769/// A reference to a resource or resource template definition.
4770#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4771pub struct ResourceTemplateReference {
4772    #[serde(rename = "type")]
4773    pub r#type: RefResourceType,
4774    /// The URI or URI template of the resource.
4775    #[serde(rename = "uri")]
4776    pub uri: String,
4777}
4778impl ResourceTemplateReference {
4779    /// Creates a value from its required fields; optional fields are `None`.
4780    #[must_use]
4781    pub fn new(uri: String) -> Self {
4782        Self {
4783            r#type: Default::default(),
4784            uri,
4785        }
4786    }
4787}
4788/// The constant `"resource"`.
4789#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4790pub enum ResourceType {
4791    /// The constant `"resource"`.
4792    #[default]
4793    #[serde(rename = "resource")]
4794    Resource,
4795}
4796impl ResourceType {
4797    /// The wire representation of this constant.
4798    pub const VALUE: &'static str = "resource";
4799}
4800/// A notification from the server to the client, informing it that a resource has changed and may need to be read again. This is only sent for resources the client opted in to via the `resourceSubscriptions` field of a `SubscriptionsListenRequestsubscriptions/listen` request.
4801#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4802pub struct ResourceUpdatedNotification {
4803    #[serde(rename = "jsonrpc")]
4804    pub jsonrpc: JsonRpcVersion,
4805    #[serde(rename = "method")]
4806    pub method: NotificationsResourcesUpdatedMethod,
4807    #[serde(rename = "params")]
4808    pub params: ResourceUpdatedNotificationParams,
4809}
4810impl ResourceUpdatedNotification {
4811    /// Creates a value from its required fields; optional fields are `None`.
4812    #[must_use]
4813    pub fn new(params: ResourceUpdatedNotificationParams) -> Self {
4814        Self {
4815            jsonrpc: Default::default(),
4816            method: Default::default(),
4817            params,
4818        }
4819    }
4820}
4821/// Parameters for a `notifications/resources/updated` notification.
4822#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4823pub struct ResourceUpdatedNotificationParams {
4824    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4825    pub meta: Option<NotificationMetaObject>,
4826    /// The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
4827    #[serde(rename = "uri")]
4828    pub uri: String,
4829}
4830impl ResourceUpdatedNotificationParams {
4831    /// Creates a value from its required fields; optional fields are `None`.
4832    #[must_use]
4833    pub fn new(uri: String) -> Self {
4834        Self { meta: None, uri }
4835    }
4836}
4837/// The constant `"resources/list"`.
4838#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4839pub enum ResourcesListMethod {
4840    /// The constant `"resources/list"`.
4841    #[default]
4842    #[serde(rename = "resources/list")]
4843    ResourcesList,
4844}
4845impl ResourcesListMethod {
4846    /// The wire representation of this constant.
4847    pub const VALUE: &'static str = "resources/list";
4848}
4849/// The constant `"resources/read"`.
4850#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4851pub enum ResourcesReadMethod {
4852    /// The constant `"resources/read"`.
4853    #[default]
4854    #[serde(rename = "resources/read")]
4855    ResourcesRead,
4856}
4857impl ResourcesReadMethod {
4858    /// The wire representation of this constant.
4859    pub const VALUE: &'static str = "resources/read";
4860}
4861/// The constant `"resources/templates/list"`.
4862#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4863pub enum ResourcesTemplatesListMethod {
4864    /// The constant `"resources/templates/list"`.
4865    #[default]
4866    #[serde(rename = "resources/templates/list")]
4867    ResourcesTemplatesList,
4868}
4869impl ResourcesTemplatesListMethod {
4870    /// The wire representation of this constant.
4871    pub const VALUE: &'static str = "resources/templates/list";
4872}
4873/// Common result fields.
4874#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4875pub struct Result {
4876    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4877    pub meta: Option<ResultMetaObject>,
4878    /// Indicates the type of the result, which allows the client to determine
4879    /// how to parse the result object.
4880    ///
4881    /// Servers implementing this protocol version MUST include this field.
4882    /// For backward compatibility, when a client receives a result from a
4883    /// server implementing an earlier protocol version (which does not include
4884    /// `resultType`), the client MUST treat the absent field as `"complete"`.
4885    #[serde(rename = "resultType")]
4886    pub result_type: String,
4887    /// Additional properties not described by the schema.
4888    #[serde(flatten)]
4889    pub extra: serde_json::Map<String, serde_json::Value>,
4890}
4891impl Result {
4892    /// Creates a value from its required fields; optional fields are `None`.
4893    #[must_use]
4894    pub fn new(result_type: String) -> Self {
4895        Self {
4896            meta: None,
4897            result_type,
4898            extra: serde_json::Map::new(),
4899        }
4900    }
4901}
4902/// Extends `MetaObject` with additional result-specific fields. All key naming rules from `MetaObject` apply.
4903#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
4904pub struct ResultMetaObject {
4905    /// Identifies the server software producing the response. Servers SHOULD
4906    /// include this field on every response unless specifically configured not
4907    /// to do so.
4908    ///
4909    /// The `Implementation` schema requires `name` and `version`; other
4910    /// fields are optional.
4911    ///
4912    /// The value is self-reported by the server and is not verified by the
4913    /// protocol. It is intended for display, logging, and debugging. Clients
4914    /// SHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for
4915    /// security decisions.
4916    #[serde(
4917        rename = "io.modelcontextprotocol/serverInfo",
4918        default,
4919        skip_serializing_if = "Option::is_none"
4920    )]
4921    pub server_info: Option<Implementation>,
4922    /// Additional properties not described by the schema.
4923    #[serde(flatten)]
4924    pub extra: serde_json::Map<String, serde_json::Value>,
4925}
4926/// Indicates the type of a `Result` object, allowing the client to
4927/// determine how to parse the response.
4928///
4929/// complete - the request completed successfully and the result contains the final content.
4930/// input_required - the request requires additional input and the result contains an `InputRequiredResult` object with instructions for the client to provide additional input before retrying the original request.
4931pub type ResultType = String;
4932/// The sender or recipient of messages and data in a conversation.
4933#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
4934pub enum Role {
4935    /// `"assistant"`
4936    #[serde(rename = "assistant")]
4937    Assistant,
4938    /// `"user"`
4939    #[serde(rename = "user")]
4940    User,
4941}
4942impl Role {
4943    /// The wire representation of this value.
4944    #[must_use]
4945    pub const fn as_str(self) -> &'static str {
4946        match self {
4947            Self::Assistant => "assistant",
4948            Self::User => "user",
4949        }
4950    }
4951}
4952/// Represents a root directory or file that the server can operate on.
4953#[deprecated(
4954    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
4955)]
4956#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4957pub struct Root {
4958    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
4959    pub meta: Option<MetaObject>,
4960    /// An optional name for the root. This can be used to provide a human-readable
4961    /// identifier for the root, which may be useful for display purposes or for
4962    /// referencing the root in other parts of the application.
4963    #[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
4964    pub name: Option<String>,
4965    /// The URI identifying the root. This *must* start with `file://` for now.
4966    /// This restriction may be relaxed in future versions of the protocol to allow
4967    /// other URI schemes.
4968    #[serde(rename = "uri")]
4969    pub uri: String,
4970}
4971impl Root {
4972    /// Creates a value from its required fields; optional fields are `None`.
4973    #[must_use]
4974    pub fn new(uri: String) -> Self {
4975        Self {
4976            meta: None,
4977            name: None,
4978            uri,
4979        }
4980    }
4981}
4982/// The constant `"roots/list"`.
4983#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4984pub enum RootsListMethod {
4985    /// The constant `"roots/list"`.
4986    #[default]
4987    #[serde(rename = "roots/list")]
4988    RootsList,
4989}
4990impl RootsListMethod {
4991    /// The wire representation of this constant.
4992    pub const VALUE: &'static str = "roots/list";
4993}
4994/// The constant `"sampling/createMessage"`.
4995#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4996pub enum SamplingCreateMessageMethod {
4997    /// The constant `"sampling/createMessage"`.
4998    #[default]
4999    #[serde(rename = "sampling/createMessage")]
5000    SamplingCreateMessage,
5001}
5002impl SamplingCreateMessageMethod {
5003    /// The wire representation of this constant.
5004    pub const VALUE: &'static str = "sampling/createMessage";
5005}
5006/// Describes a message issued to or received from an LLM API.
5007#[deprecated(
5008    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
5009)]
5010#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5011pub struct SamplingMessage {
5012    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
5013    pub meta: Option<MetaObject>,
5014    #[serde(rename = "content")]
5015    pub content: SamplingMessageContent,
5016    #[serde(rename = "role")]
5017    pub role: Role,
5018}
5019impl SamplingMessage {
5020    /// Creates a value from its required fields; optional fields are `None`.
5021    #[must_use]
5022    pub fn new(content: SamplingMessageContent, role: Role) -> Self {
5023        Self {
5024            meta: None,
5025            content,
5026            role,
5027        }
5028    }
5029}
5030#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5031#[serde(untagged)]
5032pub enum SamplingMessageContent {
5033    /// The [`TextContent`] variant.
5034    TextContent(TextContent),
5035    /// The [`ImageContent`] variant.
5036    ImageContent(ImageContent),
5037    /// The [`AudioContent`] variant.
5038    AudioContent(AudioContent),
5039    /// The [`ToolUseContent`] variant.
5040    ToolUseContent(ToolUseContent),
5041    /// The [`ToolResultContent`] variant.
5042    ToolResultContent(ToolResultContent),
5043    /// An inline variant.
5044    List(Vec<SamplingMessageContentBlock>),
5045}
5046impl From<TextContent> for SamplingMessageContent {
5047    fn from(v: TextContent) -> Self {
5048        Self::TextContent(v)
5049    }
5050}
5051impl From<ImageContent> for SamplingMessageContent {
5052    fn from(v: ImageContent) -> Self {
5053        Self::ImageContent(v)
5054    }
5055}
5056impl From<AudioContent> for SamplingMessageContent {
5057    fn from(v: AudioContent) -> Self {
5058        Self::AudioContent(v)
5059    }
5060}
5061impl From<ToolUseContent> for SamplingMessageContent {
5062    fn from(v: ToolUseContent) -> Self {
5063        Self::ToolUseContent(v)
5064    }
5065}
5066impl From<ToolResultContent> for SamplingMessageContent {
5067    fn from(v: ToolResultContent) -> Self {
5068        Self::ToolResultContent(v)
5069    }
5070}
5071impl From<Vec<SamplingMessageContentBlock>> for SamplingMessageContent {
5072    fn from(v: Vec<SamplingMessageContentBlock>) -> Self {
5073        Self::List(v)
5074    }
5075}
5076#[deprecated(
5077    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
5078)]
5079#[derive(Debug, Clone, PartialEq, Serialize)]
5080#[serde(untagged)]
5081pub enum SamplingMessageContentBlock {
5082    /// The [`TextContent`] variant.
5083    Text(TextContent),
5084    /// The [`ImageContent`] variant.
5085    Image(ImageContent),
5086    /// The [`AudioContent`] variant.
5087    Audio(AudioContent),
5088    /// The [`ToolUseContent`] variant.
5089    ToolUse(ToolUseContent),
5090    /// The [`ToolResultContent`] variant.
5091    ToolResult(ToolResultContent),
5092}
5093impl From<TextContent> for SamplingMessageContentBlock {
5094    fn from(v: TextContent) -> Self {
5095        Self::Text(v)
5096    }
5097}
5098impl From<ImageContent> for SamplingMessageContentBlock {
5099    fn from(v: ImageContent) -> Self {
5100        Self::Image(v)
5101    }
5102}
5103impl From<AudioContent> for SamplingMessageContentBlock {
5104    fn from(v: AudioContent) -> Self {
5105        Self::Audio(v)
5106    }
5107}
5108impl From<ToolUseContent> for SamplingMessageContentBlock {
5109    fn from(v: ToolUseContent) -> Self {
5110        Self::ToolUse(v)
5111    }
5112}
5113impl From<ToolResultContent> for SamplingMessageContentBlock {
5114    fn from(v: ToolResultContent) -> Self {
5115        Self::ToolResult(v)
5116    }
5117}
5118impl<'de> Deserialize<'de> for SamplingMessageContentBlock {
5119    fn deserialize<D: serde::Deserializer<'de>>(
5120        deserializer: D,
5121    ) -> ::core::result::Result<Self, D::Error> {
5122        use serde::de::Error as _;
5123        let value = serde_json::Value::deserialize(deserializer)?;
5124        let tag = value
5125            .get("type")
5126            .and_then(serde_json::Value::as_str)
5127            .map(str::to_owned);
5128        match tag.as_deref() {
5129            Some("text") => serde_json::from_value(value)
5130                .map(Self::Text)
5131                .map_err(D::Error::custom),
5132            Some("image") => serde_json::from_value(value)
5133                .map(Self::Image)
5134                .map_err(D::Error::custom),
5135            Some("audio") => serde_json::from_value(value)
5136                .map(Self::Audio)
5137                .map_err(D::Error::custom),
5138            Some("tool_use") => serde_json::from_value(value)
5139                .map(Self::ToolUse)
5140                .map_err(D::Error::custom),
5141            Some("tool_result") => serde_json::from_value(value)
5142                .map(Self::ToolResult)
5143                .map_err(D::Error::custom),
5144            None => Err(D::Error::missing_field("type")),
5145            Some(other) => Err(D::Error::unknown_variant(
5146                other,
5147                &["text", "image", "audio", "tool_use", "tool_result"],
5148            )),
5149        }
5150    }
5151}
5152/// 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.
5153#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5154pub struct ServerCapabilities {
5155    /// Present if the server supports argument autocompletion suggestions.
5156    #[serde(
5157        rename = "completions",
5158        default,
5159        skip_serializing_if = "Option::is_none"
5160    )]
5161    pub completions: Option<serde_json::Map<String, serde_json::Value>>,
5162    /// Experimental, non-standard capabilities that the server supports.
5163    #[serde(
5164        rename = "experimental",
5165        default,
5166        skip_serializing_if = "Option::is_none"
5167    )]
5168    pub experimental:
5169        Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
5170    /// Optional MCP extensions that the server supports. Keys are extension identifiers
5171    /// (e.g., "io.modelcontextprotocol/tasks"), and values are per-extension settings
5172    /// objects. An empty object indicates support with no settings.
5173    ///
5174    /// Keys MUST follow the `MetaObject`_meta``, with a
5175    /// mandatory prefix.
5176    #[serde(
5177        rename = "extensions",
5178        default,
5179        skip_serializing_if = "Option::is_none"
5180    )]
5181    pub extensions:
5182        Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
5183    /// Present if the server supports sending log messages to the client.
5184    #[deprecated(
5185        note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
5186    )]
5187    #[serde(rename = "logging", default, skip_serializing_if = "Option::is_none")]
5188    pub logging: Option<serde_json::Map<String, serde_json::Value>>,
5189    /// Present if the server offers any prompt templates.
5190    #[serde(rename = "prompts", default, skip_serializing_if = "Option::is_none")]
5191    pub prompts: Option<ServerCapabilitiesPrompts>,
5192    /// Present if the server offers any resources to read.
5193    #[serde(rename = "resources", default, skip_serializing_if = "Option::is_none")]
5194    pub resources: Option<ServerCapabilitiesResources>,
5195    /// Present if the server offers any tools to call.
5196    #[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
5197    pub tools: Option<ServerCapabilitiesTools>,
5198}
5199/// Present if the server offers any prompt templates.
5200#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5201pub struct ServerCapabilitiesPrompts {
5202    /// Whether this server supports notifications for changes to the prompt list.
5203    #[serde(
5204        rename = "listChanged",
5205        default,
5206        skip_serializing_if = "Option::is_none"
5207    )]
5208    pub list_changed: Option<bool>,
5209}
5210/// Present if the server offers any resources to read.
5211#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5212pub struct ServerCapabilitiesResources {
5213    /// Whether this server supports notifications for changes to the resource list.
5214    #[serde(
5215        rename = "listChanged",
5216        default,
5217        skip_serializing_if = "Option::is_none"
5218    )]
5219    pub list_changed: Option<bool>,
5220    /// Whether this server supports subscribing to resource updates.
5221    #[serde(rename = "subscribe", default, skip_serializing_if = "Option::is_none")]
5222    pub subscribe: Option<bool>,
5223}
5224/// Present if the server offers any tools to call.
5225#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5226pub struct ServerCapabilitiesTools {
5227    /// Whether this server supports notifications for changes to the tool list.
5228    #[serde(
5229        rename = "listChanged",
5230        default,
5231        skip_serializing_if = "Option::is_none"
5232    )]
5233    pub list_changed: Option<bool>,
5234}
5235/// The constant `"server/discover"`.
5236#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5237pub enum ServerDiscoverMethod {
5238    /// The constant `"server/discover"`.
5239    #[default]
5240    #[serde(rename = "server/discover")]
5241    ServerDiscover,
5242}
5243impl ServerDiscoverMethod {
5244    /// The wire representation of this constant.
5245    pub const VALUE: &'static str = "server/discover";
5246}
5247#[derive(Debug, Clone, PartialEq, Serialize)]
5248#[serde(untagged)]
5249pub enum ServerNotification {
5250    /// The [`CancelledNotification`] variant.
5251    Cancelled(CancelledNotification),
5252    /// The [`ProgressNotification`] variant.
5253    Progress(ProgressNotification),
5254    /// The [`ResourceListChangedNotification`] variant.
5255    ResourceListChanged(ResourceListChangedNotification),
5256    /// The [`SubscriptionsAcknowledgedNotification`] variant.
5257    SubscriptionsAcknowledged(SubscriptionsAcknowledgedNotification),
5258    /// The [`ResourceUpdatedNotification`] variant.
5259    ResourceUpdated(ResourceUpdatedNotification),
5260    /// The [`PromptListChangedNotification`] variant.
5261    PromptListChanged(PromptListChangedNotification),
5262    /// The [`ToolListChangedNotification`] variant.
5263    ToolListChanged(ToolListChangedNotification),
5264    /// The [`LoggingMessageNotification`] variant.
5265    LoggingMessage(LoggingMessageNotification),
5266}
5267impl From<CancelledNotification> for ServerNotification {
5268    fn from(v: CancelledNotification) -> Self {
5269        Self::Cancelled(v)
5270    }
5271}
5272impl From<ProgressNotification> for ServerNotification {
5273    fn from(v: ProgressNotification) -> Self {
5274        Self::Progress(v)
5275    }
5276}
5277impl From<ResourceListChangedNotification> for ServerNotification {
5278    fn from(v: ResourceListChangedNotification) -> Self {
5279        Self::ResourceListChanged(v)
5280    }
5281}
5282impl From<SubscriptionsAcknowledgedNotification> for ServerNotification {
5283    fn from(v: SubscriptionsAcknowledgedNotification) -> Self {
5284        Self::SubscriptionsAcknowledged(v)
5285    }
5286}
5287impl From<ResourceUpdatedNotification> for ServerNotification {
5288    fn from(v: ResourceUpdatedNotification) -> Self {
5289        Self::ResourceUpdated(v)
5290    }
5291}
5292impl From<PromptListChangedNotification> for ServerNotification {
5293    fn from(v: PromptListChangedNotification) -> Self {
5294        Self::PromptListChanged(v)
5295    }
5296}
5297impl From<ToolListChangedNotification> for ServerNotification {
5298    fn from(v: ToolListChangedNotification) -> Self {
5299        Self::ToolListChanged(v)
5300    }
5301}
5302impl From<LoggingMessageNotification> for ServerNotification {
5303    fn from(v: LoggingMessageNotification) -> Self {
5304        Self::LoggingMessage(v)
5305    }
5306}
5307impl<'de> Deserialize<'de> for ServerNotification {
5308    fn deserialize<D: serde::Deserializer<'de>>(
5309        deserializer: D,
5310    ) -> ::core::result::Result<Self, D::Error> {
5311        use serde::de::Error as _;
5312        let value = serde_json::Value::deserialize(deserializer)?;
5313        let tag = value
5314            .get("method")
5315            .and_then(serde_json::Value::as_str)
5316            .map(str::to_owned);
5317        match tag.as_deref() {
5318            Some("notifications/cancelled") => serde_json::from_value(value)
5319                .map(Self::Cancelled)
5320                .map_err(D::Error::custom),
5321            Some("notifications/progress") => serde_json::from_value(value)
5322                .map(Self::Progress)
5323                .map_err(D::Error::custom),
5324            Some("notifications/resources/list_changed") => serde_json::from_value(value)
5325                .map(Self::ResourceListChanged)
5326                .map_err(D::Error::custom),
5327            Some("notifications/subscriptions/acknowledged") => serde_json::from_value(value)
5328                .map(Self::SubscriptionsAcknowledged)
5329                .map_err(D::Error::custom),
5330            Some("notifications/resources/updated") => serde_json::from_value(value)
5331                .map(Self::ResourceUpdated)
5332                .map_err(D::Error::custom),
5333            Some("notifications/prompts/list_changed") => serde_json::from_value(value)
5334                .map(Self::PromptListChanged)
5335                .map_err(D::Error::custom),
5336            Some("notifications/tools/list_changed") => serde_json::from_value(value)
5337                .map(Self::ToolListChanged)
5338                .map_err(D::Error::custom),
5339            Some("notifications/message") => serde_json::from_value(value)
5340                .map(Self::LoggingMessage)
5341                .map_err(D::Error::custom),
5342            None => Err(D::Error::missing_field("method")),
5343            Some(other) => Err(D::Error::unknown_variant(
5344                other,
5345                &[
5346                    "notifications/cancelled",
5347                    "notifications/progress",
5348                    "notifications/resources/list_changed",
5349                    "notifications/subscriptions/acknowledged",
5350                    "notifications/resources/updated",
5351                    "notifications/prompts/list_changed",
5352                    "notifications/tools/list_changed",
5353                    "notifications/message",
5354                ],
5355            )),
5356        }
5357    }
5358}
5359#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5360#[serde(untagged)]
5361pub enum SingleSelectEnumSchema {
5362    /// The [`UntitledSingleSelectEnumSchema`] variant.
5363    Untitled(UntitledSingleSelectEnumSchema),
5364    /// The [`TitledSingleSelectEnumSchema`] variant.
5365    Titled(TitledSingleSelectEnumSchema),
5366}
5367impl From<UntitledSingleSelectEnumSchema> for SingleSelectEnumSchema {
5368    fn from(v: UntitledSingleSelectEnumSchema) -> Self {
5369        Self::Untitled(v)
5370    }
5371}
5372impl From<TitledSingleSelectEnumSchema> for SingleSelectEnumSchema {
5373    fn from(v: TitledSingleSelectEnumSchema) -> Self {
5374        Self::Titled(v)
5375    }
5376}
5377#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5378pub struct StringSchema {
5379    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
5380    pub default: Option<String>,
5381    #[serde(
5382        rename = "description",
5383        default,
5384        skip_serializing_if = "Option::is_none"
5385    )]
5386    pub description: Option<String>,
5387    #[serde(rename = "format", default, skip_serializing_if = "Option::is_none")]
5388    pub format: Option<StringSchemaFormat>,
5389    #[serde(rename = "maxLength", default, skip_serializing_if = "Option::is_none")]
5390    pub max_length: Option<i64>,
5391    #[serde(rename = "minLength", default, skip_serializing_if = "Option::is_none")]
5392    pub min_length: Option<i64>,
5393    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
5394    pub title: Option<String>,
5395    #[serde(rename = "type")]
5396    pub r#type: StringType,
5397}
5398#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5399pub enum StringSchemaFormat {
5400    /// `"date"`
5401    #[serde(rename = "date")]
5402    Date,
5403    /// `"date-time"`
5404    #[serde(rename = "date-time")]
5405    DateTime,
5406    /// `"email"`
5407    #[serde(rename = "email")]
5408    Email,
5409    /// `"uri"`
5410    #[serde(rename = "uri")]
5411    Uri,
5412}
5413impl StringSchemaFormat {
5414    /// The wire representation of this value.
5415    #[must_use]
5416    pub const fn as_str(self) -> &'static str {
5417        match self {
5418            Self::Date => "date",
5419            Self::DateTime => "date-time",
5420            Self::Email => "email",
5421            Self::Uri => "uri",
5422        }
5423    }
5424}
5425/// The constant `"string"`.
5426#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5427pub enum StringType {
5428    /// The constant `"string"`.
5429    #[default]
5430    #[serde(rename = "string")]
5431    String,
5432}
5433impl StringType {
5434    /// The wire representation of this constant.
5435    pub const VALUE: &'static str = "string";
5436}
5437/// The set of notification types a client may opt in to on a
5438/// `SubscriptionsListenRequestsubscriptions/listen` request.
5439///
5440/// Each notification type is **opt-in**; the server **MUST NOT** send
5441/// notification types the client has not explicitly requested here.
5442#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5443pub struct SubscriptionFilter {
5444    /// If true, receive `PromptListChangedNotificationnotifications/prompts/list_changed`.
5445    #[serde(
5446        rename = "promptsListChanged",
5447        default,
5448        skip_serializing_if = "Option::is_none"
5449    )]
5450    pub prompts_list_changed: Option<bool>,
5451    /// Subscribe to `ResourceUpdatedNotificationnotifications/resources/updated` for these resource URIs.
5452    /// Replaces the former `resources/subscribe` RPC.
5453    #[serde(
5454        rename = "resourceSubscriptions",
5455        default,
5456        skip_serializing_if = "Option::is_none"
5457    )]
5458    pub resource_subscriptions: Option<Vec<String>>,
5459    /// If true, receive `ResourceListChangedNotificationnotifications/resources/list_changed`.
5460    #[serde(
5461        rename = "resourcesListChanged",
5462        default,
5463        skip_serializing_if = "Option::is_none"
5464    )]
5465    pub resources_list_changed: Option<bool>,
5466    /// If true, receive `ToolListChangedNotificationnotifications/tools/list_changed`.
5467    #[serde(
5468        rename = "toolsListChanged",
5469        default,
5470        skip_serializing_if = "Option::is_none"
5471    )]
5472    pub tools_list_changed: Option<bool>,
5473}
5474/// Sent by the server to acknowledge that a
5475/// `SubscriptionsListenRequestsubscriptions/listen` subscription has been
5476/// established and to report which notification types it agreed to honor.
5477///
5478/// This notification MUST be the first message the server sends carrying the
5479/// subscription's ID in `io.modelcontextprotocol/subscriptionId`. The server MUST
5480/// NOT send any notification on the subscription before acknowledging it. On
5481/// stdio, where every subscription shares one channel, this ordering is defined
5482/// per subscription ID and not per channel: messages belonging to other
5483/// subscriptions MAY be interleaved before it.
5484#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5485pub struct SubscriptionsAcknowledgedNotification {
5486    #[serde(rename = "jsonrpc")]
5487    pub jsonrpc: JsonRpcVersion,
5488    #[serde(rename = "method")]
5489    pub method: NotificationsSubscriptionsAcknowledgedMethod,
5490    #[serde(rename = "params")]
5491    pub params: SubscriptionsAcknowledgedNotificationParams,
5492}
5493impl SubscriptionsAcknowledgedNotification {
5494    /// Creates a value from its required fields; optional fields are `None`.
5495    #[must_use]
5496    pub fn new(params: SubscriptionsAcknowledgedNotificationParams) -> Self {
5497        Self {
5498            jsonrpc: Default::default(),
5499            method: Default::default(),
5500            params,
5501        }
5502    }
5503}
5504/// Parameters for a `SubscriptionsAcknowledgedNotificationnotifications/subscriptions/acknowledged` notification.
5505#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5506pub struct SubscriptionsAcknowledgedNotificationParams {
5507    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
5508    pub meta: Option<NotificationMetaObject>,
5509    /// The subset of requested notification types the server agreed to honor.
5510    /// Only includes notification types the server actually supports; if the
5511    /// client requested an unsupported type (e.g., `promptsListChanged` when
5512    /// the server has no prompts), it is omitted from this set.
5513    #[serde(rename = "notifications")]
5514    pub notifications: SubscriptionFilter,
5515}
5516impl SubscriptionsAcknowledgedNotificationParams {
5517    /// Creates a value from its required fields; optional fields are `None`.
5518    #[must_use]
5519    pub fn new(notifications: SubscriptionFilter) -> Self {
5520        Self {
5521            meta: None,
5522            notifications,
5523        }
5524    }
5525}
5526/// The constant `"subscriptions/listen"`.
5527#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5528pub enum SubscriptionsListenMethod {
5529    /// The constant `"subscriptions/listen"`.
5530    #[default]
5531    #[serde(rename = "subscriptions/listen")]
5532    SubscriptionsListen,
5533}
5534impl SubscriptionsListenMethod {
5535    /// The wire representation of this constant.
5536    pub const VALUE: &'static str = "subscriptions/listen";
5537}
5538/// Sent from the client to open a long-lived channel for receiving notifications
5539/// outside the context of a specific request. Replaces the previous HTTP GET
5540/// endpoint and ensures consistent behavior between HTTP and STDIO.
5541#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5542pub struct SubscriptionsListenRequest {
5543    #[serde(rename = "id")]
5544    pub id: RequestId,
5545    #[serde(rename = "jsonrpc")]
5546    pub jsonrpc: JsonRpcVersion,
5547    #[serde(rename = "method")]
5548    pub method: SubscriptionsListenMethod,
5549    #[serde(rename = "params")]
5550    pub params: SubscriptionsListenRequestParams,
5551}
5552impl SubscriptionsListenRequest {
5553    /// Creates a value from its required fields; optional fields are `None`.
5554    #[must_use]
5555    pub fn new(id: RequestId, params: SubscriptionsListenRequestParams) -> Self {
5556        Self {
5557            id,
5558            jsonrpc: Default::default(),
5559            method: Default::default(),
5560            params,
5561        }
5562    }
5563}
5564/// Parameters for a `SubscriptionsListenRequestsubscriptions/listen` request.
5565#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5566pub struct SubscriptionsListenRequestParams {
5567    #[serde(rename = "_meta")]
5568    pub meta: RequestMetaObject,
5569    /// The notifications the client opts in to on this stream. The server
5570    /// **MUST NOT** send notification types the client has not explicitly
5571    /// requested.
5572    #[serde(rename = "notifications")]
5573    pub notifications: SubscriptionFilter,
5574}
5575impl SubscriptionsListenRequestParams {
5576    /// Creates a value from its required fields; optional fields are `None`.
5577    #[must_use]
5578    pub fn new(meta: RequestMetaObject, notifications: SubscriptionFilter) -> Self {
5579        Self {
5580            meta,
5581            notifications,
5582        }
5583    }
5584}
5585/// The response to a `SubscriptionsListenRequestsubscriptions/listen`
5586/// request, signalling that the subscription has ended gracefully (for example,
5587/// during server shutdown). Because the listen stream is long-lived, this result
5588/// is sent only when the server tears the subscription down; an abrupt transport
5589/// close carries no response. The result body is otherwise empty.
5590#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5591pub struct SubscriptionsListenResult {
5592    #[serde(rename = "_meta")]
5593    pub meta: SubscriptionsListenResultMetaObject,
5594    /// Indicates the type of the result, which allows the client to determine
5595    /// how to parse the result object.
5596    ///
5597    /// Servers implementing this protocol version MUST include this field.
5598    /// For backward compatibility, when a client receives a result from a
5599    /// server implementing an earlier protocol version (which does not include
5600    /// `resultType`), the client MUST treat the absent field as `"complete"`.
5601    #[serde(rename = "resultType")]
5602    pub result_type: String,
5603}
5604impl SubscriptionsListenResult {
5605    /// Creates a value from its required fields; optional fields are `None`.
5606    #[must_use]
5607    pub fn new(meta: SubscriptionsListenResultMetaObject, result_type: String) -> Self {
5608        Self { meta, result_type }
5609    }
5610}
5611/// Extends `ResultMetaObject` with the subscription-stream identifier carried by a
5612/// `SubscriptionsListenResult`. All key naming rules from `MetaObject` apply.
5613#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5614pub struct SubscriptionsListenResultMetaObject {
5615    /// Identifies the server software producing the response. Servers SHOULD
5616    /// include this field on every response unless specifically configured not
5617    /// to do so.
5618    ///
5619    /// The `Implementation` schema requires `name` and `version`; other
5620    /// fields are optional.
5621    ///
5622    /// The value is self-reported by the server and is not verified by the
5623    /// protocol. It is intended for display, logging, and debugging. Clients
5624    /// SHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for
5625    /// security decisions.
5626    #[serde(
5627        rename = "io.modelcontextprotocol/serverInfo",
5628        default,
5629        skip_serializing_if = "Option::is_none"
5630    )]
5631    pub server_info: Option<Implementation>,
5632    /// Identifies the subscription stream this response closes, so the client can
5633    /// correlate it with the originating subscription — mirroring the same key on
5634    /// the stream's notifications. The value is the JSON-RPC ID of the
5635    /// `subscriptions/listen` request that opened the stream (and equals this
5636    /// response's `id`).
5637    #[serde(rename = "io.modelcontextprotocol/subscriptionId")]
5638    pub subscription_id: RequestId,
5639    /// Additional properties not described by the schema.
5640    #[serde(flatten)]
5641    pub extra: serde_json::Map<String, serde_json::Value>,
5642}
5643impl SubscriptionsListenResultMetaObject {
5644    /// Creates a value from its required fields; optional fields are `None`.
5645    #[must_use]
5646    pub fn new(subscription_id: RequestId) -> Self {
5647        Self {
5648            server_info: None,
5649            subscription_id,
5650            extra: serde_json::Map::new(),
5651        }
5652    }
5653}
5654/// A successful response from the server for a `SubscriptionsListenRequestsubscriptions/listen`
5655/// request, sent when the server tears the subscription down gracefully.
5656#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5657pub struct SubscriptionsListenResultResponse {
5658    #[serde(rename = "id")]
5659    pub id: RequestId,
5660    #[serde(rename = "jsonrpc")]
5661    pub jsonrpc: JsonRpcVersion,
5662    #[serde(rename = "result")]
5663    pub result: SubscriptionsListenResult,
5664}
5665impl SubscriptionsListenResultResponse {
5666    /// Creates a value from its required fields; optional fields are `None`.
5667    #[must_use]
5668    pub fn new(id: RequestId, result: SubscriptionsListenResult) -> Self {
5669        Self {
5670            id,
5671            jsonrpc: Default::default(),
5672            result,
5673        }
5674    }
5675}
5676/// Text provided to or from an LLM.
5677#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5678pub struct TextContent {
5679    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
5680    pub meta: Option<MetaObject>,
5681    /// Optional annotations for the client.
5682    #[serde(
5683        rename = "annotations",
5684        default,
5685        skip_serializing_if = "Option::is_none"
5686    )]
5687    pub annotations: Option<Annotations>,
5688    /// The text content of the message.
5689    #[serde(rename = "text")]
5690    pub text: String,
5691    #[serde(rename = "type")]
5692    pub r#type: TextType,
5693}
5694impl TextContent {
5695    /// Creates a value from its required fields; optional fields are `None`.
5696    #[must_use]
5697    pub fn new(text: String) -> Self {
5698        Self {
5699            meta: None,
5700            annotations: None,
5701            text,
5702            r#type: Default::default(),
5703        }
5704    }
5705}
5706#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5707pub struct TextResourceContents {
5708    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
5709    pub meta: Option<MetaObject>,
5710    /// The MIME type of this resource, if known.
5711    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
5712    pub mime_type: Option<String>,
5713    /// The text of the item. This must only be set if the item can actually be represented as text (not binary data).
5714    #[serde(rename = "text")]
5715    pub text: String,
5716    /// The URI of this resource.
5717    #[serde(rename = "uri")]
5718    pub uri: String,
5719}
5720impl TextResourceContents {
5721    /// Creates a value from its required fields; optional fields are `None`.
5722    #[must_use]
5723    pub fn new(text: String, uri: String) -> Self {
5724        Self {
5725            meta: None,
5726            mime_type: None,
5727            text,
5728            uri,
5729        }
5730    }
5731}
5732/// The constant `"text"`.
5733#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5734pub enum TextType {
5735    /// The constant `"text"`.
5736    #[default]
5737    #[serde(rename = "text")]
5738    Text,
5739}
5740impl TextType {
5741    /// The wire representation of this constant.
5742    pub const VALUE: &'static str = "text";
5743}
5744/// Schema for multiple-selection enumeration with display titles for each option.
5745#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5746pub struct TitledMultiSelectEnumSchema {
5747    /// Optional default value.
5748    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
5749    pub default: Option<Vec<String>>,
5750    /// Optional description for the enum field.
5751    #[serde(
5752        rename = "description",
5753        default,
5754        skip_serializing_if = "Option::is_none"
5755    )]
5756    pub description: Option<String>,
5757    /// Schema for array items with enum options and display labels.
5758    #[serde(rename = "items")]
5759    pub items: TitledMultiSelectEnumSchemaItems,
5760    /// Maximum number of items to select.
5761    #[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")]
5762    pub max_items: Option<i64>,
5763    /// Minimum number of items to select.
5764    #[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")]
5765    pub min_items: Option<i64>,
5766    /// Optional title for the enum field.
5767    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
5768    pub title: Option<String>,
5769    #[serde(rename = "type")]
5770    pub r#type: ArrayType,
5771}
5772impl TitledMultiSelectEnumSchema {
5773    /// Creates a value from its required fields; optional fields are `None`.
5774    #[must_use]
5775    pub fn new(items: TitledMultiSelectEnumSchemaItems) -> Self {
5776        Self {
5777            default: None,
5778            description: None,
5779            items,
5780            max_items: None,
5781            min_items: None,
5782            title: None,
5783            r#type: Default::default(),
5784        }
5785    }
5786}
5787/// Schema for array items with enum options and display labels.
5788#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5789pub struct TitledMultiSelectEnumSchemaItems {
5790    /// Array of enum options with values and display labels.
5791    #[serde(rename = "anyOf")]
5792    pub any_of: Vec<TitledMultiSelectEnumSchemaItemsAnyOfItem>,
5793}
5794impl TitledMultiSelectEnumSchemaItems {
5795    /// Creates a value from its required fields; optional fields are `None`.
5796    #[must_use]
5797    pub fn new(any_of: Vec<TitledMultiSelectEnumSchemaItemsAnyOfItem>) -> Self {
5798        Self { any_of }
5799    }
5800}
5801#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5802pub struct TitledMultiSelectEnumSchemaItemsAnyOfItem {
5803    /// The constant enum value.
5804    #[serde(rename = "const")]
5805    pub r#const: String,
5806    /// Display title for this option.
5807    #[serde(rename = "title")]
5808    pub title: String,
5809}
5810impl TitledMultiSelectEnumSchemaItemsAnyOfItem {
5811    /// Creates a value from its required fields; optional fields are `None`.
5812    #[must_use]
5813    pub fn new(r#const: String, title: String) -> Self {
5814        Self { r#const, title }
5815    }
5816}
5817/// Schema for single-selection enumeration with display titles for each option.
5818#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5819pub struct TitledSingleSelectEnumSchema {
5820    /// Optional default value.
5821    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
5822    pub default: Option<String>,
5823    /// Optional description for the enum field.
5824    #[serde(
5825        rename = "description",
5826        default,
5827        skip_serializing_if = "Option::is_none"
5828    )]
5829    pub description: Option<String>,
5830    /// Array of enum options with values and display labels.
5831    #[serde(rename = "oneOf")]
5832    pub one_of: Vec<TitledSingleSelectEnumSchemaOneOfItem>,
5833    /// Optional title for the enum field.
5834    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
5835    pub title: Option<String>,
5836    #[serde(rename = "type")]
5837    pub r#type: StringType,
5838}
5839impl TitledSingleSelectEnumSchema {
5840    /// Creates a value from its required fields; optional fields are `None`.
5841    #[must_use]
5842    pub fn new(one_of: Vec<TitledSingleSelectEnumSchemaOneOfItem>) -> Self {
5843        Self {
5844            default: None,
5845            description: None,
5846            one_of,
5847            title: None,
5848            r#type: Default::default(),
5849        }
5850    }
5851}
5852#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5853pub struct TitledSingleSelectEnumSchemaOneOfItem {
5854    /// The enum value.
5855    #[serde(rename = "const")]
5856    pub r#const: String,
5857    /// Display label for this option.
5858    #[serde(rename = "title")]
5859    pub title: String,
5860}
5861impl TitledSingleSelectEnumSchemaOneOfItem {
5862    /// Creates a value from its required fields; optional fields are `None`.
5863    #[must_use]
5864    pub fn new(r#const: String, title: String) -> Self {
5865        Self { r#const, title }
5866    }
5867}
5868/// Definition for a tool the client can call.
5869#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5870pub struct Tool {
5871    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
5872    pub meta: Option<MetaObject>,
5873    /// Optional additional tool information.
5874    ///
5875    /// Display name precedence order is: `title`, `annotations.title`, then `name`.
5876    #[serde(
5877        rename = "annotations",
5878        default,
5879        skip_serializing_if = "Option::is_none"
5880    )]
5881    pub annotations: Option<ToolAnnotations>,
5882    /// A human-readable description of the tool.
5883    ///
5884    /// 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.
5885    #[serde(
5886        rename = "description",
5887        default,
5888        skip_serializing_if = "Option::is_none"
5889    )]
5890    pub description: Option<String>,
5891    /// Optional set of sized icons that the client can display in a user interface.
5892    ///
5893    /// Clients that support rendering icons MUST support at least the following MIME types:
5894    /// - `image/png` - PNG images (safe, universal compatibility)
5895    /// - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
5896    ///
5897    /// Clients that support rendering icons SHOULD also support:
5898    /// - `image/svg+xml` - SVG images (scalable but requires security precautions)
5899    /// - `image/webp` - WebP images (modern, efficient format)
5900    #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
5901    pub icons: Option<Vec<Icon>>,
5902    /// A JSON Schema object defining the expected parameters for the tool.
5903    ///
5904    /// Tool arguments are always JSON objects, so `type: "object"` is required at the root.
5905    /// Beyond that, any JSON Schema 2020-12 keyword may appear alongside `type` — including
5906    /// composition keywords (`oneOf`, `anyOf`, `allOf`, `not`), conditional keywords
5907    /// (`if`/`then`/`else`), reference keywords (`$ref`, `$defs`, `$anchor`), and any other
5908    /// standard validation or annotation keywords.
5909    ///
5910    /// Property schemas may carry an `x-mcp-header` annotation to mirror the
5911    /// argument value into an HTTP header on the Streamable HTTP transport. See
5912    /// the Streamable HTTP transport specification for the validity and
5913    /// extraction rules.
5914    ///
5915    /// Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
5916    #[serde(rename = "inputSchema")]
5917    pub input_schema: ToolInputSchema,
5918    /// Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
5919    #[serde(rename = "name")]
5920    pub name: String,
5921    /// An optional JSON Schema object defining the structure of the tool's output returned in
5922    /// the structuredContent field of a `CallToolResult`. This can be any valid JSON Schema 2020-12.
5923    ///
5924    /// Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
5925    #[serde(
5926        rename = "outputSchema",
5927        default,
5928        skip_serializing_if = "Option::is_none"
5929    )]
5930    pub output_schema: Option<ToolOutputSchema>,
5931    /// Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
5932    /// even by those unfamiliar with domain-specific terminology.
5933    ///
5934    /// If not provided, the name should be used for display (except for `Tool`,
5935    /// where `annotations.title` should be given precedence over using `name`,
5936    /// if present).
5937    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
5938    pub title: Option<String>,
5939}
5940impl Tool {
5941    /// Creates a value from its required fields; optional fields are `None`.
5942    #[must_use]
5943    pub fn new(input_schema: ToolInputSchema, name: String) -> Self {
5944        Self {
5945            meta: None,
5946            annotations: None,
5947            description: None,
5948            icons: None,
5949            input_schema,
5950            name,
5951            output_schema: None,
5952            title: None,
5953        }
5954    }
5955}
5956/// Additional properties describing a `Tool` to clients.
5957///
5958/// NOTE: all properties in `ToolAnnotations` are **hints**.
5959/// They are not guaranteed to provide a faithful description of
5960/// tool behavior (including descriptive properties like `title`).
5961///
5962/// Clients should never make tool use decisions based on `ToolAnnotations`
5963/// received from untrusted servers.
5964#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5965pub struct ToolAnnotations {
5966    /// If true, the tool may perform destructive updates to its environment.
5967    /// If false, the tool performs only additive updates.
5968    ///
5969    /// (This property is meaningful only when `readOnlyHint == false`)
5970    ///
5971    /// Default: true
5972    #[serde(
5973        rename = "destructiveHint",
5974        default,
5975        skip_serializing_if = "Option::is_none"
5976    )]
5977    pub destructive_hint: Option<bool>,
5978    /// If true, calling the tool repeatedly with the same arguments
5979    /// will have no additional effect on its environment.
5980    ///
5981    /// (This property is meaningful only when `readOnlyHint == false`)
5982    ///
5983    /// Default: false
5984    #[serde(
5985        rename = "idempotentHint",
5986        default,
5987        skip_serializing_if = "Option::is_none"
5988    )]
5989    pub idempotent_hint: Option<bool>,
5990    /// If true, this tool may interact with an "open world" of external
5991    /// entities. If false, the tool's domain of interaction is closed.
5992    /// For example, the world of a web search tool is open, whereas that
5993    /// of a memory tool is not.
5994    ///
5995    /// Default: true
5996    #[serde(
5997        rename = "openWorldHint",
5998        default,
5999        skip_serializing_if = "Option::is_none"
6000    )]
6001    pub open_world_hint: Option<bool>,
6002    /// If true, the tool does not modify its environment.
6003    ///
6004    /// Default: false
6005    #[serde(
6006        rename = "readOnlyHint",
6007        default,
6008        skip_serializing_if = "Option::is_none"
6009    )]
6010    pub read_only_hint: Option<bool>,
6011    /// A human-readable title for the tool.
6012    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
6013    pub title: Option<String>,
6014}
6015/// Controls tool selection behavior for sampling requests.
6016#[deprecated(
6017    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
6018)]
6019#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
6020pub struct ToolChoice {
6021    /// Controls the tool use ability of the model:
6022    /// - `"auto"`: Model decides whether to use tools (default)
6023    /// - `"required"`: Model MUST use at least one tool before completing
6024    /// - `"none"`: Model MUST NOT use any tools
6025    #[serde(rename = "mode", default, skip_serializing_if = "Option::is_none")]
6026    pub mode: Option<ToolChoiceMode>,
6027}
6028/// Controls the tool use ability of the model:
6029/// - `"auto"`: Model decides whether to use tools (default)
6030/// - `"required"`: Model MUST use at least one tool before completing
6031/// - `"none"`: Model MUST NOT use any tools
6032#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6033pub enum ToolChoiceMode {
6034    /// `"auto"`
6035    #[serde(rename = "auto")]
6036    Auto,
6037    /// `"none"`
6038    #[serde(rename = "none")]
6039    None,
6040    /// `"required"`
6041    #[serde(rename = "required")]
6042    Required,
6043}
6044impl ToolChoiceMode {
6045    /// The wire representation of this value.
6046    #[must_use]
6047    pub const fn as_str(self) -> &'static str {
6048        match self {
6049            Self::Auto => "auto",
6050            Self::None => "none",
6051            Self::Required => "required",
6052        }
6053    }
6054}
6055/// A JSON Schema object defining the expected parameters for the tool.
6056///
6057/// Tool arguments are always JSON objects, so `type: "object"` is required at the root.
6058/// Beyond that, any JSON Schema 2020-12 keyword may appear alongside `type` — including
6059/// composition keywords (`oneOf`, `anyOf`, `allOf`, `not`), conditional keywords
6060/// (`if`/`then`/`else`), reference keywords (`$ref`, `$defs`, `$anchor`), and any other
6061/// standard validation or annotation keywords.
6062///
6063/// Property schemas may carry an `x-mcp-header` annotation to mirror the
6064/// argument value into an HTTP header on the Streamable HTTP transport. See
6065/// the Streamable HTTP transport specification for the validity and
6066/// extraction rules.
6067///
6068/// Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
6069#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
6070pub struct ToolInputSchema {
6071    #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
6072    pub schema: Option<String>,
6073    #[serde(rename = "type")]
6074    pub r#type: ObjectType,
6075    /// Additional properties not described by the schema.
6076    #[serde(flatten)]
6077    pub extra: serde_json::Map<String, serde_json::Value>,
6078}
6079/// An optional notification from the server to the client, informing it that the list of tools it offers has changed. This is only delivered on a `SubscriptionsListenRequestsubscriptions/listen` stream when the client requested it via the `toolsListChanged` filter field.
6080#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
6081pub struct ToolListChangedNotification {
6082    #[serde(rename = "jsonrpc")]
6083    pub jsonrpc: JsonRpcVersion,
6084    #[serde(rename = "method")]
6085    pub method: NotificationsToolsListChangedMethod,
6086    #[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
6087    pub params: Option<NotificationParams>,
6088}
6089/// An optional JSON Schema object defining the structure of the tool's output returned in
6090/// the structuredContent field of a `CallToolResult`. This can be any valid JSON Schema 2020-12.
6091///
6092/// Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
6093#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
6094pub struct ToolOutputSchema {
6095    #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
6096    pub schema: Option<String>,
6097    /// Additional properties not described by the schema.
6098    #[serde(flatten)]
6099    pub extra: serde_json::Map<String, serde_json::Value>,
6100}
6101/// The result of a tool use, provided by the user back to the assistant.
6102#[deprecated(
6103    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
6104)]
6105#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6106pub struct ToolResultContent {
6107    /// Optional metadata about the tool result. Clients SHOULD preserve this field when
6108    /// including tool results in subsequent sampling requests to enable caching optimizations.
6109    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
6110    pub meta: Option<MetaObject>,
6111    /// The unstructured result content of the tool use.
6112    ///
6113    /// This has the same format as `CallToolResult.content` and can include text, images,
6114    /// audio, resource links, and embedded resources.
6115    #[serde(rename = "content")]
6116    pub content: Vec<ContentBlock>,
6117    /// Whether the tool use resulted in an error.
6118    ///
6119    /// If true, the content typically describes the error that occurred.
6120    /// Default: false
6121    #[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")]
6122    pub is_error: Option<bool>,
6123    /// An optional structured result value.
6124    ///
6125    /// This can be any JSON value (object, array, string, number, boolean, or null).
6126    /// If the tool defined an `Tool.outputSchema`, this SHOULD conform to that schema.
6127    #[serde(
6128        rename = "structuredContent",
6129        default,
6130        skip_serializing_if = "Option::is_none"
6131    )]
6132    pub structured_content: Option<serde_json::Value>,
6133    /// The ID of the tool use this result corresponds to.
6134    ///
6135    /// This MUST match the ID from a previous `ToolUseContent`.
6136    #[serde(rename = "toolUseId")]
6137    pub tool_use_id: String,
6138    #[serde(rename = "type")]
6139    pub r#type: ToolResultType,
6140}
6141impl ToolResultContent {
6142    /// Creates a value from its required fields; optional fields are `None`.
6143    #[must_use]
6144    pub fn new(content: Vec<ContentBlock>, tool_use_id: String) -> Self {
6145        Self {
6146            meta: None,
6147            content,
6148            is_error: None,
6149            structured_content: None,
6150            tool_use_id,
6151            r#type: Default::default(),
6152        }
6153    }
6154}
6155/// The constant `"tool_result"`.
6156#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6157pub enum ToolResultType {
6158    /// The constant `"tool_result"`.
6159    #[default]
6160    #[serde(rename = "tool_result")]
6161    ToolResult,
6162}
6163impl ToolResultType {
6164    /// The wire representation of this constant.
6165    pub const VALUE: &'static str = "tool_result";
6166}
6167/// A request from the assistant to call a tool.
6168#[deprecated(
6169    note = "Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains in the specification for at least twelve months; see the deprecated features registry."
6170)]
6171#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6172pub struct ToolUseContent {
6173    /// Optional metadata about the tool use. Clients SHOULD preserve this field when
6174    /// including tool uses in subsequent sampling requests to enable caching optimizations.
6175    #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
6176    pub meta: Option<MetaObject>,
6177    /// A unique identifier for this tool use.
6178    ///
6179    /// This ID is used to match tool results to their corresponding tool uses.
6180    #[serde(rename = "id")]
6181    pub id: String,
6182    /// The arguments to pass to the tool, conforming to the tool's input schema.
6183    #[serde(rename = "input")]
6184    pub input: serde_json::Map<String, serde_json::Value>,
6185    /// The name of the tool to call.
6186    #[serde(rename = "name")]
6187    pub name: String,
6188    #[serde(rename = "type")]
6189    pub r#type: ToolUseType,
6190}
6191impl ToolUseContent {
6192    /// Creates a value from its required fields; optional fields are `None`.
6193    #[must_use]
6194    pub fn new(
6195        id: String,
6196        input: serde_json::Map<String, serde_json::Value>,
6197        name: String,
6198    ) -> Self {
6199        Self {
6200            meta: None,
6201            id,
6202            input,
6203            name,
6204            r#type: Default::default(),
6205        }
6206    }
6207}
6208/// The constant `"tool_use"`.
6209#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6210pub enum ToolUseType {
6211    /// The constant `"tool_use"`.
6212    #[default]
6213    #[serde(rename = "tool_use")]
6214    ToolUse,
6215}
6216impl ToolUseType {
6217    /// The wire representation of this constant.
6218    pub const VALUE: &'static str = "tool_use";
6219}
6220/// The constant `"tools/call"`.
6221#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6222pub enum ToolsCallMethod {
6223    /// The constant `"tools/call"`.
6224    #[default]
6225    #[serde(rename = "tools/call")]
6226    ToolsCall,
6227}
6228impl ToolsCallMethod {
6229    /// The wire representation of this constant.
6230    pub const VALUE: &'static str = "tools/call";
6231}
6232/// The constant `"tools/list"`.
6233#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6234pub enum ToolsListMethod {
6235    /// The constant `"tools/list"`.
6236    #[default]
6237    #[serde(rename = "tools/list")]
6238    ToolsList,
6239}
6240impl ToolsListMethod {
6241    /// The wire representation of this constant.
6242    pub const VALUE: &'static str = "tools/list";
6243}
6244/// Returned when the request's protocol version is unknown to the server or
6245/// unsupported (e.g., a known experimental or draft version the server has
6246/// chosen not to implement). For HTTP, the response status code MUST be
6247/// `400 Bad Request`.
6248#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6249pub struct UnsupportedProtocolVersionError {
6250    #[serde(rename = "error")]
6251    pub error: UnsupportedProtocolVersionErrorObject,
6252    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
6253    pub id: Option<RequestId>,
6254    #[serde(rename = "jsonrpc")]
6255    pub jsonrpc: JsonRpcVersion,
6256}
6257impl UnsupportedProtocolVersionError {
6258    /// Creates a value from its required fields; optional fields are `None`.
6259    #[must_use]
6260    pub fn new(error: UnsupportedProtocolVersionErrorObject) -> Self {
6261        Self {
6262            error,
6263            id: None,
6264            jsonrpc: Default::default(),
6265        }
6266    }
6267}
6268#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6269pub struct UnsupportedProtocolVersionErrorData {
6270    /// The protocol version that was requested by the client.
6271    #[serde(rename = "requested")]
6272    pub requested: String,
6273    /// Protocol versions the server supports. The client should choose a
6274    /// mutually supported version from this list and retry.
6275    #[serde(rename = "supported")]
6276    pub supported: Vec<String>,
6277}
6278impl UnsupportedProtocolVersionErrorData {
6279    /// Creates a value from its required fields; optional fields are `None`.
6280    #[must_use]
6281    pub fn new(requested: String, supported: Vec<String>) -> Self {
6282        Self {
6283            requested,
6284            supported,
6285        }
6286    }
6287}
6288#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6289pub struct UnsupportedProtocolVersionErrorObject {
6290    #[serde(rename = "code")]
6291    pub code: i64,
6292    #[serde(rename = "data")]
6293    pub data: UnsupportedProtocolVersionErrorData,
6294    /// A short description of the error. The message SHOULD be limited to a concise single sentence.
6295    #[serde(rename = "message")]
6296    pub message: String,
6297}
6298impl UnsupportedProtocolVersionErrorObject {
6299    /// Creates a value from its required fields; optional fields are `None`.
6300    #[must_use]
6301    pub fn new(code: i64, data: UnsupportedProtocolVersionErrorData, message: String) -> Self {
6302        Self {
6303            code,
6304            data,
6305            message,
6306        }
6307    }
6308}
6309/// Schema for multiple-selection enumeration without display titles for options.
6310#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6311pub struct UntitledMultiSelectEnumSchema {
6312    /// Optional default value.
6313    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
6314    pub default: Option<Vec<String>>,
6315    /// Optional description for the enum field.
6316    #[serde(
6317        rename = "description",
6318        default,
6319        skip_serializing_if = "Option::is_none"
6320    )]
6321    pub description: Option<String>,
6322    /// Schema for the array items.
6323    #[serde(rename = "items")]
6324    pub items: UntitledMultiSelectEnumSchemaItems,
6325    /// Maximum number of items to select.
6326    #[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")]
6327    pub max_items: Option<i64>,
6328    /// Minimum number of items to select.
6329    #[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")]
6330    pub min_items: Option<i64>,
6331    /// Optional title for the enum field.
6332    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
6333    pub title: Option<String>,
6334    #[serde(rename = "type")]
6335    pub r#type: ArrayType,
6336}
6337impl UntitledMultiSelectEnumSchema {
6338    /// Creates a value from its required fields; optional fields are `None`.
6339    #[must_use]
6340    pub fn new(items: UntitledMultiSelectEnumSchemaItems) -> Self {
6341        Self {
6342            default: None,
6343            description: None,
6344            items,
6345            max_items: None,
6346            min_items: None,
6347            title: None,
6348            r#type: Default::default(),
6349        }
6350    }
6351}
6352/// Schema for the array items.
6353#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6354pub struct UntitledMultiSelectEnumSchemaItems {
6355    /// Array of enum values to choose from.
6356    #[serde(rename = "enum")]
6357    pub r#enum: Vec<String>,
6358    #[serde(rename = "type")]
6359    pub r#type: StringType,
6360}
6361impl UntitledMultiSelectEnumSchemaItems {
6362    /// Creates a value from its required fields; optional fields are `None`.
6363    #[must_use]
6364    pub fn new(r#enum: Vec<String>) -> Self {
6365        Self {
6366            r#enum,
6367            r#type: Default::default(),
6368        }
6369    }
6370}
6371/// Schema for single-selection enumeration without display titles for options.
6372#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6373pub struct UntitledSingleSelectEnumSchema {
6374    /// Optional default value.
6375    #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
6376    pub default: Option<String>,
6377    /// Optional description for the enum field.
6378    #[serde(
6379        rename = "description",
6380        default,
6381        skip_serializing_if = "Option::is_none"
6382    )]
6383    pub description: Option<String>,
6384    /// Array of enum values to choose from.
6385    #[serde(rename = "enum")]
6386    pub r#enum: Vec<String>,
6387    /// Optional title for the enum field.
6388    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
6389    pub title: Option<String>,
6390    #[serde(rename = "type")]
6391    pub r#type: StringType,
6392}
6393impl UntitledSingleSelectEnumSchema {
6394    /// Creates a value from its required fields; optional fields are `None`.
6395    #[must_use]
6396    pub fn new(r#enum: Vec<String>) -> Self {
6397        Self {
6398            default: None,
6399            description: None,
6400            r#enum,
6401            title: None,
6402            r#type: Default::default(),
6403        }
6404    }
6405}
6406/// The constant `"url"`.
6407#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6408pub enum UrlMode {
6409    /// The constant `"url"`.
6410    #[default]
6411    #[serde(rename = "url")]
6412    Url,
6413}
6414impl UrlMode {
6415    /// The wire representation of this constant.
6416    pub const VALUE: &'static str = "url";
6417}