pub enum McpError {
Show 17 variants
    VersionMismatch {
        expected: String,
        actual: String,
    },
    InvalidCapability(String),
    ToolNotFound(String),
    ResourceNotFound(String),
    PromptNotFound(String),
    InvalidParameters(String),
    MissingParameter(String),
    InvalidParameterType {
        param: String,
        expected: String,
        actual: String,
    },
    ParameterOutOfRange {
        param: String,
        value: String,
        constraint: String,
    },
    ToolExecutionError(String),
    ResourceAccessDenied(String),
    ConfigurationError(String),
    SessionError(String),
    ValidationError(String),
    IoError(Error),
    SerializationError(Error),
    JsonRpcError(JsonRpcError),
}Expand description
MCP-specific errors
Variants§
VersionMismatch
InvalidCapability(String)
ToolNotFound(String)
ResourceNotFound(String)
PromptNotFound(String)
InvalidParameters(String)
MissingParameter(String)
InvalidParameterType
ParameterOutOfRange
ToolExecutionError(String)
ResourceAccessDenied(String)
ConfigurationError(String)
SessionError(String)
ValidationError(String)
IoError(Error)
SerializationError(Error)
JsonRpcError(JsonRpcError)
Implementations§
Source§impl McpError
 
impl McpError
Sourcepub fn missing_param(param: &str) -> McpError
 
pub fn missing_param(param: &str) -> McpError
Create a missing parameter error
Sourcepub fn invalid_param_type(param: &str, expected: &str, actual: &str) -> McpError
 
pub fn invalid_param_type(param: &str, expected: &str, actual: &str) -> McpError
Create an invalid parameter type error
Sourcepub fn param_out_of_range(
    param: &str,
    value: &str,
    constraint: &str,
) -> McpError
 
pub fn param_out_of_range( param: &str, value: &str, constraint: &str, ) -> McpError
Create a parameter out of range error
Sourcepub fn tool_execution(message: &str) -> McpError
 
pub fn tool_execution(message: &str) -> McpError
Create a tool execution error
Sourcepub fn validation(message: &str) -> McpError
 
pub fn validation(message: &str) -> McpError
Create a validation error
Sourcepub fn configuration(message: &str) -> McpError
 
pub fn configuration(message: &str) -> McpError
Create a configuration error
Sourcepub fn to_json_rpc_error(&self) -> JsonRpcErrorObject
 
pub fn to_json_rpc_error(&self) -> JsonRpcErrorObject
Convert to a JsonRpcErrorObject for JSON-RPC 2.0 responses
Sourcepub fn to_json_rpc_response(&self, id: Option<RequestId>) -> JsonRpcError
 
pub fn to_json_rpc_response(&self, id: Option<RequestId>) -> JsonRpcError
Create a JSON-RPC error response for this MCP error
Trait Implementations§
Source§impl Error for McpError
 
impl Error for McpError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
 
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
 
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<JsonRpcError> for McpError
 
impl From<JsonRpcError> for McpError
Source§fn from(source: JsonRpcError) -> McpError
 
fn from(source: JsonRpcError) -> McpError
Converts to this type from the input type.
Source§impl From<McpError> for HttpMcpError
 
impl From<McpError> for HttpMcpError
Auto Trait Implementations§
impl Freeze for McpError
impl !RefUnwindSafe for McpError
impl Send for McpError
impl Sync for McpError
impl Unpin for McpError
impl !UnwindSafe for McpError
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
Mutably borrows from an owned value. Read more