pub enum McpError {
Show 22 variants
VersionMismatch {
expected: String,
actual: String,
},
InvalidCapability(String),
ToolNotFound(String),
ResourceNotFound(String),
PromptNotFound(String),
InvalidRequest {
message: String,
},
InvalidParameters(String),
MissingParameter(String),
InvalidParameterType {
param: String,
expected: String,
actual: String,
},
ParameterOutOfRange {
param: String,
value: String,
constraint: String,
},
ToolExecutionError(String),
ResourceExecutionError(String),
PromptExecutionError(String),
ResourceAccessDenied(String),
ConfigurationError(String),
SessionError(String),
ValidationError(String),
IoError(Error),
SerializationError(Error),
TransportError(String),
JsonRpcProtocolError(String),
JsonRpcError {
code: i64,
message: String,
data: Option<Value>,
},
}Expand description
MCP-specific errors
Variants§
VersionMismatch
InvalidCapability(String)
ToolNotFound(String)
ResourceNotFound(String)
PromptNotFound(String)
InvalidRequest
InvalidParameters(String)
MissingParameter(String)
InvalidParameterType
ParameterOutOfRange
ToolExecutionError(String)
ResourceExecutionError(String)
PromptExecutionError(String)
ResourceAccessDenied(String)
ConfigurationError(String)
SessionError(String)
ValidationError(String)
IoError(Error)
SerializationError(Error)
TransportError(String)
JsonRpcProtocolError(String)
JsonRpcError
A JSON-RPC error with preserved code, message, and optional data.
Used by tasks/result to reproduce the original error verbatim, as
required by the MCP spec: “tasks/result MUST return that same JSON-RPC error.”
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 resource_execution(message: &str) -> McpError
pub fn resource_execution(message: &str) -> McpError
Create a resource execution error
Sourcepub fn prompt_execution(message: &str) -> McpError
pub fn prompt_execution(message: &str) -> McpError
Create a prompt 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 json_rpc_protocol(message: &str) -> McpError
pub fn json_rpc_protocol(message: &str) -> McpError
Create a JSON-RPC protocol error
Sourcepub fn json_rpc_error(
code: i64,
message: impl Into<String>,
data: Option<Value>,
) -> McpError
pub fn json_rpc_error( code: i64, message: impl Into<String>, data: Option<Value>, ) -> McpError
Create a JSON-RPC error with preserved code, message, and optional data.
Used by tasks/result to reproduce original errors verbatim.
Sourcepub fn to_error_object(&self) -> JsonRpcErrorObject
pub fn to_error_object(&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
Sourcepub fn to_json_rpc_error(&self) -> JsonRpcErrorObject
👎Deprecated: Use to_error_object() instead for cleaner architecture
pub fn to_json_rpc_error(&self) -> JsonRpcErrorObject
Use to_error_object() instead for cleaner architecture
Legacy method for backward compatibility - use to_error_object() instead
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl ToJsonRpcError for McpError
impl ToJsonRpcError for McpError
Source§fn to_error_object(&self) -> JsonRpcErrorObject
fn to_error_object(&self) -> JsonRpcErrorObject
Auto Trait Implementations§
impl Freeze for McpError
impl !RefUnwindSafe for McpError
impl Send for McpError
impl Sync for McpError
impl Unpin for McpError
impl UnsafeUnpin 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more