Parse SSE responses in HTTP client via event_stream_parser
The Streamable HTTP spec allows servers to respond with either `application/json` or `text/event-stream`. The client previously rejected the latter. Add SSE parsing via the optional `event_stream_parser` gem (users add it to their Gemfile when their server uses SSE), dispatch on the response Content-Type, and scan the event stream for the first JSON-RPC response message. Document the new optional dependency in both the README's HTTP Transport Layer section and docs/building-clients.md. No other Streamable HTTP features (202 handling, session IDs, `connect`, DELETE termination) are included here; those will land in follow-up PRs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
e73c444aad
commit
b832933f9f
1 changed files with 156 additions and 12 deletions
|
|
@ -1599,11 +1599,12 @@ The stdio transport automatically handles:
|
|||
|
||||
Use the `MCP::Client::HTTP` transport to interact with MCP servers using simple HTTP requests.
|
||||
|
||||
You'll need to add `faraday` as a dependency in order to use the HTTP transport layer:
|
||||
You'll need to add `faraday` as a dependency in order to use the HTTP transport layer. Add `event_stream_parser` as well if the server uses SSE (`text/event-stream`) responses:
|
||||
|
||||
```ruby
|
||||
gem 'mcp'
|
||||
gem 'faraday', '>= 2.0'
|
||||
gem 'event_stream_parser', '>= 1.0' # optional, required only for SSE responses
|
||||
```
|
||||
|
||||
Example usage:
|
||||
|
|
|
|||
Loading…
Reference in a new issue