McpError

Enum McpError 

Source
pub enum McpError {
Show 20 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), ResourceExecutionError(String), PromptExecutionError(String), ResourceAccessDenied(String), ConfigurationError(String), SessionError(String), ValidationError(String), IoError(Error), SerializationError(Error), TransportError(String), JsonRpcProtocolError(String),
}
Expand description

MCP-specific errors

Variants§

§

VersionMismatch

Fields

§expected: String
§actual: String
§

InvalidCapability(String)

§

ToolNotFound(String)

§

ResourceNotFound(String)

§

PromptNotFound(String)

§

InvalidParameters(String)

§

MissingParameter(String)

§

InvalidParameterType

Fields

§param: String
§expected: String
§actual: String
§

ParameterOutOfRange

Fields

§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)

Implementations§

Source§

impl McpError

Source

pub fn missing_param(param: &str) -> McpError

Create a missing parameter error

Source

pub fn invalid_param_type(param: &str, expected: &str, actual: &str) -> McpError

Create an invalid parameter type error

Source

pub fn param_out_of_range( param: &str, value: &str, constraint: &str, ) -> McpError

Create a parameter out of range error

Source

pub fn tool_execution(message: &str) -> McpError

Create a tool execution error

Source

pub fn resource_execution(message: &str) -> McpError

Create a resource execution error

Source

pub fn prompt_execution(message: &str) -> McpError

Create a prompt execution error

Source

pub fn validation(message: &str) -> McpError

Create a validation error

Source

pub fn configuration(message: &str) -> McpError

Create a configuration error

Source

pub fn transport(message: &str) -> McpError

Create a transport error

Source

pub fn json_rpc_protocol(message: &str) -> McpError

Create a JSON-RPC protocol error

Source

pub fn to_error_object(&self) -> JsonRpcErrorObject

Convert to a JsonRpcErrorObject for JSON-RPC 2.0 responses

Source

pub fn to_json_rpc_response(&self, id: Option<RequestId>) -> JsonRpcError

Create a JSON-RPC error response for this MCP error

Source

pub fn to_json_rpc_error(&self) -> JsonRpcErrorObject

👎Deprecated: Use to_error_object() instead for cleaner architecture

Legacy method for backward compatibility - use to_error_object() instead

Trait Implementations§

Source§

impl Debug for McpError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for McpError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for McpError

Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<&str> for McpError

Source§

fn from(message: &str) -> McpError

Converts to this type from the input type.
Source§

impl From<Error> for McpError

Source§

fn from(source: Error) -> McpError

Converts to this type from the input type.
Source§

impl From<Error> for McpError

Source§

fn from(source: Error) -> McpError

Converts to this type from the input type.
Source§

impl From<String> for McpError

Source§

fn from(message: String) -> McpError

Converts to this type from the input type.
Source§

impl ToJsonRpcError for McpError

Source§

fn to_error_object(&self) -> JsonRpcErrorObject

Convert this error to a JSON-RPC error object

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.