Skip to content

Add MCP Streamable HTTP specification support for the client#210

Open
keisku wants to merge 3 commits intomodelcontextprotocol:mainfrom
keisku:streamable-http-spec-support-for-client
Open

Add MCP Streamable HTTP specification support for the client#210
keisku wants to merge 3 commits intomodelcontextprotocol:mainfrom
keisku:streamable-http-spec-support-for-client

Conversation

@keisku
Copy link
Copy Markdown
Contributor

@keisku keisku commented Jan 9, 2026

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:

  • POST with JSON body
  • Accept: application/json, text/event-stream header
  • Parse application/json response

This PR adds:

  • Parse text/event-stream (SSE) response via event_stream_parser gem
  • Session management (MCP-Session-Id header)
  • Handle 404 as session expiration
  • Handle 202 Accepted when server delivers response via SSE stream
  • DELETE for session termination
  • Protocol version header (MCP-Protocol-Version)
  • Client conformance test runner (conformance/client.rb)

How Has This Been Tested?

Unit tests — 59 tests pass (40 client + 19 HTTP transport):

ruby -I lib -I test test/mcp/client_test.rb      # 40 runs, 125 assertions, 0 failures
ruby -I lib -I test test/mcp/client/http_test.rb  # 19 runs, 48 assertions, 0 failures

Conformance tests — core client scenarios pass:

npx @modelcontextprotocol/conformance client --suite core --command "ruby conformance/client.rb"

✓ initialize: 1 passed, 0 failed
✓ tools_call: 1 passed, 0 failed

E2E — manual testing with examples/streamable_http_server.rb and examples/streamable_http_client.rb.

Breaking Changes

None. The public send_request(request:) method signature is preserved for backward compatibility.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

API Design

  • MCP::Client::HTTP#send_request(request:) — Returns body only (backward compatible)
  • MCP::Client::HTTP#post(body:, headers:) — Returns Response struct with body + headers (for session management)
  • MCP::Client::HTTP#delete(headers:) — For session termination
  • MCP::Client#connect(client_info:, protocol_version:, capabilities:) — Initialization handshake
  • MCP::Client#close — Session termination

Pending TODOs

@keisku keisku requested a review from atesgoral January 13, 2026 00:52
@keisku
Copy link
Copy Markdown
Contributor Author

keisku commented Jan 15, 2026

@atesgoral Thanks for reviewing this! I've addressed it.

@keisku
Copy link
Copy Markdown
Contributor Author

keisku commented Jan 26, 2026

@atesgoral Any chance you could take a look at this PR?

@keisku keisku requested a review from koic January 27, 2026 05:50
@koic
Copy link
Copy Markdown
Member

koic commented Mar 11, 2026

@keisku Could you review the feedback and squash the commits into a single commit?

@atesgoral atesgoral force-pushed the streamable-http-spec-support-for-client branch from b91a9db to 2ee2be4 Compare April 4, 2026 01:34
keisku and others added 2 commits April 4, 2026 00:30
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>
@atesgoral atesgoral force-pushed the streamable-http-spec-support-for-client branch from 2ee2be4 to eb801cc Compare April 4, 2026 04:30
@atesgoral atesgoral requested a review from koic April 4, 2026 04:30
@atesgoral
Copy link
Copy Markdown
Contributor

Commits:

  1. Squashed and rebased original PR while also matching the code base's new stylistic preferences
  2. Fixed an issue
  3. Addressed review comments

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants