pub enum McpError {
Show 26 variants
Transport(String),
Protocol(String),
Serialization(String),
InvalidUri(String),
ToolNotFound(String),
ResourceNotFound(String),
PromptNotFound(String),
MethodNotFound(String),
UnsupportedProtocolVersion {
requested: String,
supported: Vec<String>,
},
HeaderMismatch(String),
MissingRequiredClientCapability(Value),
InvalidParams(String),
Connection(String),
Authentication(String),
Auth(String),
Forbidden(String),
RateLimited {
retry_after_ms: u64,
},
Validation(String),
Io(String),
Url(String),
Http(String),
WebSocket(String),
SchemaValidation(String),
Timeout(String),
Cancelled(String),
Internal(String),
}Expand description
The main error type for the MCP SDK
Variants§
Transport(String)
Transport-related errors (connection, I/O, etc.)
Protocol(String)
Protocol-level errors (invalid messages, unexpected responses, etc.)
Serialization(String)
JSON serialization/deserialization errors
InvalidUri(String)
Invalid URI format or content
ToolNotFound(String)
Requested tool was not found
ResourceNotFound(String)
Requested resource was not found
PromptNotFound(String)
Requested prompt was not found
MethodNotFound(String)
Method not found (JSON-RPC error)
UnsupportedProtocolVersion
Requested MCP protocol revision is not supported by the peer.
HeaderMismatch(String)
Standard MCP HTTP headers do not match the JSON-RPC body.
MissingRequiredClientCapability(Value)
A modern request omitted a capability required by the operation.
InvalidParams(String)
Invalid parameters (JSON-RPC error)
Connection(String)
Connection-related errors
Authentication(String)
Authentication/authorization errors
Auth(String)
OAuth 2.1 authorization errors
Forbidden(String)
The authenticated principal is not allowed to perform the operation.
RateLimited
The caller exceeded an enforced request rate.
Validation(String)
Input validation errors
Io(String)
I/O errors from the standard library
Url(String)
URL parsing errors
Http(String)
HTTP-related errors when using HTTP transport
WebSocket(String)
WebSocket-related errors when using WebSocket transport
SchemaValidation(String)
JSON Schema validation errors
Timeout(String)
Timeout errors
Cancelled(String)
Cancellation errors
Internal(String)
Internal errors that shouldn’t normally occur
Implementations§
Source§impl McpError
impl McpError
Sourcepub fn validation<S: Into<String>>(message: S) -> Self
pub fn validation<S: Into<String>>(message: S) -> Self
Create a new validation error
Sourcepub fn connection<S: Into<String>>(message: S) -> Self
pub fn connection<S: Into<String>>(message: S) -> Self
Create a new connection error
Sourcepub fn serialization(err: Error) -> Self
pub fn serialization(err: Error) -> Self
Create a new serialization error from serde_json::Error
Sourcepub fn connection_error<S: Into<String>>(message: S) -> Self
pub fn connection_error<S: Into<String>>(message: S) -> Self
Create a connection error (compatibility method)
Sourcepub fn protocol_error<S: Into<String>>(message: S) -> Self
pub fn protocol_error<S: Into<String>>(message: S) -> Self
Create a protocol error (compatibility method)
Sourcepub fn validation_error<S: Into<String>>(message: S) -> Self
pub fn validation_error<S: Into<String>>(message: S) -> Self
Create a validation error (compatibility method)
Sourcepub fn timeout_error() -> Self
pub fn timeout_error() -> Self
Create a timeout error (compatibility method)
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this error is recoverable
Source§impl McpError
impl McpError
Sourcepub async fn log_with_context(&self, context: ErrorContext)
pub async fn log_with_context(&self, context: ErrorContext)
Log this error with structured context
Trait Implementations§
Source§impl Error for McpError
impl Error for McpError
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()
Source§impl From<&McpError> for ErrorLogLevel
impl From<&McpError> for ErrorLogLevel
Source§impl From<ParseError> for McpError
impl From<ParseError> for McpError
Source§fn from(err: ParseError) -> Self
fn from(err: ParseError) -> Self
Source§impl From<PluginError> for McpError
impl From<PluginError> for McpError
Source§fn from(err: PluginError) -> Self
fn from(err: PluginError) -> Self
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].