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) ⇒ UnsupportedProtocolVersionError

No keyword parameters here: with one present, Ruby 2.7 would split a trailing symbol-keyed request Hash into keywords and fail with "unknown keywords".



76
77
78
79
80
81
82
83
84
# File 'lib/mcp/server.rb', line 76

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