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
Core MCP protocol types and error handling 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()