Exception: MCP::Client::ServerRequestError
- Inherits:
-
StandardError
- Object
- StandardError
- MCP::Client::ServerRequestError
- Defined in:
- lib/mcp/client.rb
Overview
Raised inside a server-to-client request handler (registered via on_server_request, e.g. on_sampling)
to answer the request with a specific JSON-RPC error code instead of the default internal error.
Mirrors the TypeScript SDK's McpError and the Python SDK's ErrorData return: for example,
the sampling spec answers a rejected request with code -1.
https://modelcontextprotocol.io/specification/2025-11-25/client/sampling
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(message, code:) ⇒ ServerRequestError
constructor
A new instance of ServerRequestError.
Constructor Details
#initialize(message, code:) ⇒ ServerRequestError
Returns a new instance of ServerRequestError.
42 43 44 45 |
# File 'lib/mcp/client.rb', line 42 def initialize(, code:) super() @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
40 41 42 |
# File 'lib/mcp/client.rb', line 40 def code @code end |