Skip to content

fix: add Transfer-Encoding chunked to SSE responses#1723

Open
guoyangzhen wants to merge 2 commits intomodelcontextprotocol:mainfrom
guoyangzhen:fix/sse-chunked-encoding
Open

fix: add Transfer-Encoding chunked to SSE responses#1723
guoyangzhen wants to merge 2 commits intomodelcontextprotocol:mainfrom
guoyangzhen:fix/sse-chunked-encoding

Conversation

@guoyangzhen
Copy link

Problem

SSE streams cause HTTP/2 PROTOCOL_ERROR with some HTTP adapters (e.g. @hono/node-server). The adapters buffer small SSE responses and automatically add a Content-Length header. When the SSE stream closes, this causes an HTTP/2 PROTOCOL_ERROR because HTTP/2 does not allow Content-Length with streaming responses.

Fix

Add Transfer-Encoding: chunked header to all 3 SSE response locations in WebStandardStreamableHTTPServerTransport. This prevents HTTP adapters from buffering and adding Content-Length.

Locations

  • Line ~453: GET standalone SSE stream
  • Line ~507: SSE stream with replay
  • Line ~755: POST SSE response stream

@guoyangzhen guoyangzhen requested a review from a team as a code owner March 20, 2026 13:44
@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 73389b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/express Patch
@modelcontextprotocol/hono Patch
@modelcontextprotocol/node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 20, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1723

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1723

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1723

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1723

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1723

commit: 73389b9

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.

1 participant