#[non_exhaustive]#[repr(i32)]pub enum McpErrorCode {
ConnectionClosed = -32_000,
HeaderMismatch = -32_001,
ResourceNotFound = -32_002,
MissingRequiredClientCapability = -32_003,
UnsupportedProtocolVersion = -32_004,
SessionNotFound = -32_005,
SessionRequired = -32_006,
Forbidden = -32_007,
AlreadySubscribed = -32_008,
NotSubscribed = -32_009,
RequestTimeout = -32_010,
UrlElicitationRequired = -32_042,
}Expand description
MCP-specific error codes (in the -32000 to -32099 range).
Codes marked spec are assigned by an MCP SEP. Others are implementation-defined within the JSON-RPC server-error range; using them is permitted by JSON-RPC 2.0 but they are not part of the MCP wire spec.
Recently-changed assignments:
MissingRequiredClientCapability(-32003) andUnsupportedProtocolVersion(-32004) are spec assignments from SEP-2575.AlreadySubscribedandNotSubscribedpreviously occupied -32003 and -32004; they moved to -32008 and -32009 to make room. This is a breaking change on the wire for any subscribe/unsubscribe responses that relied on the old codes.HeaderMismatch(-32001) is a spec assignment from SEP-2243 (HTTP header standardization).RequestTimeoutpreviously occupied -32001 and moved to -32010 to make room. This is a breaking change on the wire for any consumers matching on the oldRequestTimeoutcode.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ConnectionClosed = -32_000
Transport connection was closed.
HeaderMismatch = -32_001
SEP-2243: HTTP headers (e.g. Mcp-Method, Mcp-Name,
Mcp-Param-*) do not match the corresponding values in the request
body, or a required header is missing or malformed.
Use JsonRpcError::header_mismatch to construct.
ResourceNotFound = -32_002
SEP-2164 reassigned resource-not-found to InvalidParams (-32602). Use JsonRpcError::resource_not_found or ErrorCode::InvalidParams.
Resource not found.
Deprecated: SEP-2164 (FINAL) moves this to the standard JSON-RPC
InvalidParams code (-32602). The
JsonRpcError::resource_not_found constructor now emits -32602.
The enum variant is retained so existing pattern matches on
McpErrorCode::ResourceNotFound keep compiling, but the variant’s
numeric value is no longer what the constructor produces.
MissingRequiredClientCapability = -32_003
SEP-2575: client capabilities advertised on the request do not include a capability required by the called method.
UnsupportedProtocolVersion = -32_004
SEP-2575: server does not support the protocol version the client
requested (via MCP-Protocol-Version header or per-request _meta).
Use JsonRpcError::unsupported_protocol_version to construct.
SessionNotFound = -32_005
Session not found or expired – client should re-initialize.
SEP-2567 deprecates sessions entirely. This code stays for the 2025-11-25 protocol path; sessionless deployments will never emit it.
SessionRequired = -32_006
Session ID is required but was not provided.
SEP-2567 deprecates sessions entirely. Same caveat as SessionNotFound.
Forbidden = -32_007
Access forbidden (insufficient scope or authorization).
AlreadySubscribed = -32_008
Resource already subscribed. Moved from -32003 to avoid the
SEP-2575 MissingRequiredClientCapability collision.
NotSubscribed = -32_009
Resource not subscribed (for unsubscribe). Moved from -32004 to
avoid the SEP-2575 UnsupportedProtocolVersion collision.
RequestTimeout = -32_010
Request exceeded timeout. Moved from -32001 to avoid the SEP-2243
HeaderMismatch collision.
UrlElicitationRequired = -32_042
URL elicitation is required before processing the request.
Implementations§
Trait Implementations§
Source§impl Clone for McpErrorCode
impl Clone for McpErrorCode
Source§fn clone(&self) -> McpErrorCode
fn clone(&self) -> McpErrorCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for McpErrorCode
Source§impl Debug for McpErrorCode
impl Debug for McpErrorCode
impl Eq for McpErrorCode
Source§impl PartialEq for McpErrorCode
impl PartialEq for McpErrorCode
Source§fn eq(&self, other: &McpErrorCode) -> bool
fn eq(&self, other: &McpErrorCode) -> bool
self and other values to be equal, and is used by ==.