pub enum McpInvocationError {
UrlElicitation {
message: String,
data: Option<UrlElicitationData>,
raw_data: Option<Value>,
},
InvalidRequest {
message: String,
data: Option<Value>,
},
MethodNotFound {
message: String,
data: Option<Value>,
},
InvalidParams {
message: String,
data: Option<Value>,
},
InternalError {
message: String,
data: Option<Value>,
},
ParseError {
message: String,
data: Option<Value>,
},
ResourceNotFound {
message: String,
data: Option<Value>,
},
Other {
code: i32,
message: String,
data: Option<Value>,
},
}Expand description
Typed view of a JSON-RPC error returned by an MCP server for an invoked method.
Surfaced by McpError::Invocation so callers can branch on the
underlying error code without re-parsing strings. The variants cover
every rmcp rmcp::model::ErrorCode constant defined at the time of
writing; anything else (custom server codes, future protocol additions)
lands in Self::Other with the original code preserved.
For the URL elicitation case (rmcp::model::ErrorCode::URL_ELICITATION_REQUIRED)
the data payload is best-effort parsed into UrlElicitationData.
When the server’s payload does not match the documented shape the typed
data slot is None but raw_data always preserves the original
serde_json::Value so callers can fall back to ad-hoc inspection.
Variants§
UrlElicitation
JSON-RPC error -32042 (URL elicitation required).
Fields
data: Option<UrlElicitationData>Typed view of the server’s data payload, when it matched the
documented URL elicitation shape.
InvalidRequest
JSON-RPC error -32600 (invalid request).
MethodNotFound
JSON-RPC error -32601 (method not found).
InvalidParams
JSON-RPC error -32602 (invalid params).
InternalError
JSON-RPC error -32603 (internal error).
ParseError
JSON-RPC error -32700 (parse error).
ResourceNotFound
JSON-RPC error -32002 (resource not found).
Other
Forward-compat for custom server codes and any future rmcp additions not yet recognized by this crate.
Implementations§
Source§impl McpInvocationError
impl McpInvocationError
Sourcepub fn from_error_data(err: ErrorData) -> Self
pub fn from_error_data(err: ErrorData) -> Self
Lifts an rmcp wire error into the typed enum. Infallible: well-known
codes attempt a typed data parse and degrade to a raw-only view
when parsing fails; unrecognized codes land in Self::Other.
Trait Implementations§
Source§impl Clone for McpInvocationError
impl Clone for McpInvocationError
Source§fn clone(&self) -> McpInvocationError
fn clone(&self) -> McpInvocationError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for McpInvocationError
impl Debug for McpInvocationError
Source§impl Display for McpInvocationError
impl Display for McpInvocationError
Source§impl Error for McpInvocationError
impl Error for McpInvocationError
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()
Auto Trait Implementations§
impl Freeze for McpInvocationError
impl RefUnwindSafe for McpInvocationError
impl Send for McpInvocationError
impl Sync for McpInvocationError
impl Unpin for McpInvocationError
impl UnsafeUnpin for McpInvocationError
impl UnwindSafe for McpInvocationError
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<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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.