Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: update function argument types to improve flexibility and type #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
hashemix merged 3 commits into main from chore/improve-call-tool-error-methods
Aug 30, 2025
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
25 changes: 16 additions & 9 deletions src/generated_schema/2024_11_05/schema_utils.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1465,14 +1465,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}" ),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

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

Self::from_message(full_message)
}

Expand Down Expand Up @@ -1513,7 +1521,6 @@ impl CallToolError {
}
}


/// Converts a `CallToolError` into a `RpcError`.
///
/// The conversion creates an internal error variant of `RpcError`
Expand Down
25 changes: 16 additions & 9 deletions src/generated_schema/2025_03_26/schema_utils.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1465,14 +1465,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}" ),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

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

Self::from_message(full_message)
}

Expand Down Expand Up @@ -1513,7 +1521,6 @@ impl CallToolError {
}
}


/// Converts a `CallToolError` into a `RpcError`.
///
/// The conversion creates an internal error variant of `RpcError`
Expand Down
24 changes: 16 additions & 8 deletions src/generated_schema/2025_06_18/schema_utils.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1466,14 +1466,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}"),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

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

Self::from_message(full_message)
}

Expand Down
24 changes: 16 additions & 8 deletions src/generated_schema/draft/schema_utils.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1468,14 +1468,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}"),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

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

Self::from_message(full_message)
}

Expand Down

AltStyle によって変換されたページ (->オリジナル) /