pub struct McpError { /* private fields */ }Expand description
A JSON-RPC error returned to the client.
Implementations§
Source§impl McpError
impl McpError
Sourcepub fn parse_error() -> Self
pub fn parse_error() -> Self
-32700: the message is not valid JSON.
Sourcepub fn invalid_request(reason: &'static str) -> Self
pub fn invalid_request(reason: &'static str) -> Self
-32600: the message is not a valid JSON-RPC request.
Sourcepub fn method_not_found(method: &str) -> Self
pub fn method_not_found(method: &str) -> Self
-32601: the method does not exist.
Sourcepub fn method_not_found_explained(
explanation: impl Into<Cow<'static, str>>,
) -> Self
pub fn method_not_found_explained( explanation: impl Into<Cow<'static, str>>, ) -> Self
-32601 with a custom, client-safe explanation.
Sourcepub fn invalid_params(message: impl Into<Cow<'static, str>>) -> Self
pub fn invalid_params(message: impl Into<Cow<'static, str>>) -> Self
-32602: the parameters are malformed (including missing _meta).
Sourcepub fn unknown_tool(name: &str) -> Self
pub fn unknown_tool(name: &str) -> Self
-32602: the requested tool does not exist.
Sourcepub fn request_failed(message: impl Into<Cow<'static, str>>) -> Self
pub fn request_failed(message: impl Into<Cow<'static, str>>) -> Self
-32602: a well-formed request the handler refused, with a
client-safe message (for example a ToolError::user raised while
reading a resource or getting a prompt).
Sourcepub fn resource_not_found(uri: &str) -> Self
pub fn resource_not_found(uri: &str) -> Self
-32602 with data.uri: the resource does not exist (the
2026-07-28 code for resource-not-found).
Sourcepub fn unknown_prompt(name: &str) -> Self
pub fn unknown_prompt(name: &str) -> Self
-32602: the requested prompt does not exist.
Sourcepub fn internal_with_message(message: &'static str) -> Self
pub fn internal_with_message(message: &'static str) -> Self
-32603 with a client-safe message (no internal details).
Sourcepub fn insufficient_scope(required: &[String]) -> Self
pub fn insufficient_scope(required: &[String]) -> Self
-32600 with data.requiredScopes: the access token does not grant
every scope the handler needs. Over HTTP this is a 403 whose
WWW-Authenticate challenge lists the scopes.
Sourcepub fn header_mismatch(message: impl Into<Cow<'static, str>>) -> Self
pub fn header_mismatch(message: impl Into<Cow<'static, str>>) -> Self
-32020: HTTP headers do not match the request body.
Sourcepub fn missing_client_capability(required: &ClientCapabilities) -> Self
pub fn missing_client_capability(required: &ClientCapabilities) -> Self
-32021: the request needs client capabilities the client did not declare.
Sourcepub fn unsupported_protocol_version(
requested: &str,
supported: &[String],
) -> Self
pub fn unsupported_protocol_version( requested: &str, supported: &[String], ) -> Self
-32022: the requested protocol version is not supported.
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()