1use serde::{Deserialize, Serialize};
8pub const PROTOCOL_VERSION: &str = "2026-07-28";
10pub mod error_codes {
12 pub const HEADER_MISMATCH_ERROR: i64 = -32020i64;
14 pub const INTERNAL_ERROR: i64 = -32603i64;
16 pub const INVALID_PARAMS_ERROR: i64 = -32602i64;
18 pub const INVALID_REQUEST_ERROR: i64 = -32600i64;
20 pub const METHOD_NOT_FOUND_ERROR: i64 = -32601i64;
22 pub const MISSING_REQUIRED_CLIENT_CAPABILITY_ERROR: i64 = -32021i64;
24 pub const PARSE_ERROR: i64 = -32700i64;
26 pub const UNSUPPORTED_PROTOCOL_VERSION_ERROR: i64 = -32022i64;
28}
29pub mod methods {
31 pub const COMPLETION_COMPLETE: &str = "completion/complete";
33 pub const ELICITATION_CREATE: &str = "elicitation/create";
35 pub const NOTIFICATIONS_CANCELLED: &str = "notifications/cancelled";
37 pub const NOTIFICATIONS_MESSAGE: &str = "notifications/message";
39 pub const NOTIFICATIONS_PROGRESS: &str = "notifications/progress";
41 pub const NOTIFICATIONS_PROMPTS_LIST_CHANGED: &str = "notifications/prompts/list_changed";
43 pub const NOTIFICATIONS_RESOURCES_LIST_CHANGED: &str = "notifications/resources/list_changed";
45 pub const NOTIFICATIONS_RESOURCES_UPDATED: &str = "notifications/resources/updated";
47 pub const NOTIFICATIONS_SUBSCRIPTIONS_ACKNOWLEDGED: &str =
49 "notifications/subscriptions/acknowledged";
50 pub const NOTIFICATIONS_TOOLS_LIST_CHANGED: &str = "notifications/tools/list_changed";
52 pub const PROMPTS_GET: &str = "prompts/get";
54 pub const PROMPTS_LIST: &str = "prompts/list";
56 pub const RESOURCES_LIST: &str = "resources/list";
58 pub const RESOURCES_READ: &str = "resources/read";
60 pub const RESOURCES_TEMPLATES_LIST: &str = "resources/templates/list";
62 pub const ROOTS_LIST: &str = "roots/list";
64 pub const SAMPLING_CREATE_MESSAGE: &str = "sampling/createMessage";
66 pub const SERVER_DISCOVER: &str = "server/discover";
68 pub const SUBSCRIPTIONS_LISTEN: &str = "subscriptions/listen";
70 pub const TOOLS_CALL: &str = "tools/call";
72 pub const TOOLS_LIST: &str = "tools/list";
74}
75#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
77pub struct Annotations {
78 #[serde(rename = "audience", default, skip_serializing_if = "Option::is_none")]
82 pub audience: Option<Vec<Role>>,
83 #[serde(
90 rename = "lastModified",
91 default,
92 skip_serializing_if = "Option::is_none"
93 )]
94 pub last_modified: Option<String>,
95 #[serde(rename = "priority", default, skip_serializing_if = "Option::is_none")]
101 pub priority: Option<f64>,
102}
103#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
105pub enum ArrayType {
106 #[default]
108 #[serde(rename = "array")]
109 Array,
110}
111impl ArrayType {
112 pub const VALUE: &'static str = "array";
114}
115#[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 #[serde(
122 rename = "annotations",
123 default,
124 skip_serializing_if = "Option::is_none"
125 )]
126 pub annotations: Option<Annotations>,
127 #[serde(rename = "data")]
129 pub data: String,
130 #[serde(rename = "mimeType")]
132 pub mime_type: String,
133 #[serde(rename = "type")]
134 pub r#type: AudioType,
135}
136impl AudioContent {
137 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
151pub enum AudioType {
152 #[default]
154 #[serde(rename = "audio")]
155 Audio,
156}
157impl AudioType {
158 pub const VALUE: &'static str = "audio";
160}
161#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
163pub struct BaseMetadata {
164 #[serde(rename = "name")]
166 pub name: String,
167 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
174 pub title: Option<String>,
175}
176impl BaseMetadata {
177 #[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 #[serde(rename = "blob")]
189 pub blob: String,
190 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
192 pub mime_type: Option<String>,
193 #[serde(rename = "uri")]
195 pub uri: String,
196}
197impl BlobResourceContents {
198 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
226pub enum BooleanType {
227 #[default]
229 #[serde(rename = "boolean")]
230 Boolean,
231}
232impl BooleanType {
233 pub const VALUE: &'static str = "boolean";
235}
236#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
247pub enum CacheScope {
248 #[serde(rename = "private")]
250 Private,
251 #[serde(rename = "public")]
253 Public,
254}
255impl CacheScope {
256 #[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#[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 #[serde(rename = "cacheScope")]
281 pub cache_scope: CacheScope,
282 #[serde(rename = "resultType")]
290 pub result_type: String,
291 #[serde(rename = "ttlMs")]
300 pub ttl_ms: u64,
301}
302impl CacheableResult {
303 #[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#[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
340pub struct CallToolRequestParams {
341 #[serde(rename = "_meta")]
342 pub meta: RequestMetaObject,
343 #[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 #[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 #[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#[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 #[serde(rename = "content")]
382 pub content: Vec<ContentBlock>,
383 #[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")]
396 pub is_error: Option<bool>,
397 #[serde(rename = "resultType")]
405 pub result_type: String,
406 #[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 #[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#[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 #[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 InputRequired(InputRequiredResult),
456 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#[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 #[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#[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 #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
523 pub reason: Option<String>,
524 #[serde(rename = "requestId")]
528 pub request_id: RequestId,
529}
530impl CancelledNotificationParams {
531 #[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#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
543pub struct ClientCapabilities {
544 #[serde(
546 rename = "elicitation",
547 default,
548 skip_serializing_if = "Option::is_none"
549 )]
550 pub elicitation: Option<ClientCapabilitiesElicitation>,
551 #[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 #[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 #[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 #[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#[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#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
595pub struct ClientCapabilitiesRoots {}
596#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
598pub struct ClientCapabilitiesSampling {
599 #[serde(rename = "context", default, skip_serializing_if = "Option::is_none")]
602 pub context: Option<serde_json::Map<String, serde_json::Value>>,
603 #[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
605 pub tools: Option<serde_json::Map<String, serde_json::Value>>,
606}
607#[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 #[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 Discover(DiscoverRequest),
639 ListResources(ListResourcesRequest),
641 ListResourceTemplates(ListResourceTemplatesRequest),
643 ReadResource(ReadResourceRequest),
645 SubscriptionsListen(SubscriptionsListenRequest),
647 ListPrompts(ListPromptsRequest),
649 GetPrompt(GetPromptRequest),
651 ListTools(ListToolsRequest),
653 CallTool(CallToolRequest),
655 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#[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
794pub struct CompleteRequestParams {
795 #[serde(rename = "_meta")]
796 pub meta: RequestMetaObject,
797 #[serde(rename = "argument")]
799 pub argument: CompleteRequestParamsArgument,
800 #[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
824pub struct CompleteRequestParamsArgument {
825 #[serde(rename = "name")]
827 pub name: String,
828 #[serde(rename = "value")]
830 pub value: String,
831}
832impl CompleteRequestParamsArgument {
833 #[must_use]
835 pub fn new(name: String, value: String) -> Self {
836 Self { name, value }
837 }
838}
839#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
841pub struct CompleteRequestParamsContext {
842 #[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 Prompt(PromptReference),
851 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#[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 #[serde(rename = "resultType")]
904 pub result_type: String,
905}
906impl CompleteResult {
907 #[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 #[serde(rename = "hasMore", default, skip_serializing_if = "Option::is_none")]
921 pub has_more: Option<bool>,
922 #[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
924 pub total: Option<i64>,
925 #[serde(rename = "values")]
927 pub values: Vec<String>,
928}
929impl CompleteResultCompletion {
930 #[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#[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 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
963pub enum CompletionCompleteMethod {
964 #[default]
966 #[serde(rename = "completion/complete")]
967 CompletionComplete,
968}
969impl CompletionCompleteMethod {
970 pub const VALUE: &'static str = "completion/complete";
972}
973#[derive(Debug, Clone, PartialEq, Serialize)]
974#[serde(untagged)]
975pub enum ContentBlock {
976 TextContent(TextContent),
978 ImageContent(ImageContent),
980 AudioContent(AudioContent),
982 ResourceLink(ResourceLink),
984 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#[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 #[must_use]
1060 pub fn new(params: CreateMessageRequestParams) -> Self {
1061 Self {
1062 method: Default::default(),
1063 params,
1064 }
1065 }
1066}
1067#[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 #[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 #[serde(rename = "maxTokens")]
1092 pub max_tokens: i64,
1093 #[serde(rename = "messages")]
1094 pub messages: Vec<SamplingMessage>,
1095 #[serde(rename = "metadata", default, skip_serializing_if = "Option::is_none")]
1097 pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
1098 #[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 #[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 #[serde(
1128 rename = "toolChoice",
1129 default,
1130 skip_serializing_if = "Option::is_none"
1131 )]
1132 pub tool_choice: Option<ToolChoice>,
1133 #[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
1136 pub tools: Option<Vec<Tool>>,
1137}
1138impl CreateMessageRequestParams {
1139 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1163pub enum CreateMessageRequestParamsIncludeContext {
1164 #[serde(rename = "allServers")]
1166 AllServers,
1167 #[serde(rename = "none")]
1169 None,
1170 #[serde(rename = "thisServer")]
1172 ThisServer,
1173}
1174impl CreateMessageRequestParamsIncludeContext {
1175 #[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#[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 #[serde(rename = "model")]
1199 pub model: String,
1200 #[serde(rename = "role")]
1201 pub role: Role,
1202 #[serde(
1212 rename = "stopReason",
1213 default,
1214 skip_serializing_if = "Option::is_none"
1215 )]
1216 pub stop_reason: Option<String>,
1217}
1218impl CreateMessageResult {
1219 #[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 TextContent(TextContent),
1236 ImageContent(ImageContent),
1238 AudioContent(AudioContent),
1240 ToolUseContent(ToolUseContent),
1242 ToolResultContent(ToolResultContent),
1244 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}
1277pub type Cursor = String;
1279#[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 #[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#[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 #[serde(rename = "cacheScope")]
1322 pub cache_scope: CacheScope,
1323 #[serde(rename = "capabilities")]
1325 pub capabilities: ServerCapabilities,
1326 #[serde(
1333 rename = "instructions",
1334 default,
1335 skip_serializing_if = "Option::is_none"
1336 )]
1337 pub instructions: Option<String>,
1338 #[serde(rename = "resultType")]
1346 pub result_type: String,
1347 #[serde(rename = "supportedVersions")]
1350 pub supported_versions: Vec<String>,
1351 #[serde(rename = "ttlMs")]
1360 pub ttl_ms: u64,
1361}
1362impl DiscoverResult {
1363 #[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#[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 #[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#[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 #[must_use]
1415 pub fn new(params: ElicitRequestParams) -> Self {
1416 Self {
1417 method: Default::default(),
1418 params,
1419 }
1420 }
1421}
1422#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1424pub struct ElicitRequestFormParams {
1425 #[serde(rename = "message")]
1427 pub message: String,
1428 #[serde(rename = "mode", default, skip_serializing_if = "Option::is_none")]
1430 pub mode: Option<FormMode>,
1431 #[serde(rename = "requestedSchema")]
1434 pub requested_schema: ElicitRequestFormParamsRequestedSchema,
1435}
1436impl ElicitRequestFormParams {
1437 #[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#[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 #[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#[derive(Debug, Clone, PartialEq, Serialize)]
1474#[serde(untagged)]
1475pub enum ElicitRequestParams {
1476 ElicitRequestForm(ElicitRequestFormParams),
1478 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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1517pub struct ElicitRequestUrlParams {
1518 #[serde(rename = "message")]
1520 pub message: String,
1521 #[serde(rename = "mode")]
1523 pub mode: UrlMode,
1524 #[serde(rename = "url")]
1526 pub url: String,
1527}
1528impl ElicitRequestUrlParams {
1529 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1541pub struct ElicitResult {
1542 #[serde(rename = "action")]
1547 pub action: ElicitResultAction,
1548 #[serde(rename = "content", default, skip_serializing_if = "Option::is_none")]
1552 pub content: Option<std::collections::BTreeMap<String, ElicitResultContentValue>>,
1553}
1554impl ElicitResult {
1555 #[must_use]
1557 pub fn new(action: ElicitResultAction) -> Self {
1558 Self {
1559 action,
1560 content: None,
1561 }
1562 }
1563}
1564#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
1569pub enum ElicitResultAction {
1570 #[serde(rename = "accept")]
1572 Accept,
1573 #[serde(rename = "cancel")]
1575 Cancel,
1576 #[serde(rename = "decline")]
1578 Decline,
1579}
1580impl ElicitResultAction {
1581 #[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 List(Vec<String>),
1596 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 String(String),
1614 Integer(i64),
1616 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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
1699pub enum ElicitationCreateMethod {
1700 #[default]
1702 #[serde(rename = "elicitation/create")]
1703 ElicitationCreate,
1704}
1705impl ElicitationCreateMethod {
1706 pub const VALUE: &'static str = "elicitation/create";
1708}
1709#[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 #[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 #[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 Text(TextResourceContents),
1746 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}
1759pub type EmptyResult = Result;
1761#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1762#[serde(untagged)]
1763pub enum EnumSchema {
1764 UntitledSingleSelect(UntitledSingleSelectEnumSchema),
1766 TitledSingleSelect(TitledSingleSelectEnumSchema),
1768 UntitledMultiSelect(UntitledMultiSelectEnumSchema),
1770 TitledMultiSelect(TitledMultiSelectEnumSchema),
1772 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 #[serde(rename = "code")]
1804 pub code: i64,
1805 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
1807 pub data: Option<serde_json::Value>,
1808 #[serde(rename = "message")]
1810 pub message: String,
1811}
1812impl Error {
1813 #[must_use]
1815 pub fn new(code: i64, message: String) -> Self {
1816 Self {
1817 code,
1818 data: None,
1819 message,
1820 }
1821 }
1822}
1823#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
1825pub enum FormMode {
1826 #[default]
1828 #[serde(rename = "form")]
1829 Form,
1830}
1831impl FormMode {
1832 pub const VALUE: &'static str = "form";
1834}
1835#[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1861pub struct GetPromptRequestParams {
1862 #[serde(rename = "_meta")]
1863 pub meta: RequestMetaObject,
1864 #[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 #[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 #[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#[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 #[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 #[serde(rename = "resultType")]
1918 pub result_type: String,
1919}
1920impl GetPromptResult {
1921 #[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#[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 #[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 InputRequired(InputRequiredResult),
1958 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#[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 #[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 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2021 pub data: Option<serde_json::Value>,
2022 #[serde(rename = "message")]
2024 pub message: String,
2025}
2026impl HeaderMismatchErrorObject {
2027 #[must_use]
2029 pub fn new(code: i64, message: String) -> Self {
2030 Self {
2031 code,
2032 data: None,
2033 message,
2034 }
2035 }
2036}
2037#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2039pub struct Icon {
2040 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
2043 pub mime_type: Option<String>,
2044 #[serde(rename = "sizes", default, skip_serializing_if = "Option::is_none")]
2049 pub sizes: Option<Vec<String>>,
2050 #[serde(rename = "src")]
2059 pub src: String,
2060 #[serde(rename = "theme", default, skip_serializing_if = "Option::is_none")]
2066 pub theme: Option<IconTheme>,
2067}
2068impl Icon {
2069 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
2086pub enum IconTheme {
2087 #[serde(rename = "dark")]
2089 Dark,
2090 #[serde(rename = "light")]
2092 Light,
2093}
2094impl IconTheme {
2095 #[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#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
2106pub struct Icons {
2107 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
2117 pub icons: Option<Vec<Icon>>,
2118}
2119#[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 #[serde(
2126 rename = "annotations",
2127 default,
2128 skip_serializing_if = "Option::is_none"
2129 )]
2130 pub annotations: Option<Annotations>,
2131 #[serde(rename = "data")]
2133 pub data: String,
2134 #[serde(rename = "mimeType")]
2136 pub mime_type: String,
2137 #[serde(rename = "type")]
2138 pub r#type: ImageType,
2139}
2140impl ImageContent {
2141 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
2155pub enum ImageType {
2156 #[default]
2158 #[serde(rename = "image")]
2159 Image,
2160}
2161impl ImageType {
2162 pub const VALUE: &'static str = "image";
2164}
2165#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2167pub struct Implementation {
2168 #[serde(
2174 rename = "description",
2175 default,
2176 skip_serializing_if = "Option::is_none"
2177 )]
2178 pub description: Option<String>,
2179 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
2189 pub icons: Option<Vec<Icon>>,
2190 #[serde(rename = "name")]
2192 pub name: String,
2193 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
2200 pub title: Option<String>,
2201 #[serde(rename = "version")]
2203 pub version: String,
2204 #[serde(
2206 rename = "websiteUrl",
2207 default,
2208 skip_serializing_if = "Option::is_none"
2209 )]
2210 pub website_url: Option<String>,
2211}
2212impl Implementation {
2213 #[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 CreateMessage(CreateMessageRequest),
2231 ListRoots(ListRootsRequest),
2233 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}
2279pub type InputRequests = std::collections::BTreeMap<String, InputRequest>;
2282#[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 #[serde(rename = "resultType")]
2310 pub result_type: String,
2311}
2312impl InputRequiredResult {
2313 #[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 CreateMessage(CreateMessageResult),
2329 ListRoots(ListRootsResult),
2331 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 #[must_use]
2369 pub fn new(meta: RequestMetaObject) -> Self {
2370 Self {
2371 meta,
2372 input_responses: None,
2373 request_state: None,
2374 }
2375 }
2376}
2377pub type InputResponses = std::collections::BTreeMap<String, InputResponse>;
2381#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2383pub struct InternalError {
2384 #[serde(rename = "code")]
2386 pub code: i64,
2387 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2389 pub data: Option<serde_json::Value>,
2390 #[serde(rename = "message")]
2392 pub message: String,
2393}
2394impl InternalError {
2395 #[must_use]
2397 pub fn new(code: i64, message: String) -> Self {
2398 Self {
2399 code,
2400 data: None,
2401 message,
2402 }
2403 }
2404}
2405#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2416pub struct InvalidParamsError {
2417 #[serde(rename = "code")]
2419 pub code: i64,
2420 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2422 pub data: Option<serde_json::Value>,
2423 #[serde(rename = "message")]
2425 pub message: String,
2426}
2427impl InvalidParamsError {
2428 #[must_use]
2430 pub fn new(code: i64, message: String) -> Self {
2431 Self {
2432 code,
2433 data: None,
2434 message,
2435 }
2436 }
2437}
2438#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2440pub struct InvalidRequestError {
2441 #[serde(rename = "code")]
2443 pub code: i64,
2444 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
2446 pub data: Option<serde_json::Value>,
2447 #[serde(rename = "message")]
2449 pub message: String,
2450}
2451impl InvalidRequestError {
2452 #[must_use]
2454 pub fn new(code: i64, message: String) -> Self {
2455 Self {
2456 code,
2457 data: None,
2458 message,
2459 }
2460 }
2461}
2462#[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 #[must_use]
2475 pub fn new(error: Error) -> Self {
2476 Self {
2477 error,
2478 id: None,
2479 jsonrpc: Default::default(),
2480 }
2481 }
2482}
2483#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2485#[serde(untagged)]
2486pub enum JsonRpcMessage {
2487 JsonRpcRequest(JsonRpcRequest),
2489 JsonRpcNotification(JsonRpcNotification),
2491 JsonRpcResultResponse(JsonRpcResultResponse),
2493 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#[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 #[must_use]
2529 pub fn new(method: String) -> Self {
2530 Self {
2531 jsonrpc: Default::default(),
2532 method,
2533 params: None,
2534 }
2535 }
2536}
2537#[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2563#[serde(untagged)]
2564pub enum JsonRpcResponse {
2565 JsonRpcResult(JsonRpcResultResponse),
2567 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#[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 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
2603pub enum JsonRpcVersion {
2604 #[default]
2606 #[serde(rename = "2.0")]
2607 V20,
2608}
2609impl JsonRpcVersion {
2610 pub const VALUE: &'static str = "2.0";
2612}
2613#[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 #[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 #[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#[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 #[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#[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 #[serde(rename = "cacheScope")]
2690 pub cache_scope: CacheScope,
2691 #[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 #[serde(rename = "resultType")]
2709 pub result_type: String,
2710 #[serde(rename = "ttlMs")]
2719 pub ttl_ms: u64,
2720}
2721impl ListPromptsResult {
2722 #[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#[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 #[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#[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 #[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#[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 #[serde(rename = "cacheScope")]
2801 pub cache_scope: CacheScope,
2802 #[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 #[serde(rename = "resultType")]
2820 pub result_type: String,
2821 #[serde(rename = "ttlMs")]
2830 pub ttl_ms: u64,
2831}
2832impl ListResourceTemplatesResult {
2833 #[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#[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 #[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#[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 #[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#[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 #[serde(rename = "cacheScope")]
2912 pub cache_scope: CacheScope,
2913 #[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 #[serde(rename = "resultType")]
2931 pub result_type: String,
2932 #[serde(rename = "ttlMs")]
2941 pub ttl_ms: u64,
2942}
2943impl ListResourcesResult {
2944 #[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#[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 #[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#[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#[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 #[must_use]
3019 pub fn new(roots: Vec<Root>) -> Self {
3020 Self { roots }
3021 }
3022}
3023#[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 #[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#[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 #[serde(rename = "cacheScope")]
3063 pub cache_scope: CacheScope,
3064 #[serde(
3067 rename = "nextCursor",
3068 default,
3069 skip_serializing_if = "Option::is_none"
3070 )]
3071 pub next_cursor: Option<String>,
3072 #[serde(rename = "resultType")]
3080 pub result_type: String,
3081 #[serde(rename = "tools")]
3082 pub tools: Vec<Tool>,
3083 #[serde(rename = "ttlMs")]
3092 pub ttl_ms: u64,
3093}
3094impl ListToolsResult {
3095 #[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#[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 #[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#[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 #[serde(rename = "alert")]
3145 Alert,
3146 #[serde(rename = "critical")]
3148 Critical,
3149 #[serde(rename = "debug")]
3151 Debug,
3152 #[serde(rename = "emergency")]
3154 Emergency,
3155 #[serde(rename = "error")]
3157 Error,
3158 #[serde(rename = "info")]
3160 Info,
3161 #[serde(rename = "notice")]
3163 Notice,
3164 #[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 #[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#[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 #[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#[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 #[serde(rename = "data")]
3221 pub data: serde_json::Value,
3222 #[serde(rename = "level")]
3224 pub level: LoggingLevel,
3225 #[serde(rename = "logger", default, skip_serializing_if = "Option::is_none")]
3227 pub logger: Option<String>,
3228}
3229impl LoggingMessageNotificationParams {
3230 #[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}
3241pub type MetaObject = serde_json::Map<String, serde_json::Value>;
3257#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3263pub struct MethodNotFoundError {
3264 #[serde(rename = "code")]
3266 pub code: i64,
3267 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
3269 pub data: Option<serde_json::Value>,
3270 #[serde(rename = "message")]
3272 pub message: String,
3273}
3274impl MethodNotFoundError {
3275 #[must_use]
3277 pub fn new(code: i64, message: String) -> Self {
3278 Self {
3279 code,
3280 data: None,
3281 message,
3282 }
3283 }
3284}
3285#[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 #[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 #[serde(rename = "requiredCapabilities")]
3312 pub required_capabilities: ClientCapabilities,
3313}
3314impl MissingRequiredClientCapabilityErrorData {
3315 #[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 #[serde(rename = "message")]
3331 pub message: String,
3332}
3333impl MissingRequiredClientCapabilityErrorObject {
3334 #[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#[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 #[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
3363 pub name: Option<String>,
3364}
3365#[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 #[serde(
3385 rename = "costPriority",
3386 default,
3387 skip_serializing_if = "Option::is_none"
3388 )]
3389 pub cost_priority: Option<f64>,
3390 #[serde(rename = "hints", default, skip_serializing_if = "Option::is_none")]
3398 pub hints: Option<Vec<ModelHint>>,
3399 #[serde(
3403 rename = "intelligencePriority",
3404 default,
3405 skip_serializing_if = "Option::is_none"
3406 )]
3407 pub intelligence_priority: Option<f64>,
3408 #[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 Untitled(UntitledMultiSelectEnumSchema),
3423 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 #[must_use]
3446 pub fn new(method: String) -> Self {
3447 Self {
3448 method,
3449 params: None,
3450 }
3451 }
3452}
3453#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3455pub struct NotificationMetaObject {
3456 #[serde(
3467 rename = "io.modelcontextprotocol/subscriptionId",
3468 default,
3469 skip_serializing_if = "Option::is_none"
3470 )]
3471 pub subscription_id: Option<RequestId>,
3472 #[serde(flatten)]
3474 pub extra: serde_json::Map<String, serde_json::Value>,
3475}
3476#[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3484pub enum NotificationsCancelledMethod {
3485 #[default]
3487 #[serde(rename = "notifications/cancelled")]
3488 NotificationsCancelled,
3489}
3490impl NotificationsCancelledMethod {
3491 pub const VALUE: &'static str = "notifications/cancelled";
3493}
3494#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3496pub enum NotificationsMessageMethod {
3497 #[default]
3499 #[serde(rename = "notifications/message")]
3500 NotificationsMessage,
3501}
3502impl NotificationsMessageMethod {
3503 pub const VALUE: &'static str = "notifications/message";
3505}
3506#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3508pub enum NotificationsProgressMethod {
3509 #[default]
3511 #[serde(rename = "notifications/progress")]
3512 NotificationsProgress,
3513}
3514impl NotificationsProgressMethod {
3515 pub const VALUE: &'static str = "notifications/progress";
3517}
3518#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3520pub enum NotificationsPromptsListChangedMethod {
3521 #[default]
3523 #[serde(rename = "notifications/prompts/list_changed")]
3524 NotificationsPromptsListChanged,
3525}
3526impl NotificationsPromptsListChangedMethod {
3527 pub const VALUE: &'static str = "notifications/prompts/list_changed";
3529}
3530#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3532pub enum NotificationsResourcesListChangedMethod {
3533 #[default]
3535 #[serde(rename = "notifications/resources/list_changed")]
3536 NotificationsResourcesListChanged,
3537}
3538impl NotificationsResourcesListChangedMethod {
3539 pub const VALUE: &'static str = "notifications/resources/list_changed";
3541}
3542#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3544pub enum NotificationsResourcesUpdatedMethod {
3545 #[default]
3547 #[serde(rename = "notifications/resources/updated")]
3548 NotificationsResourcesUpdated,
3549}
3550impl NotificationsResourcesUpdatedMethod {
3551 pub const VALUE: &'static str = "notifications/resources/updated";
3553}
3554#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3556pub enum NotificationsSubscriptionsAcknowledgedMethod {
3557 #[default]
3559 #[serde(rename = "notifications/subscriptions/acknowledged")]
3560 NotificationsSubscriptionsAcknowledged,
3561}
3562impl NotificationsSubscriptionsAcknowledgedMethod {
3563 pub const VALUE: &'static str = "notifications/subscriptions/acknowledged";
3565}
3566#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3568pub enum NotificationsToolsListChangedMethod {
3569 #[default]
3571 #[serde(rename = "notifications/tools/list_changed")]
3572 NotificationsToolsListChanged,
3573}
3574impl NotificationsToolsListChangedMethod {
3575 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 #[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 #[serde(rename = "integer")]
3615 Integer,
3616 #[serde(rename = "number")]
3618 Number,
3619}
3620impl NumberSchemaType {
3621 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
3632pub enum ObjectType {
3633 #[default]
3635 #[serde(rename = "object")]
3636 Object,
3637}
3638impl ObjectType {
3639 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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3667pub struct PaginatedRequestParams {
3668 #[serde(rename = "_meta")]
3669 pub meta: RequestMetaObject,
3670 #[serde(rename = "cursor", default, skip_serializing_if = "Option::is_none")]
3673 pub cursor: Option<String>,
3674}
3675impl PaginatedRequestParams {
3676 #[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 #[serde(
3689 rename = "nextCursor",
3690 default,
3691 skip_serializing_if = "Option::is_none"
3692 )]
3693 pub next_cursor: Option<String>,
3694 #[serde(rename = "resultType")]
3702 pub result_type: String,
3703}
3704impl PaginatedResult {
3705 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3717pub struct ParseError {
3718 #[serde(rename = "code")]
3720 pub code: i64,
3721 #[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
3723 pub data: Option<serde_json::Value>,
3724 #[serde(rename = "message")]
3726 pub message: String,
3727}
3728impl ParseError {
3729 #[must_use]
3731 pub fn new(code: i64, message: String) -> Self {
3732 Self {
3733 code,
3734 data: None,
3735 message,
3736 }
3737 }
3738}
3739#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3742#[serde(untagged)]
3743pub enum PrimitiveSchemaDefinition {
3744 String(StringSchema),
3746 Number(NumberSchema),
3748 Boolean(BooleanSchema),
3750 UntitledSingleSelectEnum(UntitledSingleSelectEnumSchema),
3752 TitledSingleSelectEnum(TitledSingleSelectEnumSchema),
3754 UntitledMultiSelectEnum(UntitledMultiSelectEnumSchema),
3756 TitledMultiSelectEnum(TitledMultiSelectEnumSchema),
3758 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#[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 #[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#[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 #[serde(rename = "message", default, skip_serializing_if = "Option::is_none")]
3829 pub message: Option<String>,
3830 #[serde(rename = "progress")]
3832 pub progress: f64,
3833 #[serde(rename = "progressToken")]
3835 pub progress_token: ProgressToken,
3836 #[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
3838 pub total: Option<f64>,
3839}
3840impl ProgressNotificationParams {
3841 #[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#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
3855#[serde(untagged)]
3856pub enum ProgressToken {
3857 String(String),
3859 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#[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 #[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
3936 pub arguments: Option<Vec<PromptArgument>>,
3937 #[serde(
3939 rename = "description",
3940 default,
3941 skip_serializing_if = "Option::is_none"
3942 )]
3943 pub description: Option<String>,
3944 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
3954 pub icons: Option<Vec<Icon>>,
3955 #[serde(rename = "name")]
3957 pub name: String,
3958 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
3965 pub title: Option<String>,
3966}
3967impl Prompt {
3968 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3983pub struct PromptArgument {
3984 #[serde(
3986 rename = "description",
3987 default,
3988 skip_serializing_if = "Option::is_none"
3989 )]
3990 pub description: Option<String>,
3991 #[serde(rename = "name")]
3993 pub name: String,
3994 #[serde(rename = "required", default, skip_serializing_if = "Option::is_none")]
3996 pub required: Option<bool>,
3997 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4004 pub title: Option<String>,
4005}
4006impl PromptArgument {
4007 #[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#[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#[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 #[must_use]
4042 pub fn new(content: ContentBlock, role: Role) -> Self {
4043 Self { content, role }
4044 }
4045}
4046#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4048pub struct PromptReference {
4049 #[serde(rename = "name")]
4051 pub name: String,
4052 #[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 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4076pub enum PromptsGetMethod {
4077 #[default]
4079 #[serde(rename = "prompts/get")]
4080 PromptsGet,
4081}
4082impl PromptsGetMethod {
4083 pub const VALUE: &'static str = "prompts/get";
4085}
4086#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4088pub enum PromptsListMethod {
4089 #[default]
4091 #[serde(rename = "prompts/list")]
4092 PromptsList,
4093}
4094impl PromptsListMethod {
4095 pub const VALUE: &'static str = "prompts/list";
4097}
4098#[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 #[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#[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 #[serde(rename = "uri")]
4141 pub uri: String,
4142}
4143impl ReadResourceRequestParams {
4144 #[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#[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 #[serde(rename = "cacheScope")]
4171 pub cache_scope: CacheScope,
4172 #[serde(rename = "contents")]
4173 pub contents: Vec<ReadResourceResultContentsItem>,
4174 #[serde(rename = "resultType")]
4182 pub result_type: String,
4183 #[serde(rename = "ttlMs")]
4192 pub ttl_ms: u64,
4193}
4194impl ReadResourceResult {
4195 #[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 Text(TextResourceContents),
4217 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#[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 #[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 InputRequired(InputRequiredResult),
4256 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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4291pub enum RefPromptType {
4292 #[default]
4294 #[serde(rename = "ref/prompt")]
4295 RefPrompt,
4296}
4297impl RefPromptType {
4298 pub const VALUE: &'static str = "ref/prompt";
4300}
4301#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4303pub enum RefResourceType {
4304 #[default]
4306 #[serde(rename = "ref/resource")]
4307 RefResource,
4308}
4309impl RefResourceType {
4310 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 #[must_use]
4323 pub fn new(method: String) -> Self {
4324 Self {
4325 method,
4326 params: None,
4327 }
4328 }
4329}
4330#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
4332#[serde(untagged)]
4333pub enum RequestId {
4334 String(String),
4336 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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4408pub struct RequestMetaObject {
4409 #[serde(rename = "io.modelcontextprotocol/clientCapabilities")]
4415 pub client_capabilities: ClientCapabilities,
4416 #[serde(
4428 rename = "io.modelcontextprotocol/clientInfo",
4429 default,
4430 skip_serializing_if = "Option::is_none"
4431 )]
4432 pub client_info: Option<Implementation>,
4433 #[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 #[serde(rename = "io.modelcontextprotocol/protocolVersion")]
4454 pub protocol_version: String,
4455 #[serde(
4457 rename = "progressToken",
4458 default,
4459 skip_serializing_if = "Option::is_none"
4460 )]
4461 pub progress_token: Option<ProgressToken>,
4462 #[serde(flatten)]
4464 pub extra: serde_json::Map<String, serde_json::Value>,
4465}
4466impl RequestMetaObject {
4467 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4482pub struct RequestParams {
4483 #[serde(rename = "_meta")]
4484 pub meta: RequestMetaObject,
4485}
4486impl RequestParams {
4487 #[must_use]
4489 pub fn new(meta: RequestMetaObject) -> Self {
4490 Self { meta }
4491 }
4492}
4493#[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 #[serde(
4500 rename = "annotations",
4501 default,
4502 skip_serializing_if = "Option::is_none"
4503 )]
4504 pub annotations: Option<Annotations>,
4505 #[serde(
4509 rename = "description",
4510 default,
4511 skip_serializing_if = "Option::is_none"
4512 )]
4513 pub description: Option<String>,
4514 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
4524 pub icons: Option<Vec<Icon>>,
4525 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4527 pub mime_type: Option<String>,
4528 #[serde(rename = "name")]
4530 pub name: String,
4531 #[serde(rename = "size", default, skip_serializing_if = "Option::is_none")]
4535 pub size: Option<i64>,
4536 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4543 pub title: Option<String>,
4544 #[serde(rename = "uri")]
4546 pub uri: String,
4547}
4548impl Resource {
4549 #[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#[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 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4572 pub mime_type: Option<String>,
4573 #[serde(rename = "uri")]
4575 pub uri: String,
4576}
4577impl ResourceContents {
4578 #[must_use]
4580 pub fn new(uri: String) -> Self {
4581 Self {
4582 meta: None,
4583 mime_type: None,
4584 uri,
4585 }
4586 }
4587}
4588#[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 #[serde(
4597 rename = "annotations",
4598 default,
4599 skip_serializing_if = "Option::is_none"
4600 )]
4601 pub annotations: Option<Annotations>,
4602 #[serde(
4606 rename = "description",
4607 default,
4608 skip_serializing_if = "Option::is_none"
4609 )]
4610 pub description: Option<String>,
4611 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
4621 pub icons: Option<Vec<Icon>>,
4622 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4624 pub mime_type: Option<String>,
4625 #[serde(rename = "name")]
4627 pub name: String,
4628 #[serde(rename = "size", default, skip_serializing_if = "Option::is_none")]
4632 pub size: Option<i64>,
4633 #[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 #[serde(rename = "uri")]
4645 pub uri: String,
4646}
4647impl ResourceLink {
4648 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4667pub enum ResourceLinkType {
4668 #[default]
4670 #[serde(rename = "resource_link")]
4671 ResourceLink,
4672}
4673impl ResourceLinkType {
4674 pub const VALUE: &'static str = "resource_link";
4676}
4677#[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4689pub struct ResourceRequestParams {
4690 #[serde(rename = "_meta")]
4691 pub meta: RequestMetaObject,
4692 #[serde(rename = "uri")]
4694 pub uri: String,
4695}
4696impl ResourceRequestParams {
4697 #[must_use]
4699 pub fn new(meta: RequestMetaObject, uri: String) -> Self {
4700 Self { meta, uri }
4701 }
4702}
4703#[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 #[serde(
4710 rename = "annotations",
4711 default,
4712 skip_serializing_if = "Option::is_none"
4713 )]
4714 pub annotations: Option<Annotations>,
4715 #[serde(
4719 rename = "description",
4720 default,
4721 skip_serializing_if = "Option::is_none"
4722 )]
4723 pub description: Option<String>,
4724 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
4734 pub icons: Option<Vec<Icon>>,
4735 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
4737 pub mime_type: Option<String>,
4738 #[serde(rename = "name")]
4740 pub name: String,
4741 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
4748 pub title: Option<String>,
4749 #[serde(rename = "uriTemplate")]
4751 pub uri_template: String,
4752}
4753impl ResourceTemplate {
4754 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4771pub struct ResourceTemplateReference {
4772 #[serde(rename = "type")]
4773 pub r#type: RefResourceType,
4774 #[serde(rename = "uri")]
4776 pub uri: String,
4777}
4778impl ResourceTemplateReference {
4779 #[must_use]
4781 pub fn new(uri: String) -> Self {
4782 Self {
4783 r#type: Default::default(),
4784 uri,
4785 }
4786 }
4787}
4788#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4790pub enum ResourceType {
4791 #[default]
4793 #[serde(rename = "resource")]
4794 Resource,
4795}
4796impl ResourceType {
4797 pub const VALUE: &'static str = "resource";
4799}
4800#[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 #[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#[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 #[serde(rename = "uri")]
4828 pub uri: String,
4829}
4830impl ResourceUpdatedNotificationParams {
4831 #[must_use]
4833 pub fn new(uri: String) -> Self {
4834 Self { meta: None, uri }
4835 }
4836}
4837#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4839pub enum ResourcesListMethod {
4840 #[default]
4842 #[serde(rename = "resources/list")]
4843 ResourcesList,
4844}
4845impl ResourcesListMethod {
4846 pub const VALUE: &'static str = "resources/list";
4848}
4849#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4851pub enum ResourcesReadMethod {
4852 #[default]
4854 #[serde(rename = "resources/read")]
4855 ResourcesRead,
4856}
4857impl ResourcesReadMethod {
4858 pub const VALUE: &'static str = "resources/read";
4860}
4861#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4863pub enum ResourcesTemplatesListMethod {
4864 #[default]
4866 #[serde(rename = "resources/templates/list")]
4867 ResourcesTemplatesList,
4868}
4869impl ResourcesTemplatesListMethod {
4870 pub const VALUE: &'static str = "resources/templates/list";
4872}
4873#[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 #[serde(rename = "resultType")]
4886 pub result_type: String,
4887 #[serde(flatten)]
4889 pub extra: serde_json::Map<String, serde_json::Value>,
4890}
4891impl Result {
4892 #[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#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
4904pub struct ResultMetaObject {
4905 #[serde(
4917 rename = "io.modelcontextprotocol/serverInfo",
4918 default,
4919 skip_serializing_if = "Option::is_none"
4920 )]
4921 pub server_info: Option<Implementation>,
4922 #[serde(flatten)]
4924 pub extra: serde_json::Map<String, serde_json::Value>,
4925}
4926pub type ResultType = String;
4932#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
4934pub enum Role {
4935 #[serde(rename = "assistant")]
4937 Assistant,
4938 #[serde(rename = "user")]
4940 User,
4941}
4942impl Role {
4943 #[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#[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 #[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
4964 pub name: Option<String>,
4965 #[serde(rename = "uri")]
4969 pub uri: String,
4970}
4971impl Root {
4972 #[must_use]
4974 pub fn new(uri: String) -> Self {
4975 Self {
4976 meta: None,
4977 name: None,
4978 uri,
4979 }
4980 }
4981}
4982#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4984pub enum RootsListMethod {
4985 #[default]
4987 #[serde(rename = "roots/list")]
4988 RootsList,
4989}
4990impl RootsListMethod {
4991 pub const VALUE: &'static str = "roots/list";
4993}
4994#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
4996pub enum SamplingCreateMessageMethod {
4997 #[default]
4999 #[serde(rename = "sampling/createMessage")]
5000 SamplingCreateMessage,
5001}
5002impl SamplingCreateMessageMethod {
5003 pub const VALUE: &'static str = "sampling/createMessage";
5005}
5006#[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 #[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 TextContent(TextContent),
5035 ImageContent(ImageContent),
5037 AudioContent(AudioContent),
5039 ToolUseContent(ToolUseContent),
5041 ToolResultContent(ToolResultContent),
5043 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 Text(TextContent),
5084 Image(ImageContent),
5086 Audio(AudioContent),
5088 ToolUse(ToolUseContent),
5090 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#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5154pub struct ServerCapabilities {
5155 #[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 #[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 #[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 #[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 #[serde(rename = "prompts", default, skip_serializing_if = "Option::is_none")]
5191 pub prompts: Option<ServerCapabilitiesPrompts>,
5192 #[serde(rename = "resources", default, skip_serializing_if = "Option::is_none")]
5194 pub resources: Option<ServerCapabilitiesResources>,
5195 #[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
5197 pub tools: Option<ServerCapabilitiesTools>,
5198}
5199#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5201pub struct ServerCapabilitiesPrompts {
5202 #[serde(
5204 rename = "listChanged",
5205 default,
5206 skip_serializing_if = "Option::is_none"
5207 )]
5208 pub list_changed: Option<bool>,
5209}
5210#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5212pub struct ServerCapabilitiesResources {
5213 #[serde(
5215 rename = "listChanged",
5216 default,
5217 skip_serializing_if = "Option::is_none"
5218 )]
5219 pub list_changed: Option<bool>,
5220 #[serde(rename = "subscribe", default, skip_serializing_if = "Option::is_none")]
5222 pub subscribe: Option<bool>,
5223}
5224#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5226pub struct ServerCapabilitiesTools {
5227 #[serde(
5229 rename = "listChanged",
5230 default,
5231 skip_serializing_if = "Option::is_none"
5232 )]
5233 pub list_changed: Option<bool>,
5234}
5235#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5237pub enum ServerDiscoverMethod {
5238 #[default]
5240 #[serde(rename = "server/discover")]
5241 ServerDiscover,
5242}
5243impl ServerDiscoverMethod {
5244 pub const VALUE: &'static str = "server/discover";
5246}
5247#[derive(Debug, Clone, PartialEq, Serialize)]
5248#[serde(untagged)]
5249pub enum ServerNotification {
5250 Cancelled(CancelledNotification),
5252 Progress(ProgressNotification),
5254 ResourceListChanged(ResourceListChangedNotification),
5256 SubscriptionsAcknowledged(SubscriptionsAcknowledgedNotification),
5258 ResourceUpdated(ResourceUpdatedNotification),
5260 PromptListChanged(PromptListChangedNotification),
5262 ToolListChanged(ToolListChangedNotification),
5264 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 Untitled(UntitledSingleSelectEnumSchema),
5364 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 #[serde(rename = "date")]
5402 Date,
5403 #[serde(rename = "date-time")]
5405 DateTime,
5406 #[serde(rename = "email")]
5408 Email,
5409 #[serde(rename = "uri")]
5411 Uri,
5412}
5413impl StringSchemaFormat {
5414 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5427pub enum StringType {
5428 #[default]
5430 #[serde(rename = "string")]
5431 String,
5432}
5433impl StringType {
5434 pub const VALUE: &'static str = "string";
5436}
5437#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5443pub struct SubscriptionFilter {
5444 #[serde(
5446 rename = "promptsListChanged",
5447 default,
5448 skip_serializing_if = "Option::is_none"
5449 )]
5450 pub prompts_list_changed: Option<bool>,
5451 #[serde(
5454 rename = "resourceSubscriptions",
5455 default,
5456 skip_serializing_if = "Option::is_none"
5457 )]
5458 pub resource_subscriptions: Option<Vec<String>>,
5459 #[serde(
5461 rename = "resourcesListChanged",
5462 default,
5463 skip_serializing_if = "Option::is_none"
5464 )]
5465 pub resources_list_changed: Option<bool>,
5466 #[serde(
5468 rename = "toolsListChanged",
5469 default,
5470 skip_serializing_if = "Option::is_none"
5471 )]
5472 pub tools_list_changed: Option<bool>,
5473}
5474#[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 #[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#[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 #[serde(rename = "notifications")]
5514 pub notifications: SubscriptionFilter,
5515}
5516impl SubscriptionsAcknowledgedNotificationParams {
5517 #[must_use]
5519 pub fn new(notifications: SubscriptionFilter) -> Self {
5520 Self {
5521 meta: None,
5522 notifications,
5523 }
5524 }
5525}
5526#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5528pub enum SubscriptionsListenMethod {
5529 #[default]
5531 #[serde(rename = "subscriptions/listen")]
5532 SubscriptionsListen,
5533}
5534impl SubscriptionsListenMethod {
5535 pub const VALUE: &'static str = "subscriptions/listen";
5537}
5538#[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5566pub struct SubscriptionsListenRequestParams {
5567 #[serde(rename = "_meta")]
5568 pub meta: RequestMetaObject,
5569 #[serde(rename = "notifications")]
5573 pub notifications: SubscriptionFilter,
5574}
5575impl SubscriptionsListenRequestParams {
5576 #[must_use]
5578 pub fn new(meta: RequestMetaObject, notifications: SubscriptionFilter) -> Self {
5579 Self {
5580 meta,
5581 notifications,
5582 }
5583 }
5584}
5585#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5591pub struct SubscriptionsListenResult {
5592 #[serde(rename = "_meta")]
5593 pub meta: SubscriptionsListenResultMetaObject,
5594 #[serde(rename = "resultType")]
5602 pub result_type: String,
5603}
5604impl SubscriptionsListenResult {
5605 #[must_use]
5607 pub fn new(meta: SubscriptionsListenResultMetaObject, result_type: String) -> Self {
5608 Self { meta, result_type }
5609 }
5610}
5611#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5614pub struct SubscriptionsListenResultMetaObject {
5615 #[serde(
5627 rename = "io.modelcontextprotocol/serverInfo",
5628 default,
5629 skip_serializing_if = "Option::is_none"
5630 )]
5631 pub server_info: Option<Implementation>,
5632 #[serde(rename = "io.modelcontextprotocol/subscriptionId")]
5638 pub subscription_id: RequestId,
5639 #[serde(flatten)]
5641 pub extra: serde_json::Map<String, serde_json::Value>,
5642}
5643impl SubscriptionsListenResultMetaObject {
5644 #[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#[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 #[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#[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 #[serde(
5683 rename = "annotations",
5684 default,
5685 skip_serializing_if = "Option::is_none"
5686 )]
5687 pub annotations: Option<Annotations>,
5688 #[serde(rename = "text")]
5690 pub text: String,
5691 #[serde(rename = "type")]
5692 pub r#type: TextType,
5693}
5694impl TextContent {
5695 #[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 #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
5712 pub mime_type: Option<String>,
5713 #[serde(rename = "text")]
5715 pub text: String,
5716 #[serde(rename = "uri")]
5718 pub uri: String,
5719}
5720impl TextResourceContents {
5721 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
5734pub enum TextType {
5735 #[default]
5737 #[serde(rename = "text")]
5738 Text,
5739}
5740impl TextType {
5741 pub const VALUE: &'static str = "text";
5743}
5744#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5746pub struct TitledMultiSelectEnumSchema {
5747 #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
5749 pub default: Option<Vec<String>>,
5750 #[serde(
5752 rename = "description",
5753 default,
5754 skip_serializing_if = "Option::is_none"
5755 )]
5756 pub description: Option<String>,
5757 #[serde(rename = "items")]
5759 pub items: TitledMultiSelectEnumSchemaItems,
5760 #[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")]
5762 pub max_items: Option<i64>,
5763 #[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")]
5765 pub min_items: Option<i64>,
5766 #[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5789pub struct TitledMultiSelectEnumSchemaItems {
5790 #[serde(rename = "anyOf")]
5792 pub any_of: Vec<TitledMultiSelectEnumSchemaItemsAnyOfItem>,
5793}
5794impl TitledMultiSelectEnumSchemaItems {
5795 #[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 #[serde(rename = "const")]
5805 pub r#const: String,
5806 #[serde(rename = "title")]
5808 pub title: String,
5809}
5810impl TitledMultiSelectEnumSchemaItemsAnyOfItem {
5811 #[must_use]
5813 pub fn new(r#const: String, title: String) -> Self {
5814 Self { r#const, title }
5815 }
5816}
5817#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5819pub struct TitledSingleSelectEnumSchema {
5820 #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
5822 pub default: Option<String>,
5823 #[serde(
5825 rename = "description",
5826 default,
5827 skip_serializing_if = "Option::is_none"
5828 )]
5829 pub description: Option<String>,
5830 #[serde(rename = "oneOf")]
5832 pub one_of: Vec<TitledSingleSelectEnumSchemaOneOfItem>,
5833 #[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 #[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 #[serde(rename = "const")]
5856 pub r#const: String,
5857 #[serde(rename = "title")]
5859 pub title: String,
5860}
5861impl TitledSingleSelectEnumSchemaOneOfItem {
5862 #[must_use]
5864 pub fn new(r#const: String, title: String) -> Self {
5865 Self { r#const, title }
5866 }
5867}
5868#[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 #[serde(
5877 rename = "annotations",
5878 default,
5879 skip_serializing_if = "Option::is_none"
5880 )]
5881 pub annotations: Option<ToolAnnotations>,
5882 #[serde(
5886 rename = "description",
5887 default,
5888 skip_serializing_if = "Option::is_none"
5889 )]
5890 pub description: Option<String>,
5891 #[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
5901 pub icons: Option<Vec<Icon>>,
5902 #[serde(rename = "inputSchema")]
5917 pub input_schema: ToolInputSchema,
5918 #[serde(rename = "name")]
5920 pub name: String,
5921 #[serde(
5926 rename = "outputSchema",
5927 default,
5928 skip_serializing_if = "Option::is_none"
5929 )]
5930 pub output_schema: Option<ToolOutputSchema>,
5931 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
5938 pub title: Option<String>,
5939}
5940impl Tool {
5941 #[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#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
5965pub struct ToolAnnotations {
5966 #[serde(
5973 rename = "destructiveHint",
5974 default,
5975 skip_serializing_if = "Option::is_none"
5976 )]
5977 pub destructive_hint: Option<bool>,
5978 #[serde(
5985 rename = "idempotentHint",
5986 default,
5987 skip_serializing_if = "Option::is_none"
5988 )]
5989 pub idempotent_hint: Option<bool>,
5990 #[serde(
5997 rename = "openWorldHint",
5998 default,
5999 skip_serializing_if = "Option::is_none"
6000 )]
6001 pub open_world_hint: Option<bool>,
6002 #[serde(
6006 rename = "readOnlyHint",
6007 default,
6008 skip_serializing_if = "Option::is_none"
6009 )]
6010 pub read_only_hint: Option<bool>,
6011 #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
6013 pub title: Option<String>,
6014}
6015#[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 #[serde(rename = "mode", default, skip_serializing_if = "Option::is_none")]
6026 pub mode: Option<ToolChoiceMode>,
6027}
6028#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6033pub enum ToolChoiceMode {
6034 #[serde(rename = "auto")]
6036 Auto,
6037 #[serde(rename = "none")]
6039 None,
6040 #[serde(rename = "required")]
6042 Required,
6043}
6044impl ToolChoiceMode {
6045 #[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#[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 #[serde(flatten)]
6077 pub extra: serde_json::Map<String, serde_json::Value>,
6078}
6079#[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#[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 #[serde(flatten)]
6099 pub extra: serde_json::Map<String, serde_json::Value>,
6100}
6101#[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 #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
6110 pub meta: Option<MetaObject>,
6111 #[serde(rename = "content")]
6116 pub content: Vec<ContentBlock>,
6117 #[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")]
6122 pub is_error: Option<bool>,
6123 #[serde(
6128 rename = "structuredContent",
6129 default,
6130 skip_serializing_if = "Option::is_none"
6131 )]
6132 pub structured_content: Option<serde_json::Value>,
6133 #[serde(rename = "toolUseId")]
6137 pub tool_use_id: String,
6138 #[serde(rename = "type")]
6139 pub r#type: ToolResultType,
6140}
6141impl ToolResultContent {
6142 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6157pub enum ToolResultType {
6158 #[default]
6160 #[serde(rename = "tool_result")]
6161 ToolResult,
6162}
6163impl ToolResultType {
6164 pub const VALUE: &'static str = "tool_result";
6166}
6167#[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 #[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
6176 pub meta: Option<MetaObject>,
6177 #[serde(rename = "id")]
6181 pub id: String,
6182 #[serde(rename = "input")]
6184 pub input: serde_json::Map<String, serde_json::Value>,
6185 #[serde(rename = "name")]
6187 pub name: String,
6188 #[serde(rename = "type")]
6189 pub r#type: ToolUseType,
6190}
6191impl ToolUseContent {
6192 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6210pub enum ToolUseType {
6211 #[default]
6213 #[serde(rename = "tool_use")]
6214 ToolUse,
6215}
6216impl ToolUseType {
6217 pub const VALUE: &'static str = "tool_use";
6219}
6220#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6222pub enum ToolsCallMethod {
6223 #[default]
6225 #[serde(rename = "tools/call")]
6226 ToolsCall,
6227}
6228impl ToolsCallMethod {
6229 pub const VALUE: &'static str = "tools/call";
6231}
6232#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6234pub enum ToolsListMethod {
6235 #[default]
6237 #[serde(rename = "tools/list")]
6238 ToolsList,
6239}
6240impl ToolsListMethod {
6241 pub const VALUE: &'static str = "tools/list";
6243}
6244#[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 #[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 #[serde(rename = "requested")]
6272 pub requested: String,
6273 #[serde(rename = "supported")]
6276 pub supported: Vec<String>,
6277}
6278impl UnsupportedProtocolVersionErrorData {
6279 #[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 #[serde(rename = "message")]
6296 pub message: String,
6297}
6298impl UnsupportedProtocolVersionErrorObject {
6299 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6311pub struct UntitledMultiSelectEnumSchema {
6312 #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
6314 pub default: Option<Vec<String>>,
6315 #[serde(
6317 rename = "description",
6318 default,
6319 skip_serializing_if = "Option::is_none"
6320 )]
6321 pub description: Option<String>,
6322 #[serde(rename = "items")]
6324 pub items: UntitledMultiSelectEnumSchemaItems,
6325 #[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")]
6327 pub max_items: Option<i64>,
6328 #[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")]
6330 pub min_items: Option<i64>,
6331 #[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 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6354pub struct UntitledMultiSelectEnumSchemaItems {
6355 #[serde(rename = "enum")]
6357 pub r#enum: Vec<String>,
6358 #[serde(rename = "type")]
6359 pub r#type: StringType,
6360}
6361impl UntitledMultiSelectEnumSchemaItems {
6362 #[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6373pub struct UntitledSingleSelectEnumSchema {
6374 #[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
6376 pub default: Option<String>,
6377 #[serde(
6379 rename = "description",
6380 default,
6381 skip_serializing_if = "Option::is_none"
6382 )]
6383 pub description: Option<String>,
6384 #[serde(rename = "enum")]
6386 pub r#enum: Vec<String>,
6387 #[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 #[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#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
6408pub enum UrlMode {
6409 #[default]
6411 #[serde(rename = "url")]
6412 Url,
6413}
6414impl UrlMode {
6415 pub const VALUE: &'static str = "url";
6417}