Exception: MCP::Server::RequestTimeoutError

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

Overview

Raised when a server-to-client request (sampling, elicitation, roots/list, ping) goes unanswered past its timeout. The spec asks implementations to bound every sent request so a peer that never answers cannot exhaust the sender's resources, and to cancel the request on expiry; the transport sends notifications/cancelled before raising this. These requests exist only on connections speaking 2025-11-25 or earlier, since the modern lifecycle forbids them.

Left uncaught in a handler, this answers the client's originating request with -32001 rather than a generic internal error, so the peer that failed to answer can tell a timeout apart from a server fault. The code is not spec-allocated: it sits in the implementation-defined server range and is the value the Python SDK reports for this condition, so a client that already recognizes it there reads the same meaning here.

https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#timeouts

Instance Attribute Summary collapse

Attributes inherited from RequestHandlerError

#error_code, #error_data, #error_type, #original_error

Instance Method Summary collapse

Constructor Details

#initialize(message, request_id:, timeout:) ⇒ RequestTimeoutError

Returns a new instance of RequestTimeoutError.



145
146
147
148
149
# File 'lib/mcp/server.rb', line 145

def initialize(message, request_id:, timeout:)
  super(message, nil, error_type: :request_timeout, error_code: -32001)
  @request_id = request_id
  @timeout = timeout
end

Instance Attribute Details

#request_idObject (readonly)

Returns the value of attribute request_id.



143
144
145
# File 'lib/mcp/server.rb', line 143

def request_id
  @request_id
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



143
144
145
# File 'lib/mcp/server.rb', line 143

def timeout
  @timeout
end