Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/generated_schema/2024_11_05/mcp_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : a470342d05c345b580642821605b9c885bad237b
/// Generated at : 2025-08-29 19:12:22
/// Hash : 3473e6e72b222f44163b41eab8d4b0973ac106b6
/// Generated at : 2025-09-17 19:15:48
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
3 changes: 2 additions & 1 deletion src/generated_schema/2024_11_05/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ impl CallToolError {
let message = message.unwrap_or(default_message);

// Format the full error message
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}");
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}" );

Self::from_message(full_message)
}
Expand Down Expand Up @@ -1521,6 +1521,7 @@ impl CallToolError {
}
}


/// Converts a `CallToolError` into a `RpcError`.
///
/// The conversion creates an internal error variant of `RpcError`
Expand Down
4 changes: 2 additions & 2 deletions src/generated_schema/2025_03_26/mcp_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : a470342d05c345b580642821605b9c885bad237b
/// Generated at : 2025-08-29 19:12:23
/// Hash : 3473e6e72b222f44163b41eab8d4b0973ac106b6
/// Generated at : 2025-09-17 19:15:50
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down
3 changes: 2 additions & 1 deletion src/generated_schema/2025_03_26/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ impl CallToolError {
let message = message.unwrap_or(default_message);

// Format the full error message
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}");
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}" );

Self::from_message(full_message)
}
Expand Down Expand Up @@ -1521,6 +1521,7 @@ impl CallToolError {
}
}


/// Converts a `CallToolError` into a `RpcError`.
///
/// The conversion creates an internal error variant of `RpcError`
Expand Down
12 changes: 7 additions & 5 deletions src/generated_schema/2025_06_18/mcp_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// modify or extend the implementations as needed, but please do so at your own risk.
///
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
/// Hash : a470342d05c345b580642821605b9c885bad237b
/// Generated at : 2025-08-29 19:12:24
/// Hash : 3473e6e72b222f44163b41eab8d4b0973ac106b6
/// Generated at : 2025-09-17 19:15:50
/// ----------------------------------------------------------------------------
///
/// MCP Protocol Version
Expand Down Expand Up @@ -1693,7 +1693,7 @@ pub struct ElicitRequestParams {
///The message to present to the user.
pub message: ::std::string::String,
#[serde(rename = "requestedSchema")]
pub requested_schema: ElicitRequestParamsRequestedSchema,
pub requested_schema: ElicitRequestedSchema,
}
/**A restricted subset of JSON Schema.
Only top-level properties are allowed, without nesting.*/
Expand Down Expand Up @@ -1730,14 +1730,14 @@ Only top-level properties are allowed, without nesting.*/
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct ElicitRequestParamsRequestedSchema {
pub struct ElicitRequestedSchema {
pub properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>,
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub required: ::std::vec::Vec<::std::string::String>,
#[serde(rename = "type")]
type_: ::std::string::String,
}
impl ElicitRequestParamsRequestedSchema {
impl ElicitRequestedSchema {
pub fn new(
properties: ::std::collections::HashMap<::std::string::String, PrimitiveSchemaDefinition>,
required: ::std::vec::Vec<::std::string::String>,
Expand Down Expand Up @@ -7169,3 +7169,5 @@ impl ServerNotification {
}
#[deprecated(since = "0.3.0", note = "Use `RpcError` instead.")]
pub type JsonrpcErrorError = RpcError;
#[deprecated(since = "0.7.0", note = "Use `ElicitRequestedSchema` instead.")]
pub type ElicitRequestParamsRequestedSchema = ElicitRequestedSchema;
116 changes: 116 additions & 0 deletions src/generated_schema/2025_06_18/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,122 @@ impl From<Vec<MessageFromClient>> for MessagesFromClient {
}
}

#[derive(Debug)]
pub struct StringSchemaFormatError {
invalid_value: String,
}

impl core::fmt::Display for StringSchemaFormatError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Invalid string schema format: '{}'", self.invalid_value)
}
}

impl std::error::Error for StringSchemaFormatError {}

impl FromStr for StringSchemaFormat {
type Err = StringSchemaFormatError;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s {
"date" => Ok(Self::Date),
"date-time" => Ok(Self::DateTime),
"email" => Ok(Self::Email),
"uri" => Ok(Self::Uri),
_ => Err(StringSchemaFormatError {
invalid_value: s.to_string(),
}),
}
}
}

impl TryFrom<&serde_json::Map<String, Value>> for PrimitiveSchemaDefinition {
type Error = RpcError;

fn try_from(value: &serde_json::Map<String, serde_json::Value>) -> result::Result<Self, Self::Error> {
let input_type = value
.get("type")
.and_then(|v| v.as_str())
.or_else(|| value.get("oneOf").map(|_| "enum")) // if "oneOf" exists, return "enum"
.ok_or_else(|| {
RpcError::parse_error().with_message("'type' is missing and data type is not supported!".to_string())
})?;

let description = value.get("description").and_then(|v| v.as_str().map(|s| s.to_string()));
let title = value.get("title").and_then(|v| v.as_str().map(|s| s.to_string()));

let schema_definition: PrimitiveSchemaDefinition = match input_type {
"string" => {
let max_length = value.get("maxLength").and_then(|v| v.as_number().and_then(|n| n.as_i64()));
let min_length = value.get("minLength").and_then(|v| v.as_number().and_then(|n| n.as_i64()));

let format_str = value.get("format").and_then(|v| v.as_str());
let format = format_str.and_then(|s| StringSchemaFormat::from_str(s).ok());

PrimitiveSchemaDefinition::StringSchema(StringSchema::new(
description,
format,
max_length,
min_length,
title,
))
}
"number" | "integer" => {
let maximum = value.get("maximum").and_then(|v| v.as_number().and_then(|n| n.as_i64()));
let minimum = value.get("minimum").and_then(|v| v.as_number().and_then(|n| n.as_i64()));
PrimitiveSchemaDefinition::NumberSchema(NumberSchema {
description,
maximum,
minimum,
title,
type_: if input_type == "integer" {
NumberSchemaType::Integer
} else {
NumberSchemaType::Number
},
})
}
"boolean" => {
let default = value.get("default").and_then(|v| v.as_bool().map(|s| s.to_owned()));
PrimitiveSchemaDefinition::BooleanSchema(BooleanSchema::new(default, description, title))
}

"enum" => {
let mut enum_values: ::std::vec::Vec<::std::string::String> = vec![];
let mut enum_names: ::std::vec::Vec<::std::string::String> = vec![];
let values = value.get("oneOf").and_then(|v| v.as_array()).ok_or_else(|| {
RpcError::parse_error()
.with_message("Unsupported enum type, only simple enums are supported!".to_string())
})?;

for v in values {
let title = v.get("title").and_then(|v| v.as_str().map(|s| s.to_string()));
let enum_value = v.get("enum").and_then(|v| v.as_array()).ok_or_else(|| {
RpcError::parse_error()
.with_message("Unsupported enum type. only simple enums are supported!".to_string())
})?;
let enum_value = enum_value
.first()
.and_then(|s| s.as_str().map(|s| s.to_string()))
.ok_or_else(|| {
RpcError::parse_error()
.with_message("Unsupported enum value, only simple enums are supported!".to_string())
})?;

enum_values.push(enum_value.to_owned());
enum_names.push(title.unwrap_or(enum_value));
}
PrimitiveSchemaDefinition::EnumSchema(EnumSchema::new(enum_values, enum_names, description, title))
}
other => {
panic!("'{other}' type is not currently supported");
}
};

Ok(schema_definition)
}
}

#[deprecated(since = "0.4.0", note = "This trait was renamed to RpcMessage. Use RpcMessage instead.")]
pub type RPCMessage = ();
#[deprecated(since = "0.4.0", note = "This trait was renamed to McpMessage. Use McpMessage instead.")]
Expand Down
Loading