Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-sse-chunked-encoding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/server': patch
---

Add Transfer-Encoding: chunked header to SSE responses in WebStandardStreamableHTTPServerTransport. Prevents HTTP/2 PROTOCOL_ERROR with adapters like @hono/node-server that buffer responses and add Content-Length headers.
3 changes: 3 additions & 0 deletions packages/server/src/server/streamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
const headers: Record<string, string> = {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache, no-transform',
'Transfer-Encoding': 'chunked',
Connection: 'keep-alive'
};

Expand Down Expand Up @@ -503,6 +504,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
const headers: Record<string, string> = {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache, no-transform',
'Transfer-Encoding': 'chunked',
Connection: 'keep-alive'
};

Expand Down Expand Up @@ -751,6 +753,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
const headers: Record<string, string> = {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Transfer-Encoding': 'chunked',
Connection: 'keep-alive'
};

Expand Down
Loading