Add MCP Streamable HTTP specification support for the client#210
Add MCP Streamable HTTP specification support for the client#210keisku wants to merge 3 commits intomodelcontextprotocol:mainfrom
Conversation
|
@atesgoral Thanks for reviewing this! I've addressed it. |
|
@atesgoral Any chance you could take a look at this PR? |
|
@keisku Could you review the feedback and squash the commits into a single commit? |
b91a9db to
2ee2be4
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When an SSE stream is active, the server responds with 202 Accepted (no Content-Type, empty body) to POST requests, delivering the actual response via the SSE stream. Previously this raised an unsupported Content-Type error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2ee2be4 to
eb801cc
Compare
|
Commits:
|
- Move event_stream_parser from Gemfile to gemspec as runtime dependency - Add brief descriptions to TODO comments in client/http.rb and streamable_http_transport.rb - Add description to spec URL comment in client.rb - Use SESSION_ID_HEADER constant for session ID header lookup in connect Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
eb801cc to
ae64c6a
Compare
| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
| spec.require_paths = ["lib"] | ||
|
|
||
| spec.add_dependency("event_stream_parser", ">= 1.0") |
There was a problem hiding this comment.
My previous comment may have overlooked some aspects.
EventStreamParser is only used in lib/mcp/client/http.rb. Considering how Faraday is currently handled, I'm not entirely certain, but it may be more consistent to make this an optional dependency that users include in their Gemfile when needed:
https://github.com/modelcontextprotocol/ruby-sdk/blob/v0.10.0/lib/mcp/client/http.rb#L84-L90
Assuming that many users of the SDK primarily use the server functionality, a setup similar to Faraday, where it is not a direct runtime dependency, may be more appropriate.
Motivation and Context
Implements the MCP Streamable HTTP specification for the Ruby SDK client.
Rebased from #210 (original by @keisku) with merge conflict resolution, bug fixes, and review feedback addressed.
Already supported:
Accept: application/json, text/event-streamheaderapplication/jsonresponseThis PR adds:
text/event-stream(SSE) response viaevent_stream_parsergemMCP-Session-Idheader)MCP-Protocol-Version)conformance/client.rb)How Has This Been Tested?
Unit tests — 59 tests pass (40 client + 19 HTTP transport):
Conformance tests — core client scenarios pass:
E2E — manual testing with
examples/streamable_http_server.rbandexamples/streamable_http_client.rb.Breaking Changes
None. The public
send_request(request:)method signature is preserved for backward compatibility.Types of changes
Checklist
API Design
MCP::Client::HTTP#send_request(request:)— Returns body only (backward compatible)MCP::Client::HTTP#post(body:, headers:)— ReturnsResponsestruct with body + headers (for session management)MCP::Client::HTTP#delete(headers:)— For session terminationMCP::Client#connect(client_info:, protocol_version:, capabilities:)— Initialization handshakeMCP::Client#close— Session terminationPending TODOs
Last-Event-IDheader