Exception: MCPClient::Errors::MissingRequiredClientCapabilityError

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

Overview

-32021 MissingRequiredClientCapability (MCP 2026-07-28): processing the request needs a capability the client did not declare in its per-request clientCapabilities.

Constant Summary collapse

TYPED_CAPABILITY_MEMBERS =

Capabilities whose named members the schema types as objects.

{ 'elicitation' => %w[form url], 'sampling' => %w[context tools] }.freeze
OBJECT_MAP_CAPABILITIES =

Capabilities the schema types as maps from name to object.

%w[experimental extensions].freeze
OPEN_OBJECT_CAPABILITIES =

Capabilities the schema types as objects with no typed member.

%w[roots].freeze

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

#required_capabilities ⇒ Hash

Returns the capabilities the server requires (data.requiredCapabilities).

Returns:

  • (Hash) —

    the capabilities the server requires (data.requiredCapabilities)



317
318
319
320
# File 'lib/mcp_client/errors.rb', line 317

def required_capabilities
  caps = data_member('requiredCapabilities')
  caps.is_a?(Hash) ? caps : {}
end

#well_formed? ⇒ Boolean

The schema types this error's data as requiredCapabilities: ClientCapabilities — an open object whose KNOWN members are typed: elicitation and sampling are objects holding objects under the names the schema gives them (form/url, context/tools) and nothing is said about their other members; experimental and extensions map names to objects; roots is an object with no typed member at all; and a capability the schema does not name may be anything. A body that breaks any of THAT is not ClientCapabilities, and must not claim the signal that separates a well-formed modern rejection from a legacy peer or an intermediary emitting a bare -32021 — but reading more into the schema than it says turns schema-valid rejections into "legacy" ones and strips their typed interface on the way to the caller, so exactly the schema's constraints are checked, no more.

Returns:

  • (Boolean) —

    whether data.requiredCapabilities is ClientCapabilities-shaped



336
337
338
339
# File 'lib/mcp_client/errors.rb', line 336

def well_formed?
  caps = data_member('requiredCapabilities')
  caps.is_a?(Hash) && caps.all? { |name, value| capability_well_formed?(name, value) }
end