use serde::{Deserialize, Serialize};
pub const PROTOCOL_VERSION: &str = "2026-07-28";
pub mod error_codes {
pub const HEADER_MISMATCH_ERROR: i64 = -32020i64;
pub const INTERNAL_ERROR: i64 = -32603i64;
pub const INVALID_PARAMS_ERROR: i64 = -32602i64;
pub const INVALID_REQUEST_ERROR: i64 = -32600i64;
pub const METHOD_NOT_FOUND_ERROR: i64 = -32601i64;
pub const MISSING_REQUIRED_CLIENT_CAPABILITY_ERROR: i64 = -32021i64;
pub const PARSE_ERROR: i64 = -32700i64;
pub const UNSUPPORTED_PROTOCOL_VERSION_ERROR: i64 = -32022i64;
}
pub mod methods {
pub const COMPLETION_COMPLETE: &str = "completion/complete";
pub const ELICITATION_CREATE: &str = "elicitation/create";
pub const NOTIFICATIONS_CANCELLED: &str = "notifications/cancelled";
pub const NOTIFICATIONS_MESSAGE: &str = "notifications/message";
pub const NOTIFICATIONS_PROGRESS: &str = "notifications/progress";
pub const NOTIFICATIONS_PROMPTS_LIST_CHANGED: &str = "notifications/prompts/list_changed";
pub const NOTIFICATIONS_RESOURCES_LIST_CHANGED: &str = "notifications/resources/list_changed";
pub const NOTIFICATIONS_RESOURCES_UPDATED: &str = "notifications/resources/updated";
pub const NOTIFICATIONS_SUBSCRIPTIONS_ACKNOWLEDGED: &str =
"notifications/subscriptions/acknowledged";
pub const NOTIFICATIONS_TOOLS_LIST_CHANGED: &str = "notifications/tools/list_changed";
pub const PROMPTS_GET: &str = "prompts/get";
pub const PROMPTS_LIST: &str = "prompts/list";
pub const RESOURCES_LIST: &str = "resources/list";
pub const RESOURCES_READ: &str = "resources/read";
pub const RESOURCES_TEMPLATES_LIST: &str = "resources/templates/list";
pub const ROOTS_LIST: &str = "roots/list";
pub const SAMPLING_CREATE_MESSAGE: &str = "sampling/createMessage";
pub const SERVER_DISCOVER: &str = "server/discover";
pub const SUBSCRIPTIONS_LISTEN: &str = "subscriptions/listen";
pub const TOOLS_CALL: &str = "tools/call";
pub const TOOLS_LIST: &str = "tools/list";
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct Annotations {
#[serde(rename = "audience", default, skip_serializing_if = "Option::is_none")]
pub audience: Option<Vec<Role>>,
#[serde(
rename = "lastModified",
default,
skip_serializing_if = "Option::is_none"
)]
pub last_modified: Option<String>,
#[serde(rename = "priority", default, skip_serializing_if = "Option::is_none")]
pub priority: Option<f64>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ArrayType {
#[default]
#[serde(rename = "array")]
Array,
}
impl ArrayType {
pub const VALUE: &'static str = "array";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AudioContent {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(rename = "data")]
pub data: String,
#[serde(rename = "mimeType")]
pub mime_type: String,
#[serde(rename = "type")]
pub r#type: AudioType,
}
impl AudioContent {
#[must_use]
pub fn new(data: String, mime_type: String) -> Self {
Self {
meta: None,
annotations: None,
data,
mime_type,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum AudioType {
#[default]
#[serde(rename = "audio")]
Audio,
}
impl AudioType {
pub const VALUE: &'static str = "audio";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BaseMetadata {
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
impl BaseMetadata {
#[must_use]
pub fn new(name: String) -> Self {
Self { name, title: None }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BlobResourceContents {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "blob")]
pub blob: String,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "uri")]
pub uri: String,
}
impl BlobResourceContents {
#[must_use]
pub fn new(blob: String, uri: String) -> Self {
Self {
meta: None,
blob,
mime_type: None,
uri,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct BooleanSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<bool>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: BooleanType,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum BooleanType {
#[default]
#[serde(rename = "boolean")]
Boolean,
}
impl BooleanType {
pub const VALUE: &'static str = "boolean";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CacheScope {
#[serde(rename = "private")]
Private,
#[serde(rename = "public")]
Public,
}
impl CacheScope {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Private => "private",
Self::Public => "public",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CacheableResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl CacheableResult {
#[must_use]
pub fn new(cache_scope: CacheScope, result_type: String, ttl_ms: u64) -> Self {
Self {
meta: None,
cache_scope,
result_type,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CallToolRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: ToolsCallMethod,
#[serde(rename = "params")]
pub params: CallToolRequestParams,
}
impl CallToolRequest {
#[must_use]
pub fn new(id: RequestId, params: CallToolRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CallToolRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
pub arguments: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(
rename = "inputResponses",
default,
skip_serializing_if = "Option::is_none"
)]
pub input_responses: Option<InputResponses>,
#[serde(rename = "name")]
pub name: String,
#[serde(
rename = "requestState",
default,
skip_serializing_if = "Option::is_none"
)]
pub request_state: Option<String>,
}
impl CallToolRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject, name: String) -> Self {
Self {
meta,
arguments: None,
input_responses: None,
name,
request_state: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CallToolResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "content")]
pub content: Vec<ContentBlock>,
#[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")]
pub is_error: Option<bool>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(
rename = "structuredContent",
default,
skip_serializing_if = "Option::is_none"
)]
pub structured_content: Option<serde_json::Value>,
}
impl CallToolResult {
#[must_use]
pub fn new(content: Vec<ContentBlock>, result_type: String) -> Self {
Self {
meta: None,
content,
is_error: None,
result_type,
structured_content: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CallToolResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: CallToolResultResponseResult,
}
impl CallToolResultResponse {
#[must_use]
pub fn new(id: RequestId, result: CallToolResultResponseResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum CallToolResultResponseResult {
InputRequired(InputRequiredResult),
CallTool(CallToolResult),
}
impl From<InputRequiredResult> for CallToolResultResponseResult {
fn from(v: InputRequiredResult) -> Self {
Self::InputRequired(v)
}
}
impl From<CallToolResult> for CallToolResultResponseResult {
fn from(v: CallToolResult) -> Self {
Self::CallTool(v)
}
}
impl<'de> Deserialize<'de> for CallToolResultResponseResult {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("resultType")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("input_required") => serde_json::from_value(value)
.map(Self::InputRequired)
.map_err(D::Error::custom),
_ => serde_json::from_value(value)
.map(Self::CallTool)
.map_err(D::Error::custom),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CancelledNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsCancelledMethod,
#[serde(rename = "params")]
pub params: CancelledNotificationParams,
}
impl CancelledNotification {
#[must_use]
pub fn new(params: CancelledNotificationParams) -> Self {
Self {
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CancelledNotificationParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<NotificationMetaObject>,
#[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
#[serde(rename = "requestId")]
pub request_id: RequestId,
}
impl CancelledNotificationParams {
#[must_use]
pub fn new(request_id: RequestId) -> Self {
Self {
meta: None,
reason: None,
request_id,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ClientCapabilities {
#[serde(
rename = "elicitation",
default,
skip_serializing_if = "Option::is_none"
)]
pub elicitation: Option<ClientCapabilitiesElicitation>,
#[serde(
rename = "experimental",
default,
skip_serializing_if = "Option::is_none"
)]
pub experimental:
Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
#[serde(
rename = "extensions",
default,
skip_serializing_if = "Option::is_none"
)]
pub extensions:
Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
#[deprecated(
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."
)]
#[serde(rename = "roots", default, skip_serializing_if = "Option::is_none")]
pub roots: Option<ClientCapabilitiesRoots>,
#[deprecated(
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."
)]
#[serde(rename = "sampling", default, skip_serializing_if = "Option::is_none")]
pub sampling: Option<ClientCapabilitiesSampling>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ClientCapabilitiesElicitation {
#[serde(rename = "form", default, skip_serializing_if = "Option::is_none")]
pub form: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(rename = "url", default, skip_serializing_if = "Option::is_none")]
pub url: Option<serde_json::Map<String, serde_json::Value>>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ClientCapabilitiesRoots {}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ClientCapabilitiesSampling {
#[serde(rename = "context", default, skip_serializing_if = "Option::is_none")]
pub context: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
pub tools: Option<serde_json::Map<String, serde_json::Value>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ClientNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsCancelledMethod,
#[serde(rename = "params")]
pub params: CancelledNotificationParams,
}
impl ClientNotification {
#[must_use]
pub fn new(params: CancelledNotificationParams) -> Self {
Self {
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum ClientRequest {
Discover(DiscoverRequest),
ListResources(ListResourcesRequest),
ListResourceTemplates(ListResourceTemplatesRequest),
ReadResource(ReadResourceRequest),
SubscriptionsListen(SubscriptionsListenRequest),
ListPrompts(ListPromptsRequest),
GetPrompt(GetPromptRequest),
ListTools(ListToolsRequest),
CallTool(CallToolRequest),
Complete(CompleteRequest),
}
impl From<DiscoverRequest> for ClientRequest {
fn from(v: DiscoverRequest) -> Self {
Self::Discover(v)
}
}
impl From<ListResourcesRequest> for ClientRequest {
fn from(v: ListResourcesRequest) -> Self {
Self::ListResources(v)
}
}
impl From<ListResourceTemplatesRequest> for ClientRequest {
fn from(v: ListResourceTemplatesRequest) -> Self {
Self::ListResourceTemplates(v)
}
}
impl From<ReadResourceRequest> for ClientRequest {
fn from(v: ReadResourceRequest) -> Self {
Self::ReadResource(v)
}
}
impl From<SubscriptionsListenRequest> for ClientRequest {
fn from(v: SubscriptionsListenRequest) -> Self {
Self::SubscriptionsListen(v)
}
}
impl From<ListPromptsRequest> for ClientRequest {
fn from(v: ListPromptsRequest) -> Self {
Self::ListPrompts(v)
}
}
impl From<GetPromptRequest> for ClientRequest {
fn from(v: GetPromptRequest) -> Self {
Self::GetPrompt(v)
}
}
impl From<ListToolsRequest> for ClientRequest {
fn from(v: ListToolsRequest) -> Self {
Self::ListTools(v)
}
}
impl From<CallToolRequest> for ClientRequest {
fn from(v: CallToolRequest) -> Self {
Self::CallTool(v)
}
}
impl From<CompleteRequest> for ClientRequest {
fn from(v: CompleteRequest) -> Self {
Self::Complete(v)
}
}
impl<'de> Deserialize<'de> for ClientRequest {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("method")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("server/discover") => serde_json::from_value(value)
.map(Self::Discover)
.map_err(D::Error::custom),
Some("resources/list") => serde_json::from_value(value)
.map(Self::ListResources)
.map_err(D::Error::custom),
Some("resources/templates/list") => serde_json::from_value(value)
.map(Self::ListResourceTemplates)
.map_err(D::Error::custom),
Some("resources/read") => serde_json::from_value(value)
.map(Self::ReadResource)
.map_err(D::Error::custom),
Some("subscriptions/listen") => serde_json::from_value(value)
.map(Self::SubscriptionsListen)
.map_err(D::Error::custom),
Some("prompts/list") => serde_json::from_value(value)
.map(Self::ListPrompts)
.map_err(D::Error::custom),
Some("prompts/get") => serde_json::from_value(value)
.map(Self::GetPrompt)
.map_err(D::Error::custom),
Some("tools/list") => serde_json::from_value(value)
.map(Self::ListTools)
.map_err(D::Error::custom),
Some("tools/call") => serde_json::from_value(value)
.map(Self::CallTool)
.map_err(D::Error::custom),
Some("completion/complete") => serde_json::from_value(value)
.map(Self::Complete)
.map_err(D::Error::custom),
None => Err(D::Error::missing_field("method")),
Some(other) => Err(D::Error::unknown_variant(
other,
&[
"server/discover",
"resources/list",
"resources/templates/list",
"resources/read",
"subscriptions/listen",
"prompts/list",
"prompts/get",
"tools/list",
"tools/call",
"completion/complete",
],
)),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CompleteRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: CompletionCompleteMethod,
#[serde(rename = "params")]
pub params: CompleteRequestParams,
}
impl CompleteRequest {
#[must_use]
pub fn new(id: RequestId, params: CompleteRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CompleteRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(rename = "argument")]
pub argument: CompleteRequestParamsArgument,
#[serde(rename = "context", default, skip_serializing_if = "Option::is_none")]
pub context: Option<CompleteRequestParamsContext>,
#[serde(rename = "ref")]
pub r#ref: CompleteRequestParamsRef,
}
impl CompleteRequestParams {
#[must_use]
pub fn new(
meta: RequestMetaObject,
argument: CompleteRequestParamsArgument,
r#ref: CompleteRequestParamsRef,
) -> Self {
Self {
meta,
argument,
context: None,
r#ref,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CompleteRequestParamsArgument {
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "value")]
pub value: String,
}
impl CompleteRequestParamsArgument {
#[must_use]
pub fn new(name: String, value: String) -> Self {
Self { name, value }
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct CompleteRequestParamsContext {
#[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
pub arguments: Option<std::collections::BTreeMap<String, String>>,
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum CompleteRequestParamsRef {
Prompt(PromptReference),
ResourceTemplate(ResourceTemplateReference),
}
impl From<PromptReference> for CompleteRequestParamsRef {
fn from(v: PromptReference) -> Self {
Self::Prompt(v)
}
}
impl From<ResourceTemplateReference> for CompleteRequestParamsRef {
fn from(v: ResourceTemplateReference) -> Self {
Self::ResourceTemplate(v)
}
}
impl<'de> Deserialize<'de> for CompleteRequestParamsRef {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("type")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("ref/prompt") => serde_json::from_value(value)
.map(Self::Prompt)
.map_err(D::Error::custom),
Some("ref/resource") => serde_json::from_value(value)
.map(Self::ResourceTemplate)
.map_err(D::Error::custom),
None => Err(D::Error::missing_field("type")),
Some(other) => Err(D::Error::unknown_variant(
other,
&["ref/prompt", "ref/resource"],
)),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CompleteResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "completion")]
pub completion: CompleteResultCompletion,
#[serde(rename = "resultType")]
pub result_type: String,
}
impl CompleteResult {
#[must_use]
pub fn new(completion: CompleteResultCompletion, result_type: String) -> Self {
Self {
meta: None,
completion,
result_type,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CompleteResultCompletion {
#[serde(rename = "hasMore", default, skip_serializing_if = "Option::is_none")]
pub has_more: Option<bool>,
#[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
pub total: Option<i64>,
#[serde(rename = "values")]
pub values: Vec<String>,
}
impl CompleteResultCompletion {
#[must_use]
pub fn new(values: Vec<String>) -> Self {
Self {
has_more: None,
total: None,
values,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CompleteResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: CompleteResult,
}
impl CompleteResultResponse {
#[must_use]
pub fn new(id: RequestId, result: CompleteResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum CompletionCompleteMethod {
#[default]
#[serde(rename = "completion/complete")]
CompletionComplete,
}
impl CompletionCompleteMethod {
pub const VALUE: &'static str = "completion/complete";
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum ContentBlock {
TextContent(TextContent),
ImageContent(ImageContent),
AudioContent(AudioContent),
ResourceLink(ResourceLink),
EmbeddedResource(EmbeddedResource),
}
impl From<TextContent> for ContentBlock {
fn from(v: TextContent) -> Self {
Self::TextContent(v)
}
}
impl From<ImageContent> for ContentBlock {
fn from(v: ImageContent) -> Self {
Self::ImageContent(v)
}
}
impl From<AudioContent> for ContentBlock {
fn from(v: AudioContent) -> Self {
Self::AudioContent(v)
}
}
impl From<ResourceLink> for ContentBlock {
fn from(v: ResourceLink) -> Self {
Self::ResourceLink(v)
}
}
impl From<EmbeddedResource> for ContentBlock {
fn from(v: EmbeddedResource) -> Self {
Self::EmbeddedResource(v)
}
}
impl<'de> Deserialize<'de> for ContentBlock {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("type")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("text") => serde_json::from_value(value)
.map(Self::TextContent)
.map_err(D::Error::custom),
Some("image") => serde_json::from_value(value)
.map(Self::ImageContent)
.map_err(D::Error::custom),
Some("audio") => serde_json::from_value(value)
.map(Self::AudioContent)
.map_err(D::Error::custom),
Some("resource_link") => serde_json::from_value(value)
.map(Self::ResourceLink)
.map_err(D::Error::custom),
Some("resource") => serde_json::from_value(value)
.map(Self::EmbeddedResource)
.map_err(D::Error::custom),
None => Err(D::Error::missing_field("type")),
Some(other) => Err(D::Error::unknown_variant(
other,
&["text", "image", "audio", "resource_link", "resource"],
)),
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateMessageRequest {
#[serde(rename = "method")]
pub method: SamplingCreateMessageMethod,
#[serde(rename = "params")]
pub params: CreateMessageRequestParams,
}
impl CreateMessageRequest {
#[must_use]
pub fn new(params: CreateMessageRequestParams) -> Self {
Self {
method: Default::default(),
params,
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateMessageRequestParams {
#[deprecated(
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\"`."
)]
#[serde(
rename = "includeContext",
default,
skip_serializing_if = "Option::is_none"
)]
pub include_context: Option<CreateMessageRequestParamsIncludeContext>,
#[serde(rename = "maxTokens")]
pub max_tokens: i64,
#[serde(rename = "messages")]
pub messages: Vec<SamplingMessage>,
#[serde(rename = "metadata", default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(
rename = "modelPreferences",
default,
skip_serializing_if = "Option::is_none"
)]
pub model_preferences: Option<ModelPreferences>,
#[serde(
rename = "stopSequences",
default,
skip_serializing_if = "Option::is_none"
)]
pub stop_sequences: Option<Vec<String>>,
#[serde(
rename = "systemPrompt",
default,
skip_serializing_if = "Option::is_none"
)]
pub system_prompt: Option<String>,
#[serde(
rename = "temperature",
default,
skip_serializing_if = "Option::is_none"
)]
pub temperature: Option<f64>,
#[serde(
rename = "toolChoice",
default,
skip_serializing_if = "Option::is_none"
)]
pub tool_choice: Option<ToolChoice>,
#[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
pub tools: Option<Vec<Tool>>,
}
impl CreateMessageRequestParams {
#[must_use]
pub fn new(max_tokens: i64, messages: Vec<SamplingMessage>) -> Self {
Self {
include_context: None,
max_tokens,
messages,
metadata: None,
model_preferences: None,
stop_sequences: None,
system_prompt: None,
temperature: None,
tool_choice: None,
tools: None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CreateMessageRequestParamsIncludeContext {
#[serde(rename = "allServers")]
AllServers,
#[serde(rename = "none")]
None,
#[serde(rename = "thisServer")]
ThisServer,
}
impl CreateMessageRequestParamsIncludeContext {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::AllServers => "allServers",
Self::None => "none",
Self::ThisServer => "thisServer",
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateMessageResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "content")]
pub content: CreateMessageResultContent,
#[serde(rename = "model")]
pub model: String,
#[serde(rename = "role")]
pub role: Role,
#[serde(
rename = "stopReason",
default,
skip_serializing_if = "Option::is_none"
)]
pub stop_reason: Option<String>,
}
impl CreateMessageResult {
#[must_use]
pub fn new(content: CreateMessageResultContent, model: String, role: Role) -> Self {
Self {
meta: None,
content,
model,
role,
stop_reason: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMessageResultContent {
TextContent(TextContent),
ImageContent(ImageContent),
AudioContent(AudioContent),
ToolUseContent(ToolUseContent),
ToolResultContent(ToolResultContent),
List(Vec<SamplingMessageContentBlock>),
}
impl From<TextContent> for CreateMessageResultContent {
fn from(v: TextContent) -> Self {
Self::TextContent(v)
}
}
impl From<ImageContent> for CreateMessageResultContent {
fn from(v: ImageContent) -> Self {
Self::ImageContent(v)
}
}
impl From<AudioContent> for CreateMessageResultContent {
fn from(v: AudioContent) -> Self {
Self::AudioContent(v)
}
}
impl From<ToolUseContent> for CreateMessageResultContent {
fn from(v: ToolUseContent) -> Self {
Self::ToolUseContent(v)
}
}
impl From<ToolResultContent> for CreateMessageResultContent {
fn from(v: ToolResultContent) -> Self {
Self::ToolResultContent(v)
}
}
impl From<Vec<SamplingMessageContentBlock>> for CreateMessageResultContent {
fn from(v: Vec<SamplingMessageContentBlock>) -> Self {
Self::List(v)
}
}
pub type Cursor = String;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DiscoverRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: ServerDiscoverMethod,
#[serde(rename = "params")]
pub params: RequestParams,
}
impl DiscoverRequest {
#[must_use]
pub fn new(id: RequestId, params: RequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DiscoverResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(rename = "capabilities")]
pub capabilities: ServerCapabilities,
#[serde(
rename = "instructions",
default,
skip_serializing_if = "Option::is_none"
)]
pub instructions: Option<String>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "supportedVersions")]
pub supported_versions: Vec<String>,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl DiscoverResult {
#[must_use]
pub fn new(
cache_scope: CacheScope,
capabilities: ServerCapabilities,
result_type: String,
supported_versions: Vec<String>,
ttl_ms: u64,
) -> Self {
Self {
meta: None,
cache_scope,
capabilities,
instructions: None,
result_type,
supported_versions,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DiscoverResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: DiscoverResult,
}
impl DiscoverResultResponse {
#[must_use]
pub fn new(id: RequestId, result: DiscoverResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElicitRequest {
#[serde(rename = "method")]
pub method: ElicitationCreateMethod,
#[serde(rename = "params")]
pub params: ElicitRequestParams,
}
impl ElicitRequest {
#[must_use]
pub fn new(params: ElicitRequestParams) -> Self {
Self {
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElicitRequestFormParams {
#[serde(rename = "message")]
pub message: String,
#[serde(rename = "mode", default, skip_serializing_if = "Option::is_none")]
pub mode: Option<FormMode>,
#[serde(rename = "requestedSchema")]
pub requested_schema: ElicitRequestFormParamsRequestedSchema,
}
impl ElicitRequestFormParams {
#[must_use]
pub fn new(message: String, requested_schema: ElicitRequestFormParamsRequestedSchema) -> Self {
Self {
message,
mode: None,
requested_schema,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElicitRequestFormParamsRequestedSchema {
#[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(rename = "properties")]
pub properties: std::collections::BTreeMap<String, PrimitiveSchemaDefinition>,
#[serde(rename = "required", default, skip_serializing_if = "Option::is_none")]
pub required: Option<Vec<String>>,
#[serde(rename = "type")]
pub r#type: ObjectType,
}
impl ElicitRequestFormParamsRequestedSchema {
#[must_use]
pub fn new(properties: std::collections::BTreeMap<String, PrimitiveSchemaDefinition>) -> Self {
Self {
schema: None,
properties,
required: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum ElicitRequestParams {
ElicitRequestForm(ElicitRequestFormParams),
ElicitRequestUrl(ElicitRequestUrlParams),
}
impl From<ElicitRequestFormParams> for ElicitRequestParams {
fn from(v: ElicitRequestFormParams) -> Self {
Self::ElicitRequestForm(v)
}
}
impl From<ElicitRequestUrlParams> for ElicitRequestParams {
fn from(v: ElicitRequestUrlParams) -> Self {
Self::ElicitRequestUrl(v)
}
}
impl<'de> Deserialize<'de> for ElicitRequestParams {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("mode")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("form") => serde_json::from_value(value)
.map(Self::ElicitRequestForm)
.map_err(D::Error::custom),
Some("url") => serde_json::from_value(value)
.map(Self::ElicitRequestUrl)
.map_err(D::Error::custom),
None => serde_json::from_value(value)
.map(Self::ElicitRequestForm)
.map_err(D::Error::custom),
Some(other) => Err(D::Error::unknown_variant(other, &["form", "url"])),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElicitRequestUrlParams {
#[serde(rename = "message")]
pub message: String,
#[serde(rename = "mode")]
pub mode: UrlMode,
#[serde(rename = "url")]
pub url: String,
}
impl ElicitRequestUrlParams {
#[must_use]
pub fn new(message: String, url: String) -> Self {
Self {
message,
mode: Default::default(),
url,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ElicitResult {
#[serde(rename = "action")]
pub action: ElicitResultAction,
#[serde(rename = "content", default, skip_serializing_if = "Option::is_none")]
pub content: Option<std::collections::BTreeMap<String, ElicitResultContentValue>>,
}
impl ElicitResult {
#[must_use]
pub fn new(action: ElicitResultAction) -> Self {
Self {
action,
content: None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElicitResultAction {
#[serde(rename = "accept")]
Accept,
#[serde(rename = "cancel")]
Cancel,
#[serde(rename = "decline")]
Decline,
}
impl ElicitResultAction {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Accept => "accept",
Self::Cancel => "cancel",
Self::Decline => "decline",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ElicitResultContentValue {
List(Vec<String>),
Scalar(ElicitResultContentValueScalar),
}
impl From<Vec<String>> for ElicitResultContentValue {
fn from(v: Vec<String>) -> Self {
Self::List(v)
}
}
impl From<ElicitResultContentValueScalar> for ElicitResultContentValue {
fn from(v: ElicitResultContentValueScalar) -> Self {
Self::Scalar(v)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
#[serde(untagged)]
pub enum ElicitResultContentValueScalar {
String(String),
Integer(i64),
Boolean(bool),
}
impl From<String> for ElicitResultContentValueScalar {
fn from(v: String) -> Self {
Self::String(v)
}
}
impl From<&str> for ElicitResultContentValueScalar {
fn from(v: &str) -> Self {
Self::String(v.to_owned())
}
}
impl From<i64> for ElicitResultContentValueScalar {
fn from(v: i64) -> Self {
Self::Integer(v)
}
}
impl From<bool> for ElicitResultContentValueScalar {
fn from(v: bool) -> Self {
Self::Boolean(v)
}
}
impl<'de> Deserialize<'de> for ElicitResultContentValueScalar {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
struct Visitor;
impl serde::de::Visitor<'_> for Visitor {
type Value = ElicitResultContentValueScalar;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("a string or an integer or a boolean")
}
fn visit_str<E: serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<Self::Value, E> {
Ok(ElicitResultContentValueScalar::String(v.to_owned()))
}
fn visit_string<E: serde::de::Error>(
self,
v: String,
) -> ::core::result::Result<Self::Value, E> {
Ok(ElicitResultContentValueScalar::String(v))
}
fn visit_i64<E: serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<Self::Value, E> {
Ok(ElicitResultContentValueScalar::Integer(v))
}
fn visit_u64<E: serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<Self::Value, E> {
i64::try_from(v)
.map(ElicitResultContentValueScalar::Integer)
.map_err(|_| E::invalid_value(serde::de::Unexpected::Unsigned(v), &self))
}
#[allow(clippy::cast_possible_truncation, clippy::float_cmp)]
fn visit_f64<E: serde::de::Error>(
self,
v: f64,
) -> ::core::result::Result<Self::Value, E> {
const MAX_SAFE: f64 = 9_007_199_254_740_991.0;
if v.fract() == 0.0 && (-MAX_SAFE..=MAX_SAFE).contains(&v) {
Ok(ElicitResultContentValueScalar::Integer(v as i64))
} else {
Err(E::invalid_type(serde::de::Unexpected::Float(v), &self))
}
}
fn visit_bool<E: serde::de::Error>(
self,
v: bool,
) -> ::core::result::Result<Self::Value, E> {
Ok(ElicitResultContentValueScalar::Boolean(v))
}
}
deserializer.deserialize_any(Visitor)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ElicitationCreateMethod {
#[default]
#[serde(rename = "elicitation/create")]
ElicitationCreate,
}
impl ElicitationCreateMethod {
pub const VALUE: &'static str = "elicitation/create";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EmbeddedResource {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(rename = "resource")]
pub resource: EmbeddedResourceResource,
#[serde(rename = "type")]
pub r#type: ResourceType,
}
impl EmbeddedResource {
#[must_use]
pub fn new(resource: EmbeddedResourceResource) -> Self {
Self {
meta: None,
annotations: None,
resource,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EmbeddedResourceResource {
Text(TextResourceContents),
Blob(BlobResourceContents),
}
impl From<TextResourceContents> for EmbeddedResourceResource {
fn from(v: TextResourceContents) -> Self {
Self::Text(v)
}
}
impl From<BlobResourceContents> for EmbeddedResourceResource {
fn from(v: BlobResourceContents) -> Self {
Self::Blob(v)
}
}
pub type EmptyResult = Result;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EnumSchema {
UntitledSingleSelect(UntitledSingleSelectEnumSchema),
TitledSingleSelect(TitledSingleSelectEnumSchema),
UntitledMultiSelect(UntitledMultiSelectEnumSchema),
TitledMultiSelect(TitledMultiSelectEnumSchema),
LegacyTitled(LegacyTitledEnumSchema),
}
impl From<UntitledSingleSelectEnumSchema> for EnumSchema {
fn from(v: UntitledSingleSelectEnumSchema) -> Self {
Self::UntitledSingleSelect(v)
}
}
impl From<TitledSingleSelectEnumSchema> for EnumSchema {
fn from(v: TitledSingleSelectEnumSchema) -> Self {
Self::TitledSingleSelect(v)
}
}
impl From<UntitledMultiSelectEnumSchema> for EnumSchema {
fn from(v: UntitledMultiSelectEnumSchema) -> Self {
Self::UntitledMultiSelect(v)
}
}
impl From<TitledMultiSelectEnumSchema> for EnumSchema {
fn from(v: TitledMultiSelectEnumSchema) -> Self {
Self::TitledMultiSelect(v)
}
}
impl From<LegacyTitledEnumSchema> for EnumSchema {
fn from(v: LegacyTitledEnumSchema) -> Self {
Self::LegacyTitled(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Error {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl Error {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum FormMode {
#[default]
#[serde(rename = "form")]
Form,
}
impl FormMode {
pub const VALUE: &'static str = "form";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetPromptRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: PromptsGetMethod,
#[serde(rename = "params")]
pub params: GetPromptRequestParams,
}
impl GetPromptRequest {
#[must_use]
pub fn new(id: RequestId, params: GetPromptRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetPromptRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
pub arguments: Option<std::collections::BTreeMap<String, String>>,
#[serde(
rename = "inputResponses",
default,
skip_serializing_if = "Option::is_none"
)]
pub input_responses: Option<InputResponses>,
#[serde(rename = "name")]
pub name: String,
#[serde(
rename = "requestState",
default,
skip_serializing_if = "Option::is_none"
)]
pub request_state: Option<String>,
}
impl GetPromptRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject, name: String) -> Self {
Self {
meta,
arguments: None,
input_responses: None,
name,
request_state: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetPromptResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "messages")]
pub messages: Vec<PromptMessage>,
#[serde(rename = "resultType")]
pub result_type: String,
}
impl GetPromptResult {
#[must_use]
pub fn new(messages: Vec<PromptMessage>, result_type: String) -> Self {
Self {
meta: None,
description: None,
messages,
result_type,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetPromptResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: GetPromptResultResponseResult,
}
impl GetPromptResultResponse {
#[must_use]
pub fn new(id: RequestId, result: GetPromptResultResponseResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum GetPromptResultResponseResult {
InputRequired(InputRequiredResult),
GetPrompt(GetPromptResult),
}
impl From<InputRequiredResult> for GetPromptResultResponseResult {
fn from(v: InputRequiredResult) -> Self {
Self::InputRequired(v)
}
}
impl From<GetPromptResult> for GetPromptResultResponseResult {
fn from(v: GetPromptResult) -> Self {
Self::GetPrompt(v)
}
}
impl<'de> Deserialize<'de> for GetPromptResultResponseResult {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("resultType")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("input_required") => serde_json::from_value(value)
.map(Self::InputRequired)
.map_err(D::Error::custom),
_ => serde_json::from_value(value)
.map(Self::GetPrompt)
.map_err(D::Error::custom),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HeaderMismatchError {
#[serde(rename = "error")]
pub error: HeaderMismatchErrorObject,
#[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
pub id: Option<RequestId>,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
}
impl HeaderMismatchError {
#[must_use]
pub fn new(error: HeaderMismatchErrorObject) -> Self {
Self {
error,
id: None,
jsonrpc: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HeaderMismatchErrorObject {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl HeaderMismatchErrorObject {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Icon {
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "sizes", default, skip_serializing_if = "Option::is_none")]
pub sizes: Option<Vec<String>>,
#[serde(rename = "src")]
pub src: String,
#[serde(rename = "theme", default, skip_serializing_if = "Option::is_none")]
pub theme: Option<IconTheme>,
}
impl Icon {
#[must_use]
pub fn new(src: String) -> Self {
Self {
mime_type: None,
sizes: None,
src,
theme: None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum IconTheme {
#[serde(rename = "dark")]
Dark,
#[serde(rename = "light")]
Light,
}
impl IconTheme {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Dark => "dark",
Self::Light => "light",
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct Icons {
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ImageContent {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(rename = "data")]
pub data: String,
#[serde(rename = "mimeType")]
pub mime_type: String,
#[serde(rename = "type")]
pub r#type: ImageType,
}
impl ImageContent {
#[must_use]
pub fn new(data: String, mime_type: String) -> Self {
Self {
meta: None,
annotations: None,
data,
mime_type,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ImageType {
#[default]
#[serde(rename = "image")]
Image,
}
impl ImageType {
pub const VALUE: &'static str = "image";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Implementation {
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "version")]
pub version: String,
#[serde(
rename = "websiteUrl",
default,
skip_serializing_if = "Option::is_none"
)]
pub website_url: Option<String>,
}
impl Implementation {
#[must_use]
pub fn new(name: String, version: String) -> Self {
Self {
description: None,
icons: None,
name,
title: None,
version,
website_url: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum InputRequest {
CreateMessage(CreateMessageRequest),
ListRoots(ListRootsRequest),
Elicit(ElicitRequest),
}
impl From<CreateMessageRequest> for InputRequest {
fn from(v: CreateMessageRequest) -> Self {
Self::CreateMessage(v)
}
}
impl From<ListRootsRequest> for InputRequest {
fn from(v: ListRootsRequest) -> Self {
Self::ListRoots(v)
}
}
impl From<ElicitRequest> for InputRequest {
fn from(v: ElicitRequest) -> Self {
Self::Elicit(v)
}
}
impl<'de> Deserialize<'de> for InputRequest {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("method")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("sampling/createMessage") => serde_json::from_value(value)
.map(Self::CreateMessage)
.map_err(D::Error::custom),
Some("roots/list") => serde_json::from_value(value)
.map(Self::ListRoots)
.map_err(D::Error::custom),
Some("elicitation/create") => serde_json::from_value(value)
.map(Self::Elicit)
.map_err(D::Error::custom),
None => Err(D::Error::missing_field("method")),
Some(other) => Err(D::Error::unknown_variant(
other,
&["sampling/createMessage", "roots/list", "elicitation/create"],
)),
}
}
}
pub type InputRequests = std::collections::BTreeMap<String, InputRequest>;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InputRequiredResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(
rename = "inputRequests",
default,
skip_serializing_if = "Option::is_none"
)]
pub input_requests: Option<InputRequests>,
#[serde(
rename = "requestState",
default,
skip_serializing_if = "Option::is_none"
)]
pub request_state: Option<String>,
#[serde(rename = "resultType")]
pub result_type: String,
}
impl InputRequiredResult {
#[must_use]
pub fn new(result_type: String) -> Self {
Self {
meta: None,
input_requests: None,
request_state: None,
result_type,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InputResponse {
CreateMessage(CreateMessageResult),
ListRoots(ListRootsResult),
Elicit(ElicitResult),
}
impl From<CreateMessageResult> for InputResponse {
fn from(v: CreateMessageResult) -> Self {
Self::CreateMessage(v)
}
}
impl From<ListRootsResult> for InputResponse {
fn from(v: ListRootsResult) -> Self {
Self::ListRoots(v)
}
}
impl From<ElicitResult> for InputResponse {
fn from(v: ElicitResult) -> Self {
Self::Elicit(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InputResponseRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(
rename = "inputResponses",
default,
skip_serializing_if = "Option::is_none"
)]
pub input_responses: Option<InputResponses>,
#[serde(
rename = "requestState",
default,
skip_serializing_if = "Option::is_none"
)]
pub request_state: Option<String>,
}
impl InputResponseRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject) -> Self {
Self {
meta,
input_responses: None,
request_state: None,
}
}
}
pub type InputResponses = std::collections::BTreeMap<String, InputResponse>;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InternalError {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl InternalError {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InvalidParamsError {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl InvalidParamsError {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InvalidRequestError {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl InvalidRequestError {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct JsonRpcErrorResponse {
#[serde(rename = "error")]
pub error: Error,
#[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
pub id: Option<RequestId>,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
}
impl JsonRpcErrorResponse {
#[must_use]
pub fn new(error: Error) -> Self {
Self {
error,
id: None,
jsonrpc: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum JsonRpcMessage {
JsonRpcRequest(JsonRpcRequest),
JsonRpcNotification(JsonRpcNotification),
JsonRpcResultResponse(JsonRpcResultResponse),
JsonRpcErrorResponse(JsonRpcErrorResponse),
}
impl From<JsonRpcRequest> for JsonRpcMessage {
fn from(v: JsonRpcRequest) -> Self {
Self::JsonRpcRequest(v)
}
}
impl From<JsonRpcNotification> for JsonRpcMessage {
fn from(v: JsonRpcNotification) -> Self {
Self::JsonRpcNotification(v)
}
}
impl From<JsonRpcResultResponse> for JsonRpcMessage {
fn from(v: JsonRpcResultResponse) -> Self {
Self::JsonRpcResultResponse(v)
}
}
impl From<JsonRpcErrorResponse> for JsonRpcMessage {
fn from(v: JsonRpcErrorResponse) -> Self {
Self::JsonRpcErrorResponse(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct JsonRpcNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: String,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<serde_json::Map<String, serde_json::Value>>,
}
impl JsonRpcNotification {
#[must_use]
pub fn new(method: String) -> Self {
Self {
jsonrpc: Default::default(),
method,
params: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct JsonRpcRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: String,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<serde_json::Map<String, serde_json::Value>>,
}
impl JsonRpcRequest {
#[must_use]
pub fn new(id: RequestId, method: String) -> Self {
Self {
id,
jsonrpc: Default::default(),
method,
params: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum JsonRpcResponse {
JsonRpcResult(JsonRpcResultResponse),
JsonRpcError(JsonRpcErrorResponse),
}
impl From<JsonRpcResultResponse> for JsonRpcResponse {
fn from(v: JsonRpcResultResponse) -> Self {
Self::JsonRpcResult(v)
}
}
impl From<JsonRpcErrorResponse> for JsonRpcResponse {
fn from(v: JsonRpcErrorResponse) -> Self {
Self::JsonRpcError(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct JsonRpcResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: Result,
}
impl JsonRpcResultResponse {
#[must_use]
pub fn new(id: RequestId, result: Result) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum JsonRpcVersion {
#[default]
#[serde(rename = "2.0")]
V20,
}
impl JsonRpcVersion {
pub const VALUE: &'static str = "2.0";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LegacyTitledEnumSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<String>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "enum")]
pub r#enum: Vec<String>,
#[serde(rename = "enumNames", default, skip_serializing_if = "Option::is_none")]
pub enum_names: Option<Vec<String>>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: StringType,
}
impl LegacyTitledEnumSchema {
#[must_use]
pub fn new(r#enum: Vec<String>) -> Self {
Self {
default: None,
description: None,
r#enum,
enum_names: None,
title: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListPromptsRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: PromptsListMethod,
#[serde(rename = "params")]
pub params: PaginatedRequestParams,
}
impl ListPromptsRequest {
#[must_use]
pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListPromptsResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "Option::is_none"
)]
pub next_cursor: Option<String>,
#[serde(rename = "prompts")]
pub prompts: Vec<Prompt>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl ListPromptsResult {
#[must_use]
pub fn new(
cache_scope: CacheScope,
prompts: Vec<Prompt>,
result_type: String,
ttl_ms: u64,
) -> Self {
Self {
meta: None,
cache_scope,
next_cursor: None,
prompts,
result_type,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListPromptsResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: ListPromptsResult,
}
impl ListPromptsResultResponse {
#[must_use]
pub fn new(id: RequestId, result: ListPromptsResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListResourceTemplatesRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: ResourcesTemplatesListMethod,
#[serde(rename = "params")]
pub params: PaginatedRequestParams,
}
impl ListResourceTemplatesRequest {
#[must_use]
pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListResourceTemplatesResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "Option::is_none"
)]
pub next_cursor: Option<String>,
#[serde(rename = "resourceTemplates")]
pub resource_templates: Vec<ResourceTemplate>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl ListResourceTemplatesResult {
#[must_use]
pub fn new(
cache_scope: CacheScope,
resource_templates: Vec<ResourceTemplate>,
result_type: String,
ttl_ms: u64,
) -> Self {
Self {
meta: None,
cache_scope,
next_cursor: None,
resource_templates,
result_type,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListResourceTemplatesResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: ListResourceTemplatesResult,
}
impl ListResourceTemplatesResultResponse {
#[must_use]
pub fn new(id: RequestId, result: ListResourceTemplatesResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListResourcesRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: ResourcesListMethod,
#[serde(rename = "params")]
pub params: PaginatedRequestParams,
}
impl ListResourcesRequest {
#[must_use]
pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListResourcesResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "Option::is_none"
)]
pub next_cursor: Option<String>,
#[serde(rename = "resources")]
pub resources: Vec<Resource>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl ListResourcesResult {
#[must_use]
pub fn new(
cache_scope: CacheScope,
resources: Vec<Resource>,
result_type: String,
ttl_ms: u64,
) -> Self {
Self {
meta: None,
cache_scope,
next_cursor: None,
resources,
result_type,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListResourcesResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: ListResourcesResult,
}
impl ListResourcesResultResponse {
#[must_use]
pub fn new(id: RequestId, result: ListResourcesResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ListRootsRequest {
#[serde(rename = "method")]
pub method: RootsListMethod,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<ListRootsRequestParams>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ListRootsRequestParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListRootsResult {
#[serde(rename = "roots")]
pub roots: Vec<Root>,
}
impl ListRootsResult {
#[must_use]
pub fn new(roots: Vec<Root>) -> Self {
Self { roots }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListToolsRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: ToolsListMethod,
#[serde(rename = "params")]
pub params: PaginatedRequestParams,
}
impl ListToolsRequest {
#[must_use]
pub fn new(id: RequestId, params: PaginatedRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListToolsResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "Option::is_none"
)]
pub next_cursor: Option<String>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "tools")]
pub tools: Vec<Tool>,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl ListToolsResult {
#[must_use]
pub fn new(
cache_scope: CacheScope,
result_type: String,
tools: Vec<Tool>,
ttl_ms: u64,
) -> Self {
Self {
meta: None,
cache_scope,
next_cursor: None,
result_type,
tools,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ListToolsResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: ListToolsResult,
}
impl ListToolsResultResponse {
#[must_use]
pub fn new(id: RequestId, result: ListToolsResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum LoggingLevel {
#[serde(rename = "alert")]
Alert,
#[serde(rename = "critical")]
Critical,
#[serde(rename = "debug")]
Debug,
#[serde(rename = "emergency")]
Emergency,
#[serde(rename = "error")]
Error,
#[serde(rename = "info")]
Info,
#[serde(rename = "notice")]
Notice,
#[serde(rename = "warning")]
Warning,
}
#[deprecated(
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."
)]
impl LoggingLevel {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Alert => "alert",
Self::Critical => "critical",
Self::Debug => "debug",
Self::Emergency => "emergency",
Self::Error => "error",
Self::Info => "info",
Self::Notice => "notice",
Self::Warning => "warning",
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LoggingMessageNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsMessageMethod,
#[serde(rename = "params")]
pub params: LoggingMessageNotificationParams,
}
impl LoggingMessageNotification {
#[must_use]
pub fn new(params: LoggingMessageNotificationParams) -> Self {
Self {
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LoggingMessageNotificationParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<NotificationMetaObject>,
#[serde(rename = "data")]
pub data: serde_json::Value,
#[serde(rename = "level")]
pub level: LoggingLevel,
#[serde(rename = "logger", default, skip_serializing_if = "Option::is_none")]
pub logger: Option<String>,
}
impl LoggingMessageNotificationParams {
#[must_use]
pub fn new(data: serde_json::Value, level: LoggingLevel) -> Self {
Self {
meta: None,
data,
level,
logger: None,
}
}
}
pub type MetaObject = serde_json::Map<String, serde_json::Value>;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MethodNotFoundError {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl MethodNotFoundError {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MissingRequiredClientCapabilityError {
#[serde(rename = "error")]
pub error: MissingRequiredClientCapabilityErrorObject,
#[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
pub id: Option<RequestId>,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
}
impl MissingRequiredClientCapabilityError {
#[must_use]
pub fn new(error: MissingRequiredClientCapabilityErrorObject) -> Self {
Self {
error,
id: None,
jsonrpc: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MissingRequiredClientCapabilityErrorData {
#[serde(rename = "requiredCapabilities")]
pub required_capabilities: ClientCapabilities,
}
impl MissingRequiredClientCapabilityErrorData {
#[must_use]
pub fn new(required_capabilities: ClientCapabilities) -> Self {
Self {
required_capabilities,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MissingRequiredClientCapabilityErrorObject {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data")]
pub data: MissingRequiredClientCapabilityErrorData,
#[serde(rename = "message")]
pub message: String,
}
impl MissingRequiredClientCapabilityErrorObject {
#[must_use]
pub fn new(code: i64, data: MissingRequiredClientCapabilityErrorData, message: String) -> Self {
Self {
code,
data,
message,
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ModelHint {
#[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ModelPreferences {
#[serde(
rename = "costPriority",
default,
skip_serializing_if = "Option::is_none"
)]
pub cost_priority: Option<f64>,
#[serde(rename = "hints", default, skip_serializing_if = "Option::is_none")]
pub hints: Option<Vec<ModelHint>>,
#[serde(
rename = "intelligencePriority",
default,
skip_serializing_if = "Option::is_none"
)]
pub intelligence_priority: Option<f64>,
#[serde(
rename = "speedPriority",
default,
skip_serializing_if = "Option::is_none"
)]
pub speed_priority: Option<f64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MultiSelectEnumSchema {
Untitled(UntitledMultiSelectEnumSchema),
Titled(TitledMultiSelectEnumSchema),
}
impl From<UntitledMultiSelectEnumSchema> for MultiSelectEnumSchema {
fn from(v: UntitledMultiSelectEnumSchema) -> Self {
Self::Untitled(v)
}
}
impl From<TitledMultiSelectEnumSchema> for MultiSelectEnumSchema {
fn from(v: TitledMultiSelectEnumSchema) -> Self {
Self::Titled(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Notification {
#[serde(rename = "method")]
pub method: String,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<serde_json::Map<String, serde_json::Value>>,
}
impl Notification {
#[must_use]
pub fn new(method: String) -> Self {
Self {
method,
params: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct NotificationMetaObject {
#[serde(
rename = "io.modelcontextprotocol/subscriptionId",
default,
skip_serializing_if = "Option::is_none"
)]
pub subscription_id: Option<RequestId>,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct NotificationParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<NotificationMetaObject>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsCancelledMethod {
#[default]
#[serde(rename = "notifications/cancelled")]
NotificationsCancelled,
}
impl NotificationsCancelledMethod {
pub const VALUE: &'static str = "notifications/cancelled";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsMessageMethod {
#[default]
#[serde(rename = "notifications/message")]
NotificationsMessage,
}
impl NotificationsMessageMethod {
pub const VALUE: &'static str = "notifications/message";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsProgressMethod {
#[default]
#[serde(rename = "notifications/progress")]
NotificationsProgress,
}
impl NotificationsProgressMethod {
pub const VALUE: &'static str = "notifications/progress";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsPromptsListChangedMethod {
#[default]
#[serde(rename = "notifications/prompts/list_changed")]
NotificationsPromptsListChanged,
}
impl NotificationsPromptsListChangedMethod {
pub const VALUE: &'static str = "notifications/prompts/list_changed";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsResourcesListChangedMethod {
#[default]
#[serde(rename = "notifications/resources/list_changed")]
NotificationsResourcesListChanged,
}
impl NotificationsResourcesListChangedMethod {
pub const VALUE: &'static str = "notifications/resources/list_changed";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsResourcesUpdatedMethod {
#[default]
#[serde(rename = "notifications/resources/updated")]
NotificationsResourcesUpdated,
}
impl NotificationsResourcesUpdatedMethod {
pub const VALUE: &'static str = "notifications/resources/updated";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsSubscriptionsAcknowledgedMethod {
#[default]
#[serde(rename = "notifications/subscriptions/acknowledged")]
NotificationsSubscriptionsAcknowledged,
}
impl NotificationsSubscriptionsAcknowledgedMethod {
pub const VALUE: &'static str = "notifications/subscriptions/acknowledged";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum NotificationsToolsListChangedMethod {
#[default]
#[serde(rename = "notifications/tools/list_changed")]
NotificationsToolsListChanged,
}
impl NotificationsToolsListChangedMethod {
pub const VALUE: &'static str = "notifications/tools/list_changed";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct NumberSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<f64>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "maximum", default, skip_serializing_if = "Option::is_none")]
pub maximum: Option<f64>,
#[serde(rename = "minimum", default, skip_serializing_if = "Option::is_none")]
pub minimum: Option<f64>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: NumberSchemaType,
}
impl NumberSchema {
#[must_use]
pub fn new(r#type: NumberSchemaType) -> Self {
Self {
default: None,
description: None,
maximum: None,
minimum: None,
title: None,
r#type,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum NumberSchemaType {
#[serde(rename = "integer")]
Integer,
#[serde(rename = "number")]
Number,
}
impl NumberSchemaType {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Integer => "integer",
Self::Number => "number",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ObjectType {
#[default]
#[serde(rename = "object")]
Object,
}
impl ObjectType {
pub const VALUE: &'static str = "object";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PaginatedRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: String,
#[serde(rename = "params")]
pub params: PaginatedRequestParams,
}
impl PaginatedRequest {
#[must_use]
pub fn new(id: RequestId, method: String, params: PaginatedRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method,
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PaginatedRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(rename = "cursor", default, skip_serializing_if = "Option::is_none")]
pub cursor: Option<String>,
}
impl PaginatedRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject) -> Self {
Self { meta, cursor: None }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PaginatedResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "Option::is_none"
)]
pub next_cursor: Option<String>,
#[serde(rename = "resultType")]
pub result_type: String,
}
impl PaginatedResult {
#[must_use]
pub fn new(result_type: String) -> Self {
Self {
meta: None,
next_cursor: None,
result_type,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ParseError {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data", default, skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
#[serde(rename = "message")]
pub message: String,
}
impl ParseError {
#[must_use]
pub fn new(code: i64, message: String) -> Self {
Self {
code,
data: None,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PrimitiveSchemaDefinition {
String(StringSchema),
Number(NumberSchema),
Boolean(BooleanSchema),
UntitledSingleSelectEnum(UntitledSingleSelectEnumSchema),
TitledSingleSelectEnum(TitledSingleSelectEnumSchema),
UntitledMultiSelectEnum(UntitledMultiSelectEnumSchema),
TitledMultiSelectEnum(TitledMultiSelectEnumSchema),
LegacyTitledEnum(LegacyTitledEnumSchema),
}
impl From<StringSchema> for PrimitiveSchemaDefinition {
fn from(v: StringSchema) -> Self {
Self::String(v)
}
}
impl From<NumberSchema> for PrimitiveSchemaDefinition {
fn from(v: NumberSchema) -> Self {
Self::Number(v)
}
}
impl From<BooleanSchema> for PrimitiveSchemaDefinition {
fn from(v: BooleanSchema) -> Self {
Self::Boolean(v)
}
}
impl From<UntitledSingleSelectEnumSchema> for PrimitiveSchemaDefinition {
fn from(v: UntitledSingleSelectEnumSchema) -> Self {
Self::UntitledSingleSelectEnum(v)
}
}
impl From<TitledSingleSelectEnumSchema> for PrimitiveSchemaDefinition {
fn from(v: TitledSingleSelectEnumSchema) -> Self {
Self::TitledSingleSelectEnum(v)
}
}
impl From<UntitledMultiSelectEnumSchema> for PrimitiveSchemaDefinition {
fn from(v: UntitledMultiSelectEnumSchema) -> Self {
Self::UntitledMultiSelectEnum(v)
}
}
impl From<TitledMultiSelectEnumSchema> for PrimitiveSchemaDefinition {
fn from(v: TitledMultiSelectEnumSchema) -> Self {
Self::TitledMultiSelectEnum(v)
}
}
impl From<LegacyTitledEnumSchema> for PrimitiveSchemaDefinition {
fn from(v: LegacyTitledEnumSchema) -> Self {
Self::LegacyTitledEnum(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ProgressNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsProgressMethod,
#[serde(rename = "params")]
pub params: ProgressNotificationParams,
}
impl ProgressNotification {
#[must_use]
pub fn new(params: ProgressNotificationParams) -> Self {
Self {
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ProgressNotificationParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<NotificationMetaObject>,
#[serde(rename = "message", default, skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "progress")]
pub progress: f64,
#[serde(rename = "progressToken")]
pub progress_token: ProgressToken,
#[serde(rename = "total", default, skip_serializing_if = "Option::is_none")]
pub total: Option<f64>,
}
impl ProgressNotificationParams {
#[must_use]
pub fn new(progress: f64, progress_token: ProgressToken) -> Self {
Self {
meta: None,
message: None,
progress,
progress_token,
total: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
#[serde(untagged)]
pub enum ProgressToken {
String(String),
Integer(i64),
}
impl From<String> for ProgressToken {
fn from(v: String) -> Self {
Self::String(v)
}
}
impl From<&str> for ProgressToken {
fn from(v: &str) -> Self {
Self::String(v.to_owned())
}
}
impl From<i64> for ProgressToken {
fn from(v: i64) -> Self {
Self::Integer(v)
}
}
impl<'de> Deserialize<'de> for ProgressToken {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
struct Visitor;
impl serde::de::Visitor<'_> for Visitor {
type Value = ProgressToken;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("a string or an integer")
}
fn visit_str<E: serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<Self::Value, E> {
Ok(ProgressToken::String(v.to_owned()))
}
fn visit_string<E: serde::de::Error>(
self,
v: String,
) -> ::core::result::Result<Self::Value, E> {
Ok(ProgressToken::String(v))
}
fn visit_i64<E: serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<Self::Value, E> {
Ok(ProgressToken::Integer(v))
}
fn visit_u64<E: serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<Self::Value, E> {
i64::try_from(v)
.map(ProgressToken::Integer)
.map_err(|_| E::invalid_value(serde::de::Unexpected::Unsigned(v), &self))
}
#[allow(clippy::cast_possible_truncation, clippy::float_cmp)]
fn visit_f64<E: serde::de::Error>(
self,
v: f64,
) -> ::core::result::Result<Self::Value, E> {
const MAX_SAFE: f64 = 9_007_199_254_740_991.0;
if v.fract() == 0.0 && (-MAX_SAFE..=MAX_SAFE).contains(&v) {
Ok(ProgressToken::Integer(v as i64))
} else {
Err(E::invalid_type(serde::de::Unexpected::Float(v), &self))
}
}
}
deserializer.deserialize_any(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Prompt {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "arguments", default, skip_serializing_if = "Option::is_none")]
pub arguments: Option<Vec<PromptArgument>>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
impl Prompt {
#[must_use]
pub fn new(name: String) -> Self {
Self {
meta: None,
arguments: None,
description: None,
icons: None,
name,
title: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PromptArgument {
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "required", default, skip_serializing_if = "Option::is_none")]
pub required: Option<bool>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
impl PromptArgument {
#[must_use]
pub fn new(name: String) -> Self {
Self {
description: None,
name,
required: None,
title: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct PromptListChangedNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsPromptsListChangedMethod,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<NotificationParams>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PromptMessage {
#[serde(rename = "content")]
pub content: ContentBlock,
#[serde(rename = "role")]
pub role: Role,
}
impl PromptMessage {
#[must_use]
pub fn new(content: ContentBlock, role: Role) -> Self {
Self { content, role }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PromptReference {
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: RefPromptType,
}
impl PromptReference {
#[must_use]
pub fn new(name: String) -> Self {
Self {
name,
title: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum PromptsGetMethod {
#[default]
#[serde(rename = "prompts/get")]
PromptsGet,
}
impl PromptsGetMethod {
pub const VALUE: &'static str = "prompts/get";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum PromptsListMethod {
#[default]
#[serde(rename = "prompts/list")]
PromptsList,
}
impl PromptsListMethod {
pub const VALUE: &'static str = "prompts/list";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReadResourceRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: ResourcesReadMethod,
#[serde(rename = "params")]
pub params: ReadResourceRequestParams,
}
impl ReadResourceRequest {
#[must_use]
pub fn new(id: RequestId, params: ReadResourceRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReadResourceRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(
rename = "inputResponses",
default,
skip_serializing_if = "Option::is_none"
)]
pub input_responses: Option<InputResponses>,
#[serde(
rename = "requestState",
default,
skip_serializing_if = "Option::is_none"
)]
pub request_state: Option<String>,
#[serde(rename = "uri")]
pub uri: String,
}
impl ReadResourceRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject, uri: String) -> Self {
Self {
meta,
input_responses: None,
request_state: None,
uri,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReadResourceResult {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "cacheScope")]
pub cache_scope: CacheScope,
#[serde(rename = "contents")]
pub contents: Vec<ReadResourceResultContentsItem>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(rename = "ttlMs")]
pub ttl_ms: u64,
}
impl ReadResourceResult {
#[must_use]
pub fn new(
cache_scope: CacheScope,
contents: Vec<ReadResourceResultContentsItem>,
result_type: String,
ttl_ms: u64,
) -> Self {
Self {
meta: None,
cache_scope,
contents,
result_type,
ttl_ms,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReadResourceResultContentsItem {
Text(TextResourceContents),
Blob(BlobResourceContents),
}
impl From<TextResourceContents> for ReadResourceResultContentsItem {
fn from(v: TextResourceContents) -> Self {
Self::Text(v)
}
}
impl From<BlobResourceContents> for ReadResourceResultContentsItem {
fn from(v: BlobResourceContents) -> Self {
Self::Blob(v)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReadResourceResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: ReadResourceResultResponseResult,
}
impl ReadResourceResultResponse {
#[must_use]
pub fn new(id: RequestId, result: ReadResourceResultResponseResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum ReadResourceResultResponseResult {
InputRequired(InputRequiredResult),
ReadResource(ReadResourceResult),
}
impl From<InputRequiredResult> for ReadResourceResultResponseResult {
fn from(v: InputRequiredResult) -> Self {
Self::InputRequired(v)
}
}
impl From<ReadResourceResult> for ReadResourceResultResponseResult {
fn from(v: ReadResourceResult) -> Self {
Self::ReadResource(v)
}
}
impl<'de> Deserialize<'de> for ReadResourceResultResponseResult {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("resultType")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("input_required") => serde_json::from_value(value)
.map(Self::InputRequired)
.map_err(D::Error::custom),
_ => serde_json::from_value(value)
.map(Self::ReadResource)
.map_err(D::Error::custom),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum RefPromptType {
#[default]
#[serde(rename = "ref/prompt")]
RefPrompt,
}
impl RefPromptType {
pub const VALUE: &'static str = "ref/prompt";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum RefResourceType {
#[default]
#[serde(rename = "ref/resource")]
RefResource,
}
impl RefResourceType {
pub const VALUE: &'static str = "ref/resource";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Request {
#[serde(rename = "method")]
pub method: String,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<serde_json::Map<String, serde_json::Value>>,
}
impl Request {
#[must_use]
pub fn new(method: String) -> Self {
Self {
method,
params: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
#[serde(untagged)]
pub enum RequestId {
String(String),
Integer(i64),
}
impl From<String> for RequestId {
fn from(v: String) -> Self {
Self::String(v)
}
}
impl From<&str> for RequestId {
fn from(v: &str) -> Self {
Self::String(v.to_owned())
}
}
impl From<i64> for RequestId {
fn from(v: i64) -> Self {
Self::Integer(v)
}
}
impl<'de> Deserialize<'de> for RequestId {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
struct Visitor;
impl serde::de::Visitor<'_> for Visitor {
type Value = RequestId;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("a string or an integer")
}
fn visit_str<E: serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<Self::Value, E> {
Ok(RequestId::String(v.to_owned()))
}
fn visit_string<E: serde::de::Error>(
self,
v: String,
) -> ::core::result::Result<Self::Value, E> {
Ok(RequestId::String(v))
}
fn visit_i64<E: serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<Self::Value, E> {
Ok(RequestId::Integer(v))
}
fn visit_u64<E: serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<Self::Value, E> {
i64::try_from(v)
.map(RequestId::Integer)
.map_err(|_| E::invalid_value(serde::de::Unexpected::Unsigned(v), &self))
}
#[allow(clippy::cast_possible_truncation, clippy::float_cmp)]
fn visit_f64<E: serde::de::Error>(
self,
v: f64,
) -> ::core::result::Result<Self::Value, E> {
const MAX_SAFE: f64 = 9_007_199_254_740_991.0;
if v.fract() == 0.0 && (-MAX_SAFE..=MAX_SAFE).contains(&v) {
Ok(RequestId::Integer(v as i64))
} else {
Err(E::invalid_type(serde::de::Unexpected::Float(v), &self))
}
}
}
deserializer.deserialize_any(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RequestMetaObject {
#[serde(rename = "io.modelcontextprotocol/clientCapabilities")]
pub client_capabilities: ClientCapabilities,
#[serde(
rename = "io.modelcontextprotocol/clientInfo",
default,
skip_serializing_if = "Option::is_none"
)]
pub client_info: Option<Implementation>,
#[deprecated(
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."
)]
#[serde(
rename = "io.modelcontextprotocol/logLevel",
default,
skip_serializing_if = "Option::is_none"
)]
pub log_level: Option<LoggingLevel>,
#[serde(rename = "io.modelcontextprotocol/protocolVersion")]
pub protocol_version: String,
#[serde(
rename = "progressToken",
default,
skip_serializing_if = "Option::is_none"
)]
pub progress_token: Option<ProgressToken>,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl RequestMetaObject {
#[must_use]
pub fn new(client_capabilities: ClientCapabilities, protocol_version: String) -> Self {
Self {
client_capabilities,
client_info: None,
log_level: None,
protocol_version,
progress_token: None,
extra: serde_json::Map::new(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
}
impl RequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject) -> Self {
Self { meta }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Resource {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "size", default, skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "uri")]
pub uri: String,
}
impl Resource {
#[must_use]
pub fn new(name: String, uri: String) -> Self {
Self {
meta: None,
annotations: None,
description: None,
icons: None,
mime_type: None,
name,
size: None,
title: None,
uri,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceContents {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "uri")]
pub uri: String,
}
impl ResourceContents {
#[must_use]
pub fn new(uri: String) -> Self {
Self {
meta: None,
mime_type: None,
uri,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceLink {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "size", default, skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: ResourceLinkType,
#[serde(rename = "uri")]
pub uri: String,
}
impl ResourceLink {
#[must_use]
pub fn new(name: String, uri: String) -> Self {
Self {
meta: None,
annotations: None,
description: None,
icons: None,
mime_type: None,
name,
size: None,
title: None,
r#type: Default::default(),
uri,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ResourceLinkType {
#[default]
#[serde(rename = "resource_link")]
ResourceLink,
}
impl ResourceLinkType {
pub const VALUE: &'static str = "resource_link";
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ResourceListChangedNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsResourcesListChangedMethod,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<NotificationParams>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(rename = "uri")]
pub uri: String,
}
impl ResourceRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject, uri: String) -> Self {
Self { meta, uri }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceTemplate {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "uriTemplate")]
pub uri_template: String,
}
impl ResourceTemplate {
#[must_use]
pub fn new(name: String, uri_template: String) -> Self {
Self {
meta: None,
annotations: None,
description: None,
icons: None,
mime_type: None,
name,
title: None,
uri_template,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceTemplateReference {
#[serde(rename = "type")]
pub r#type: RefResourceType,
#[serde(rename = "uri")]
pub uri: String,
}
impl ResourceTemplateReference {
#[must_use]
pub fn new(uri: String) -> Self {
Self {
r#type: Default::default(),
uri,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ResourceType {
#[default]
#[serde(rename = "resource")]
Resource,
}
impl ResourceType {
pub const VALUE: &'static str = "resource";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceUpdatedNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsResourcesUpdatedMethod,
#[serde(rename = "params")]
pub params: ResourceUpdatedNotificationParams,
}
impl ResourceUpdatedNotification {
#[must_use]
pub fn new(params: ResourceUpdatedNotificationParams) -> Self {
Self {
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceUpdatedNotificationParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<NotificationMetaObject>,
#[serde(rename = "uri")]
pub uri: String,
}
impl ResourceUpdatedNotificationParams {
#[must_use]
pub fn new(uri: String) -> Self {
Self { meta: None, uri }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ResourcesListMethod {
#[default]
#[serde(rename = "resources/list")]
ResourcesList,
}
impl ResourcesListMethod {
pub const VALUE: &'static str = "resources/list";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ResourcesReadMethod {
#[default]
#[serde(rename = "resources/read")]
ResourcesRead,
}
impl ResourcesReadMethod {
pub const VALUE: &'static str = "resources/read";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ResourcesTemplatesListMethod {
#[default]
#[serde(rename = "resources/templates/list")]
ResourcesTemplatesList,
}
impl ResourcesTemplatesListMethod {
pub const VALUE: &'static str = "resources/templates/list";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Result {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<ResultMetaObject>,
#[serde(rename = "resultType")]
pub result_type: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl Result {
#[must_use]
pub fn new(result_type: String) -> Self {
Self {
meta: None,
result_type,
extra: serde_json::Map::new(),
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ResultMetaObject {
#[serde(
rename = "io.modelcontextprotocol/serverInfo",
default,
skip_serializing_if = "Option::is_none"
)]
pub server_info: Option<Implementation>,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
pub type ResultType = String;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Role {
#[serde(rename = "assistant")]
Assistant,
#[serde(rename = "user")]
User,
}
impl Role {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Assistant => "assistant",
Self::User => "user",
}
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Root {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "uri")]
pub uri: String,
}
impl Root {
#[must_use]
pub fn new(uri: String) -> Self {
Self {
meta: None,
name: None,
uri,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum RootsListMethod {
#[default]
#[serde(rename = "roots/list")]
RootsList,
}
impl RootsListMethod {
pub const VALUE: &'static str = "roots/list";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum SamplingCreateMessageMethod {
#[default]
#[serde(rename = "sampling/createMessage")]
SamplingCreateMessage,
}
impl SamplingCreateMessageMethod {
pub const VALUE: &'static str = "sampling/createMessage";
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SamplingMessage {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "content")]
pub content: SamplingMessageContent,
#[serde(rename = "role")]
pub role: Role,
}
impl SamplingMessage {
#[must_use]
pub fn new(content: SamplingMessageContent, role: Role) -> Self {
Self {
meta: None,
content,
role,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SamplingMessageContent {
TextContent(TextContent),
ImageContent(ImageContent),
AudioContent(AudioContent),
ToolUseContent(ToolUseContent),
ToolResultContent(ToolResultContent),
List(Vec<SamplingMessageContentBlock>),
}
impl From<TextContent> for SamplingMessageContent {
fn from(v: TextContent) -> Self {
Self::TextContent(v)
}
}
impl From<ImageContent> for SamplingMessageContent {
fn from(v: ImageContent) -> Self {
Self::ImageContent(v)
}
}
impl From<AudioContent> for SamplingMessageContent {
fn from(v: AudioContent) -> Self {
Self::AudioContent(v)
}
}
impl From<ToolUseContent> for SamplingMessageContent {
fn from(v: ToolUseContent) -> Self {
Self::ToolUseContent(v)
}
}
impl From<ToolResultContent> for SamplingMessageContent {
fn from(v: ToolResultContent) -> Self {
Self::ToolResultContent(v)
}
}
impl From<Vec<SamplingMessageContentBlock>> for SamplingMessageContent {
fn from(v: Vec<SamplingMessageContentBlock>) -> Self {
Self::List(v)
}
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum SamplingMessageContentBlock {
Text(TextContent),
Image(ImageContent),
Audio(AudioContent),
ToolUse(ToolUseContent),
ToolResult(ToolResultContent),
}
impl From<TextContent> for SamplingMessageContentBlock {
fn from(v: TextContent) -> Self {
Self::Text(v)
}
}
impl From<ImageContent> for SamplingMessageContentBlock {
fn from(v: ImageContent) -> Self {
Self::Image(v)
}
}
impl From<AudioContent> for SamplingMessageContentBlock {
fn from(v: AudioContent) -> Self {
Self::Audio(v)
}
}
impl From<ToolUseContent> for SamplingMessageContentBlock {
fn from(v: ToolUseContent) -> Self {
Self::ToolUse(v)
}
}
impl From<ToolResultContent> for SamplingMessageContentBlock {
fn from(v: ToolResultContent) -> Self {
Self::ToolResult(v)
}
}
impl<'de> Deserialize<'de> for SamplingMessageContentBlock {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("type")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("text") => serde_json::from_value(value)
.map(Self::Text)
.map_err(D::Error::custom),
Some("image") => serde_json::from_value(value)
.map(Self::Image)
.map_err(D::Error::custom),
Some("audio") => serde_json::from_value(value)
.map(Self::Audio)
.map_err(D::Error::custom),
Some("tool_use") => serde_json::from_value(value)
.map(Self::ToolUse)
.map_err(D::Error::custom),
Some("tool_result") => serde_json::from_value(value)
.map(Self::ToolResult)
.map_err(D::Error::custom),
None => Err(D::Error::missing_field("type")),
Some(other) => Err(D::Error::unknown_variant(
other,
&["text", "image", "audio", "tool_use", "tool_result"],
)),
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ServerCapabilities {
#[serde(
rename = "completions",
default,
skip_serializing_if = "Option::is_none"
)]
pub completions: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(
rename = "experimental",
default,
skip_serializing_if = "Option::is_none"
)]
pub experimental:
Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
#[serde(
rename = "extensions",
default,
skip_serializing_if = "Option::is_none"
)]
pub extensions:
Option<std::collections::BTreeMap<String, serde_json::Map<String, serde_json::Value>>>,
#[deprecated(
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."
)]
#[serde(rename = "logging", default, skip_serializing_if = "Option::is_none")]
pub logging: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(rename = "prompts", default, skip_serializing_if = "Option::is_none")]
pub prompts: Option<ServerCapabilitiesPrompts>,
#[serde(rename = "resources", default, skip_serializing_if = "Option::is_none")]
pub resources: Option<ServerCapabilitiesResources>,
#[serde(rename = "tools", default, skip_serializing_if = "Option::is_none")]
pub tools: Option<ServerCapabilitiesTools>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ServerCapabilitiesPrompts {
#[serde(
rename = "listChanged",
default,
skip_serializing_if = "Option::is_none"
)]
pub list_changed: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ServerCapabilitiesResources {
#[serde(
rename = "listChanged",
default,
skip_serializing_if = "Option::is_none"
)]
pub list_changed: Option<bool>,
#[serde(rename = "subscribe", default, skip_serializing_if = "Option::is_none")]
pub subscribe: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ServerCapabilitiesTools {
#[serde(
rename = "listChanged",
default,
skip_serializing_if = "Option::is_none"
)]
pub list_changed: Option<bool>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ServerDiscoverMethod {
#[default]
#[serde(rename = "server/discover")]
ServerDiscover,
}
impl ServerDiscoverMethod {
pub const VALUE: &'static str = "server/discover";
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum ServerNotification {
Cancelled(CancelledNotification),
Progress(ProgressNotification),
ResourceListChanged(ResourceListChangedNotification),
SubscriptionsAcknowledged(SubscriptionsAcknowledgedNotification),
ResourceUpdated(ResourceUpdatedNotification),
PromptListChanged(PromptListChangedNotification),
ToolListChanged(ToolListChangedNotification),
LoggingMessage(LoggingMessageNotification),
}
impl From<CancelledNotification> for ServerNotification {
fn from(v: CancelledNotification) -> Self {
Self::Cancelled(v)
}
}
impl From<ProgressNotification> for ServerNotification {
fn from(v: ProgressNotification) -> Self {
Self::Progress(v)
}
}
impl From<ResourceListChangedNotification> for ServerNotification {
fn from(v: ResourceListChangedNotification) -> Self {
Self::ResourceListChanged(v)
}
}
impl From<SubscriptionsAcknowledgedNotification> for ServerNotification {
fn from(v: SubscriptionsAcknowledgedNotification) -> Self {
Self::SubscriptionsAcknowledged(v)
}
}
impl From<ResourceUpdatedNotification> for ServerNotification {
fn from(v: ResourceUpdatedNotification) -> Self {
Self::ResourceUpdated(v)
}
}
impl From<PromptListChangedNotification> for ServerNotification {
fn from(v: PromptListChangedNotification) -> Self {
Self::PromptListChanged(v)
}
}
impl From<ToolListChangedNotification> for ServerNotification {
fn from(v: ToolListChangedNotification) -> Self {
Self::ToolListChanged(v)
}
}
impl From<LoggingMessageNotification> for ServerNotification {
fn from(v: LoggingMessageNotification) -> Self {
Self::LoggingMessage(v)
}
}
impl<'de> Deserialize<'de> for ServerNotification {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> ::core::result::Result<Self, D::Error> {
use serde::de::Error as _;
let value = serde_json::Value::deserialize(deserializer)?;
let tag = value
.get("method")
.and_then(serde_json::Value::as_str)
.map(str::to_owned);
match tag.as_deref() {
Some("notifications/cancelled") => serde_json::from_value(value)
.map(Self::Cancelled)
.map_err(D::Error::custom),
Some("notifications/progress") => serde_json::from_value(value)
.map(Self::Progress)
.map_err(D::Error::custom),
Some("notifications/resources/list_changed") => serde_json::from_value(value)
.map(Self::ResourceListChanged)
.map_err(D::Error::custom),
Some("notifications/subscriptions/acknowledged") => serde_json::from_value(value)
.map(Self::SubscriptionsAcknowledged)
.map_err(D::Error::custom),
Some("notifications/resources/updated") => serde_json::from_value(value)
.map(Self::ResourceUpdated)
.map_err(D::Error::custom),
Some("notifications/prompts/list_changed") => serde_json::from_value(value)
.map(Self::PromptListChanged)
.map_err(D::Error::custom),
Some("notifications/tools/list_changed") => serde_json::from_value(value)
.map(Self::ToolListChanged)
.map_err(D::Error::custom),
Some("notifications/message") => serde_json::from_value(value)
.map(Self::LoggingMessage)
.map_err(D::Error::custom),
None => Err(D::Error::missing_field("method")),
Some(other) => Err(D::Error::unknown_variant(
other,
&[
"notifications/cancelled",
"notifications/progress",
"notifications/resources/list_changed",
"notifications/subscriptions/acknowledged",
"notifications/resources/updated",
"notifications/prompts/list_changed",
"notifications/tools/list_changed",
"notifications/message",
],
)),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SingleSelectEnumSchema {
Untitled(UntitledSingleSelectEnumSchema),
Titled(TitledSingleSelectEnumSchema),
}
impl From<UntitledSingleSelectEnumSchema> for SingleSelectEnumSchema {
fn from(v: UntitledSingleSelectEnumSchema) -> Self {
Self::Untitled(v)
}
}
impl From<TitledSingleSelectEnumSchema> for SingleSelectEnumSchema {
fn from(v: TitledSingleSelectEnumSchema) -> Self {
Self::Titled(v)
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct StringSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<String>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "format", default, skip_serializing_if = "Option::is_none")]
pub format: Option<StringSchemaFormat>,
#[serde(rename = "maxLength", default, skip_serializing_if = "Option::is_none")]
pub max_length: Option<i64>,
#[serde(rename = "minLength", default, skip_serializing_if = "Option::is_none")]
pub min_length: Option<i64>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: StringType,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StringSchemaFormat {
#[serde(rename = "date")]
Date,
#[serde(rename = "date-time")]
DateTime,
#[serde(rename = "email")]
Email,
#[serde(rename = "uri")]
Uri,
}
impl StringSchemaFormat {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Date => "date",
Self::DateTime => "date-time",
Self::Email => "email",
Self::Uri => "uri",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum StringType {
#[default]
#[serde(rename = "string")]
String,
}
impl StringType {
pub const VALUE: &'static str = "string";
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct SubscriptionFilter {
#[serde(
rename = "promptsListChanged",
default,
skip_serializing_if = "Option::is_none"
)]
pub prompts_list_changed: Option<bool>,
#[serde(
rename = "resourceSubscriptions",
default,
skip_serializing_if = "Option::is_none"
)]
pub resource_subscriptions: Option<Vec<String>>,
#[serde(
rename = "resourcesListChanged",
default,
skip_serializing_if = "Option::is_none"
)]
pub resources_list_changed: Option<bool>,
#[serde(
rename = "toolsListChanged",
default,
skip_serializing_if = "Option::is_none"
)]
pub tools_list_changed: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsAcknowledgedNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsSubscriptionsAcknowledgedMethod,
#[serde(rename = "params")]
pub params: SubscriptionsAcknowledgedNotificationParams,
}
impl SubscriptionsAcknowledgedNotification {
#[must_use]
pub fn new(params: SubscriptionsAcknowledgedNotificationParams) -> Self {
Self {
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsAcknowledgedNotificationParams {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<NotificationMetaObject>,
#[serde(rename = "notifications")]
pub notifications: SubscriptionFilter,
}
impl SubscriptionsAcknowledgedNotificationParams {
#[must_use]
pub fn new(notifications: SubscriptionFilter) -> Self {
Self {
meta: None,
notifications,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum SubscriptionsListenMethod {
#[default]
#[serde(rename = "subscriptions/listen")]
SubscriptionsListen,
}
impl SubscriptionsListenMethod {
pub const VALUE: &'static str = "subscriptions/listen";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsListenRequest {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: SubscriptionsListenMethod,
#[serde(rename = "params")]
pub params: SubscriptionsListenRequestParams,
}
impl SubscriptionsListenRequest {
#[must_use]
pub fn new(id: RequestId, params: SubscriptionsListenRequestParams) -> Self {
Self {
id,
jsonrpc: Default::default(),
method: Default::default(),
params,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsListenRequestParams {
#[serde(rename = "_meta")]
pub meta: RequestMetaObject,
#[serde(rename = "notifications")]
pub notifications: SubscriptionFilter,
}
impl SubscriptionsListenRequestParams {
#[must_use]
pub fn new(meta: RequestMetaObject, notifications: SubscriptionFilter) -> Self {
Self {
meta,
notifications,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsListenResult {
#[serde(rename = "_meta")]
pub meta: SubscriptionsListenResultMetaObject,
#[serde(rename = "resultType")]
pub result_type: String,
}
impl SubscriptionsListenResult {
#[must_use]
pub fn new(meta: SubscriptionsListenResultMetaObject, result_type: String) -> Self {
Self { meta, result_type }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsListenResultMetaObject {
#[serde(
rename = "io.modelcontextprotocol/serverInfo",
default,
skip_serializing_if = "Option::is_none"
)]
pub server_info: Option<Implementation>,
#[serde(rename = "io.modelcontextprotocol/subscriptionId")]
pub subscription_id: RequestId,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl SubscriptionsListenResultMetaObject {
#[must_use]
pub fn new(subscription_id: RequestId) -> Self {
Self {
server_info: None,
subscription_id,
extra: serde_json::Map::new(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SubscriptionsListenResultResponse {
#[serde(rename = "id")]
pub id: RequestId,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "result")]
pub result: SubscriptionsListenResult,
}
impl SubscriptionsListenResultResponse {
#[must_use]
pub fn new(id: RequestId, result: SubscriptionsListenResult) -> Self {
Self {
id,
jsonrpc: Default::default(),
result,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TextContent {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<Annotations>,
#[serde(rename = "text")]
pub text: String,
#[serde(rename = "type")]
pub r#type: TextType,
}
impl TextContent {
#[must_use]
pub fn new(text: String) -> Self {
Self {
meta: None,
annotations: None,
text,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TextResourceContents {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(rename = "text")]
pub text: String,
#[serde(rename = "uri")]
pub uri: String,
}
impl TextResourceContents {
#[must_use]
pub fn new(text: String, uri: String) -> Self {
Self {
meta: None,
mime_type: None,
text,
uri,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum TextType {
#[default]
#[serde(rename = "text")]
Text,
}
impl TextType {
pub const VALUE: &'static str = "text";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TitledMultiSelectEnumSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<Vec<String>>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "items")]
pub items: TitledMultiSelectEnumSchemaItems,
#[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
#[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")]
pub min_items: Option<i64>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: ArrayType,
}
impl TitledMultiSelectEnumSchema {
#[must_use]
pub fn new(items: TitledMultiSelectEnumSchemaItems) -> Self {
Self {
default: None,
description: None,
items,
max_items: None,
min_items: None,
title: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TitledMultiSelectEnumSchemaItems {
#[serde(rename = "anyOf")]
pub any_of: Vec<TitledMultiSelectEnumSchemaItemsAnyOfItem>,
}
impl TitledMultiSelectEnumSchemaItems {
#[must_use]
pub fn new(any_of: Vec<TitledMultiSelectEnumSchemaItemsAnyOfItem>) -> Self {
Self { any_of }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TitledMultiSelectEnumSchemaItemsAnyOfItem {
#[serde(rename = "const")]
pub r#const: String,
#[serde(rename = "title")]
pub title: String,
}
impl TitledMultiSelectEnumSchemaItemsAnyOfItem {
#[must_use]
pub fn new(r#const: String, title: String) -> Self {
Self { r#const, title }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TitledSingleSelectEnumSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<String>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "oneOf")]
pub one_of: Vec<TitledSingleSelectEnumSchemaOneOfItem>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: StringType,
}
impl TitledSingleSelectEnumSchema {
#[must_use]
pub fn new(one_of: Vec<TitledSingleSelectEnumSchemaOneOfItem>) -> Self {
Self {
default: None,
description: None,
one_of,
title: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TitledSingleSelectEnumSchemaOneOfItem {
#[serde(rename = "const")]
pub r#const: String,
#[serde(rename = "title")]
pub title: String,
}
impl TitledSingleSelectEnumSchemaOneOfItem {
#[must_use]
pub fn new(r#const: String, title: String) -> Self {
Self { r#const, title }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Tool {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(
rename = "annotations",
default,
skip_serializing_if = "Option::is_none"
)]
pub annotations: Option<ToolAnnotations>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "icons", default, skip_serializing_if = "Option::is_none")]
pub icons: Option<Vec<Icon>>,
#[serde(rename = "inputSchema")]
pub input_schema: ToolInputSchema,
#[serde(rename = "name")]
pub name: String,
#[serde(
rename = "outputSchema",
default,
skip_serializing_if = "Option::is_none"
)]
pub output_schema: Option<ToolOutputSchema>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
impl Tool {
#[must_use]
pub fn new(input_schema: ToolInputSchema, name: String) -> Self {
Self {
meta: None,
annotations: None,
description: None,
icons: None,
input_schema,
name,
output_schema: None,
title: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ToolAnnotations {
#[serde(
rename = "destructiveHint",
default,
skip_serializing_if = "Option::is_none"
)]
pub destructive_hint: Option<bool>,
#[serde(
rename = "idempotentHint",
default,
skip_serializing_if = "Option::is_none"
)]
pub idempotent_hint: Option<bool>,
#[serde(
rename = "openWorldHint",
default,
skip_serializing_if = "Option::is_none"
)]
pub open_world_hint: Option<bool>,
#[serde(
rename = "readOnlyHint",
default,
skip_serializing_if = "Option::is_none"
)]
pub read_only_hint: Option<bool>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ToolChoice {
#[serde(rename = "mode", default, skip_serializing_if = "Option::is_none")]
pub mode: Option<ToolChoiceMode>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ToolChoiceMode {
#[serde(rename = "auto")]
Auto,
#[serde(rename = "none")]
None,
#[serde(rename = "required")]
Required,
}
impl ToolChoiceMode {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Auto => "auto",
Self::None => "none",
Self::Required => "required",
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ToolInputSchema {
#[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(rename = "type")]
pub r#type: ObjectType,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ToolListChangedNotification {
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
#[serde(rename = "method")]
pub method: NotificationsToolsListChangedMethod,
#[serde(rename = "params", default, skip_serializing_if = "Option::is_none")]
pub params: Option<NotificationParams>,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ToolOutputSchema {
#[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ToolResultContent {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "content")]
pub content: Vec<ContentBlock>,
#[serde(rename = "isError", default, skip_serializing_if = "Option::is_none")]
pub is_error: Option<bool>,
#[serde(
rename = "structuredContent",
default,
skip_serializing_if = "Option::is_none"
)]
pub structured_content: Option<serde_json::Value>,
#[serde(rename = "toolUseId")]
pub tool_use_id: String,
#[serde(rename = "type")]
pub r#type: ToolResultType,
}
impl ToolResultContent {
#[must_use]
pub fn new(content: Vec<ContentBlock>, tool_use_id: String) -> Self {
Self {
meta: None,
content,
is_error: None,
structured_content: None,
tool_use_id,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ToolResultType {
#[default]
#[serde(rename = "tool_result")]
ToolResult,
}
impl ToolResultType {
pub const VALUE: &'static str = "tool_result";
}
#[deprecated(
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."
)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ToolUseContent {
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
pub meta: Option<MetaObject>,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "input")]
pub input: serde_json::Map<String, serde_json::Value>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "type")]
pub r#type: ToolUseType,
}
impl ToolUseContent {
#[must_use]
pub fn new(
id: String,
input: serde_json::Map<String, serde_json::Value>,
name: String,
) -> Self {
Self {
meta: None,
id,
input,
name,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ToolUseType {
#[default]
#[serde(rename = "tool_use")]
ToolUse,
}
impl ToolUseType {
pub const VALUE: &'static str = "tool_use";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ToolsCallMethod {
#[default]
#[serde(rename = "tools/call")]
ToolsCall,
}
impl ToolsCallMethod {
pub const VALUE: &'static str = "tools/call";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum ToolsListMethod {
#[default]
#[serde(rename = "tools/list")]
ToolsList,
}
impl ToolsListMethod {
pub const VALUE: &'static str = "tools/list";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UnsupportedProtocolVersionError {
#[serde(rename = "error")]
pub error: UnsupportedProtocolVersionErrorObject,
#[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
pub id: Option<RequestId>,
#[serde(rename = "jsonrpc")]
pub jsonrpc: JsonRpcVersion,
}
impl UnsupportedProtocolVersionError {
#[must_use]
pub fn new(error: UnsupportedProtocolVersionErrorObject) -> Self {
Self {
error,
id: None,
jsonrpc: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UnsupportedProtocolVersionErrorData {
#[serde(rename = "requested")]
pub requested: String,
#[serde(rename = "supported")]
pub supported: Vec<String>,
}
impl UnsupportedProtocolVersionErrorData {
#[must_use]
pub fn new(requested: String, supported: Vec<String>) -> Self {
Self {
requested,
supported,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UnsupportedProtocolVersionErrorObject {
#[serde(rename = "code")]
pub code: i64,
#[serde(rename = "data")]
pub data: UnsupportedProtocolVersionErrorData,
#[serde(rename = "message")]
pub message: String,
}
impl UnsupportedProtocolVersionErrorObject {
#[must_use]
pub fn new(code: i64, data: UnsupportedProtocolVersionErrorData, message: String) -> Self {
Self {
code,
data,
message,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UntitledMultiSelectEnumSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<Vec<String>>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "items")]
pub items: UntitledMultiSelectEnumSchemaItems,
#[serde(rename = "maxItems", default, skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
#[serde(rename = "minItems", default, skip_serializing_if = "Option::is_none")]
pub min_items: Option<i64>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: ArrayType,
}
impl UntitledMultiSelectEnumSchema {
#[must_use]
pub fn new(items: UntitledMultiSelectEnumSchemaItems) -> Self {
Self {
default: None,
description: None,
items,
max_items: None,
min_items: None,
title: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UntitledMultiSelectEnumSchemaItems {
#[serde(rename = "enum")]
pub r#enum: Vec<String>,
#[serde(rename = "type")]
pub r#type: StringType,
}
impl UntitledMultiSelectEnumSchemaItems {
#[must_use]
pub fn new(r#enum: Vec<String>) -> Self {
Self {
r#enum,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UntitledSingleSelectEnumSchema {
#[serde(rename = "default", default, skip_serializing_if = "Option::is_none")]
pub default: Option<String>,
#[serde(
rename = "description",
default,
skip_serializing_if = "Option::is_none"
)]
pub description: Option<String>,
#[serde(rename = "enum")]
pub r#enum: Vec<String>,
#[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "type")]
pub r#type: StringType,
}
impl UntitledSingleSelectEnumSchema {
#[must_use]
pub fn new(r#enum: Vec<String>) -> Self {
Self {
default: None,
description: None,
r#enum,
title: None,
r#type: Default::default(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub enum UrlMode {
#[default]
#[serde(rename = "url")]
Url,
}
impl UrlMode {
pub const VALUE: &'static str = "url";
}