ruby-sdk/lib/mcp/client
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Koichi ITO 09c89aef14 Parse HTTP client response bodies without Faraday's JSON middleware
## Motivation and Context

json 3.0, released on 2026-09-07, accepts the options of `JSON.parse` as keywords only, and Faraday's json response middleware,
through 2.14.3, hands them over as a positional Hash, which Ruby 3 no longer converts. With both installed, every JSON body
the client receives fails inside that middleware, and `MCP::Client::HTTP` reports each request as an internal error.
Faraday's main branch passes the options as keywords, but no release carries that yet.

The client already parses streamed bodies and buffered SSE bodies itself; only a JSON body delivered
whole by an adapter without streaming support still went through the middleware. The client now parses that body too
and no longer registers the middleware, so every body takes `parse_json_buffer` and a malformed one answers
`:parse_error` whichever way it arrived. A JSON middleware added through the Faraday customizer block still works,
since a body it has parsed already is used as is.

## How Has This Been Tested?

A new test drives a buffered JSON response through a stand-in `JSON.parse` with the json 3.0 signature, options as keywords only,
so on Ruby 3 it failed with the middleware registered whatever json version is installed and passes now.
The existing buffered-body test keeps covering the plain path. The full suite passes on Ruby 3.0.7 with json 3.0.1 and faraday 2.14.3,
where five client tests failed before.

## Breaking Changes

None. A malformed JSON body delivered by an adapter without streaming support now raises `RequestHandlerError` with `error_type: :parse_error`,
as the streamed path already did, instead of `:internal_error` wrapping a `Faraday::ParsingError`.
2026-09-08 18:09:09 +09:00
..
oauth Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00
elicitation.rb Support client-side elicitation with SEP-1034 schema defaults 2026-07-08 01:44:24 +09:00
http.rb Parse HTTP client response bodies without Faraday's JSON middleware 2026-09-08 18:09:09 +09:00
mcp_param_headers.rb Mirror x-mcp-header tool parameters into Mcp-Param-* headers per SEP-2243 2026-08-08 20:58:35 +09:00
modern_envelope.rb Finalize server/discover and Add Client Modern Lifecycle Support per SEP-2575 2026-08-08 03:45:00 +09:00
oauth.rb Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00
paginated_result.rb Add Opt-In ttlMs / cacheScope Cache Hints to List and Read Results per SEP-2549 2026-07-02 17:51:01 +09:00
stdio.rb Answer server-to-client pings in the client 2026-09-03 16:55:06 +09:00
tool.rb Expose server tool annotations on MCP::Client::Tool 2026-07-27 09:54:54 -04:00