Exception: MCPClient::Errors::InputRequiredError

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

Overview

Raised when a request returns an InputRequiredResult (resultType "input_required", MCP 2026-07-28 multi round-trip requests) that this client cannot fulfil — for example because it declared no capability the server could have asked for. Exposes the server's input requests and opaque request state so a host can drive the round trip itself.

Instance Attribute Summary collapse

Attributes inherited from ServerError

#code, #data, #http_status

Instance Method Summary collapse

Methods inherited from ServerError

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

Methods inherited from MCPError

#era_inconclusive?

Constructor Details

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

Instance Attribute Details

#request_method ⇒ String?

The request the round trip was driving, when the error was raised by the round-trip resolver: what JsonRpcCommon::InputWaits#resume_input_required re-issues, with the requestState echoed and no inputResponses.

Returns:

  • (String, nil) —

    the JSON-RPC method



424
425
426
# File 'lib/mcp_client/errors.rb', line 424

def request_method
  @request_method
end

#request_params ⇒ Hash?

Returns the original request params.

Returns:

  • (Hash, nil) —

    the original request params



426
427
428
# File 'lib/mcp_client/errors.rb', line 426

def request_params
  @request_params
end

#transport ⇒ Object?

Returns the transport that raised the error.

Returns:

  • (Object, nil) —

    the transport that raised the error



428
429
430
# File 'lib/mcp_client/errors.rb', line 428

def transport
  @transport
end

Instance Method Details

#answered_so_far ⇒ Hash{String => Hash}

The answers this client had already produced when the round trip failed part way through. An input request answered before the failure was put to the host — and, through it, possibly to a person — so a caller that can hold on to it (the tasks extension's poll loop keeps it pending for the next tasks/update) never asks for it twice. Empty unless a partial fulfilment recorded any.

Returns:

  • (Hash{String => Hash}) —

    key => InputResponse



453
454
455
# File 'lib/mcp_client/errors.rb', line 453

def answered_so_far
  @answered_so_far || {}
end

#input_requests ⇒ Hash

Returns the InputRequests map (key => request object).

Returns:

  • (Hash) —

    the InputRequests map (key => request object)



436
437
438
439
# File 'lib/mcp_client/errors.rb', line 436

def input_requests
  requests = data.is_a?(Hash) ? (data['inputRequests'] || data[:inputRequests]) : nil
  requests.is_a?(Hash) ? requests : {}
end

#protocol_error? ⇒ Boolean

Returns always true: a protocol-level condition, never wrapped.

Returns:

  • (Boolean) —

    always true: a protocol-level condition, never wrapped



466
467
468
# File 'lib/mcp_client/errors.rb', line 466

def protocol_error?
  true
end

#request_state ⇒ String?

Returns the opaque requestState to echo on a retry.

Returns:

  • (String, nil) —

    the opaque requestState to echo on a retry



442
443
444
# File 'lib/mcp_client/errors.rb', line 442

def request_state
  data.is_a?(Hash) ? (data['requestState'] || data[:requestState]) : nil
end

#resumable? ⇒ Boolean

Returns whether the error carries a continuation to resume from.

Returns:

  • (Boolean) —

    whether the error carries a continuation to resume from



431
432
433
# File 'lib/mcp_client/errors.rb', line 431

def resumable?
  request_method.is_a?(String)
end

#with_answered_so_far(responses) ⇒ self

Record the answers produced before this failure.

Parameters:

  • responses (Hash) —

    key => InputResponse

Returns:

  • (self)


460
461
462
463
# File 'lib/mcp_client/errors.rb', line 460

def with_answered_so_far(responses)
  @answered_so_far = responses.is_a?(Hash) ? responses.dup.freeze : nil
  self
end