Skip to content

Commit 44af58c

Browse files
authored
Merge pull request #544 from koic/add_event_stream_parser_to_installation_docs
[Doc] Explain when the HTTP client needs event_stream_parser
2 parents 8a24e50 + 0da0291 commit 44af58c

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎docs/_client/transports.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ The stdio transport automatically handles:
6464

6565
Use the `MCP::Client::HTTP` transport to interact with MCP servers using simple HTTP requests.
6666

67-
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:
67+
You'll need to add `faraday` as a dependency in order to use the HTTP transport layer, and `event_stream_parser`
68+
to read SSE (`text/event-stream`) responses.
69+
Whether a response is JSON or SSE is the server's choice, made for each response, and a client must accept both,
70+
so a client written for arbitrary servers needs both gems. This SDK's own server picks SSE by default and always
71+
does on the modern lifecycle, and the listening stream that `on_elicitation` and `on_sampling` open is SSE as well.
72+
`event_stream_parser` is loaded on the first SSE response, so it can be left out only against a server known to
73+
answer with JSON alone, such as this SDK's server in [JSON response mode](/server/transports/#json-response-mode)
74+
serving handshake-lifecycle clients, and only while no listening stream is opened:
6875

6976
```ruby
7077
gem "mcp"

‎docs/installation.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ $ gem install mcp
3838
You may need to add additional dependencies depending on which features you wish to access. For example, the HTTP client transport requires the `faraday` gem:
3939

4040
```ruby
41-
gem "mcp"
4241
gem "faraday", ">= 2.0"
4342
```
43+
44+
Reading SSE (`text/event-stream`) responses needs `event_stream_parser` as well.
45+
Whether a response is JSON or SSE is the server's choice, made for each response, and this SDK's own server picks SSE by default,
46+
so a client written for arbitrary servers needs both gems:
47+
48+
```ruby
49+
gem "faraday", ">= 2.0"
50+
gem "event_stream_parser", ">= 1.0"
51+
```
52+
53+
The [Transports](/client/transports/#http-transport-layer) page describes the one setup where `faraday` alone is enough.

0 commit comments

Comments
 (0)