Exception: MCP::Server::UnsupportedProtocolVersionError

Inherits:
RequestHandlerError show all
Defined in:
lib/mcp/server.rb

Overview

Raised when a request carries a protocol version the server does not support under the stateless lifecycle of MCP 2026-07-28 (SEP-2575). Maps to JSON-RPC error -32022 with data: { supported: [...], requested: "..." } so the client can select a mutually supported version and retry.

https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2575

Instance Attribute Summary

Attributes inherited from RequestHandlerError

#error_code, #error_data, #error_type, #original_error

Instance Method Summary collapse

Constructor Details

#initialize(requested, request = nil, supported: Configuration::SUPPORTED_MODERN_PROTOCOL_VERSIONS) ⇒ UnsupportedProtocolVersionError

Returns a new instance of UnsupportedProtocolVersionError.



68
69
70
71
72
73
74
75
76
# File 'lib/mcp/server.rb', line 68

def initialize(requested, request = nil, supported: Configuration::SUPPORTED_MODERN_PROTOCOL_VERSIONS)
  super(
    "Unsupported protocol version",
    request,
    error_type: :unsupported_protocol_version,
    error_code: ErrorCodes::UNSUPPORTED_PROTOCOL_VERSION,
    error_data: { supported: supported, requested: requested || "unknown" },
  )
end