Exception: MCPClient::Errors::UnsupportedProtocolVersionError

Inherits:
ServerError show all
Includes:
ModernProtocolError
Defined in:
lib/mcp_client/errors.rb

Overview

-32022 UnsupportedProtocolVersion (MCP 2026-07-28): the server does not implement the protocol version the request declared. supported lists the versions it does implement so the client can retry with one.

Instance Attribute Summary

Attributes inherited from ServerError

#code, #data, #http_status

Instance Method Summary collapse

Methods included from ModernProtocolError

#modern_protocol_error?

Methods inherited from ServerError

from_jsonrpc, #initialize, #modern_http_protocol_error?, #modern_protocol_error?, #modern_protocol_error_for_probe?, #protocol_error?

Methods inherited from MCPError

#era_inconclusive?

Constructor Details

This class inherits a constructor from MCPClient::Errors::ServerError

Instance Method Details

#requested ⇒ String?

Returns the protocol version the request asked for (data.requested).

Returns:

  • (String, nil) —

    the protocol version the request asked for (data.requested)



394
395
396
# File 'lib/mcp_client/errors.rb', line 394

def requested
  data_member('requested')
end

#supported ⇒ Array<String>

Returns protocol versions the server supports (data.supported).

Returns:

  • (Array<String>) —

    protocol versions the server supports (data.supported)



382
383
384
385
# File 'lib/mcp_client/errors.rb', line 382

def supported
  list = data_member('supported')
  list.is_a?(Array) ? list.grep(String) : []
end

#supported_suffix ⇒ String

The versions the server named, phrased for a message about the rejection.

Returns:

  • (String) —

    " (server supports: ...)" or "" when it named none



389
390
391
# File 'lib/mcp_client/errors.rb', line 389

def supported_suffix
  supported.empty? ? '' : " (server supports: #{supported.join(', ')})"
end

#well_formed? ⇒ Boolean

The schema types this error's data as supported: string[] and requested: string. Both members, with those types, are what a modern server's rejection carries and what a legacy endpoint emitting a bare -32022 does not — so they are the whole test. Their length is not: an empty supported means the server named no version this client can retry with, which is a failed negotiation with a modern server, not evidence of a legacy one.

Returns:

  • (Boolean) —

    whether data carries the shape the schema requires



406
407
408
409
410
411
# File 'lib/mcp_client/errors.rb', line 406

def well_formed?
  list = data_member('supported')
  return false unless list.is_a?(Array) && list.all?(String)

  requested.is_a?(String)
end