Skip to main content

Module error

Module error 

Source
Expand description

Error types for MCP

§JSON-RPC Error Codes

Standard JSON-RPC 2.0 error codes are defined in the specification: https://www.jsonrpc.org/specification#error_object

CodeMessageMeaning
-32700Parse errorInvalid JSON was received
-32600Invalid RequestThe JSON sent is not a valid Request
-32601Method not foundThe method does not exist / is not available
-32602Invalid paramsInvalid method parameter(s)
-32603Internal errorInternal JSON-RPC error

§MCP-Specific Error Codes

MCP uses the server error range (-32000 to -32099) for protocol-specific errors. Codes assigned by the spec are marked spec; codes used only by this implementation (in the JSON-RPC “implementation-defined” subrange) are marked impl.

CodeNameSourceMeaning
-32000ConnectionClosedimplTransport connection was closed
-32001HeaderMismatchspec (SEP-2243)HTTP headers do not match the request body, or required headers are missing/malformed
-32002ResourceNotFounddeprecatedSEP-2164 reassigned to -32602; variant kept for backcompat
-32003MissingRequiredClientCapabilityspec (SEP-2575)Client lacks a capability required by the request
-32004UnsupportedProtocolVersionspec (SEP-2575)Server does not support the request’s protocol version
-32005SessionNotFoundimplSession not found or expired (legacy; deprecated by SEP-2567)
-32006SessionRequiredimplMcp-Session-Id header required (legacy; deprecated by SEP-2567)
-32007ForbiddenimplAccess forbidden (insufficient scope)
-32008AlreadySubscribedimplResource already subscribed (moved from -32003 to avoid collision with SEP-2575)
-32009NotSubscribedimplResource not subscribed (moved from -32004 to avoid collision with SEP-2575)
-32010RequestTimeoutimplRequest exceeded timeout (moved from -32001 to avoid collision with SEP-2243)
-32042UrlElicitationRequiredTS SDKURL elicitation required

Structs§

JsonRpcError
JSON-RPC error object
ToolError
Tool execution error with context
UnsupportedProtocolVersionData
SEP-2575 error data for UnsupportedProtocolVersion (-32004).

Enums§

Error
tower-mcp error type
ErrorCode
Standard JSON-RPC error codes
McpErrorCode
MCP-specific error codes (in the -32000 to -32099 range).

Traits§

ResultExt
Extension trait for converting errors into tower-mcp tool errors.

Type Aliases§

BoxError
Type-erased error type used for middleware composition.
Result
Result type alias for tower-mcp