pub enum McpToolError {
Show 18 variants
ArgumentsMustBeObject,
MissingField {
field: String,
},
UnexpectedNull {
field: String,
},
DuplicateField {
field: String,
},
DecodeField {
field: String,
message: String,
},
UnknownField {
field: String,
},
InvalidFieldValue {
field: String,
value: String,
},
Validation {
message: String,
details: Vec<Value>,
},
InvalidToolOutput {
name: String,
message: String,
},
Conversion {
message: String,
},
Handler {
message: String,
},
InvalidSchema {
label: String,
message: String,
},
DuplicateTool {
name: String,
},
UnknownTool {
name: String,
},
DuplicateResource {
uri: String,
},
UnknownResource {
uri: String,
},
DuplicatePrompt {
name: String,
},
UnknownPrompt {
name: String,
},
}Expand description
Typed setup, decoding, validation, and handler error used by MCP helpers.
Variants§
ArgumentsMustBeObject
Tool arguments were omitted or supplied as a non-object JSON value.
MissingField
A required tool argument field is missing.
UnexpectedNull
A non-nullable tool argument field was supplied as JSON null.
DuplicateField
A field was supplied by multiple accepted wire names.
DecodeField
A field could not be decoded into its typed Rust value.
UnknownField
A raw argument field remains after typed decoding finishes.
InvalidFieldValue
A field value is outside the accepted schema or enum values.
Validation
Validation rejected a value or metadata object.
InvalidToolOutput
A handler returned structured content that does not match its output schema.
Conversion
A value conversion failed.
Handler
A handler returned an application-level failure.
InvalidSchema
A schema or metadata definition is invalid.
DuplicateTool
A tool with the same name is already registered.
UnknownTool
A requested tool name is not registered.
DuplicateResource
A resource with the same URI is already registered.
UnknownResource
A requested resource URI is not registered.
DuplicatePrompt
A prompt with the same name is already registered.
UnknownPrompt
A requested prompt name is not registered.
Implementations§
Source§impl McpToolError
impl McpToolError
Sourcepub const fn kind(&self) -> &'static str
pub const fn kind(&self) -> &'static str
Stable machine-readable error kind used in MCP structured error content.
Sourcepub fn to_structured_value(&self) -> Value
pub fn to_structured_value(&self) -> Value
Build the structured_content.error object for this typed MCP error.
Sourcepub fn missing_field(field: impl Into<String>) -> Self
pub fn missing_field(field: impl Into<String>) -> Self
Build a missing-field error.
Sourcepub fn decode(field: impl Into<String>, message: impl Into<String>) -> Self
pub fn decode(field: impl Into<String>, message: impl Into<String>) -> Self
Build a field decoding error.
Sourcepub fn invalid_field_value(
field: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn invalid_field_value( field: impl Into<String>, value: impl Into<String>, ) -> Self
Build an invalid field value error.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Build a validation error with a text message.
Sourcepub fn validation_details(
details: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn validation_details( details: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Build a validation error from text details.
Sourcepub fn validation_structured_details(
message: impl Into<String>,
details: impl IntoIterator<Item = Value>,
) -> Self
pub fn validation_structured_details( message: impl Into<String>, details: impl IntoIterator<Item = Value>, ) -> Self
Build a validation error with machine-readable structured details.
Sourcepub fn conversion(message: impl Into<String>) -> Self
pub fn conversion(message: impl Into<String>) -> Self
Build a conversion error.
Sourcepub fn invalid_tool_output(
name: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn invalid_tool_output( name: impl Into<String>, message: impl Into<String>, ) -> Self
Build an invalid tool-output error.
Sourcepub fn invalid_schema(
label: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn invalid_schema( label: impl Into<String>, message: impl Into<String>, ) -> Self
Build an invalid schema or metadata error.
Sourcepub fn duplicate_tool(name: impl Into<String>) -> Self
pub fn duplicate_tool(name: impl Into<String>) -> Self
Build a duplicate tool registration error.
Sourcepub fn duplicate_resource(uri: impl Into<String>) -> Self
pub fn duplicate_resource(uri: impl Into<String>) -> Self
Build a duplicate resource registration error.
Sourcepub fn unknown_resource(uri: impl Into<String>) -> Self
pub fn unknown_resource(uri: impl Into<String>) -> Self
Build an unknown resource lookup error.
Sourcepub fn duplicate_prompt(name: impl Into<String>) -> Self
pub fn duplicate_prompt(name: impl Into<String>) -> Self
Build a duplicate prompt registration error.
Sourcepub fn unknown_prompt(name: impl Into<String>) -> Self
pub fn unknown_prompt(name: impl Into<String>) -> Self
Build an unknown prompt lookup error.
Trait Implementations§
Source§impl Clone for McpToolError
impl Clone for McpToolError
Source§impl Debug for McpToolError
impl Debug for McpToolError
Source§impl Display for McpToolError
impl Display for McpToolError
impl Eq for McpToolError
Source§impl Error for McpToolError
impl Error for McpToolError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for McpToolError
impl PartialEq for McpToolError
impl StructuralPartialEq for McpToolError
Auto Trait Implementations§
impl Freeze for McpToolError
impl RefUnwindSafe for McpToolError
impl Send for McpToolError
impl Sync for McpToolError
impl Unpin for McpToolError
impl UnsafeUnpin for McpToolError
impl UnwindSafe for McpToolError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.