Skip to content

fix(server): leave SSE connection policy to adapters - #2554

Open
colinaaa wants to merge 1 commit into
modelcontextprotocol:mainfrom
colinaaa:codex/web-standard-connection-policy
Open

fix(server): leave SSE connection policy to adapters#2554
colinaaa wants to merge 1 commit into
modelcontextprotocol:mainfrom
colinaaa:codex/web-standard-connection-policy

Conversation

@colinaaa

Copy link
Copy Markdown

Summary

  • remove Connection: keep-alive from the three Web Standard Streamable HTTP SSE response paths
  • assert that POST, standalone GET, and Last-Event-ID replay responses do not set hop-by-hop connection policy
  • add a patch changeset for @modelcontextprotocol/server

Fixes #2553.

Why

A web-standard Response does not own the underlying connection and cannot know its lifetime. Setting Connection: keep-alive in the transport suppresses concrete HTTP/1.1 servers from advertising their real Keep-Alive: timeout=..., and Connection is forbidden on HTTP/2.

Omitting the header does not disable persistent connections. Node HTTP/1.1 can emit its own matching Connection and Keep-Alive headers, while HTTP/2 and other Fetch adapters remain free to apply their own policy. This adds no Connection: close, retry, or timeout behavior.

Verification

  • focused Streamable HTTP tests: 47/47
  • full @modelcontextprotocol/server tests: 448/448
  • server typecheck
  • server ESLint and Prettier
  • repository pre-push build, typecheck, lint, and snippet checks
  • git diff --check

Interaction with #2541

#2541 edits the same three header objects to add SSE heartbeat and anti-buffering behavior. The changes are semantically independent: retain its heartbeat and X-Accel-Buffering changes, while omitting only the hop-by-hop Connection header.

Remove hop-by-hop Connection headers from Web Standard Streamable HTTP responses so concrete HTTP adapters can advertise their actual connection lifetime.
@colinaaa
colinaaa requested a review from a team as a code owner July 27, 2026 07:38
@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 81a5558

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core-internal 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

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2554

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2554

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2554

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2554

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2554

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2554

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2554

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2554

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2554

commit: 81a5558

@knoal knoal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing via MCE A/B pilot 7 (sophia@hermes.local).

Summary

Removes Connection: keep-alive header from 3 SSE response sites in streamableHttp.ts. Reason: hop-by-hop connection policy should be the HTTP adapter's job, not the SDK's.

What's good

  • Correct technical fixConnection is a hop-by-hop header per RFC 7230 §6.1, and the SDK was setting it manually when the HTTP adapter should manage connection lifecycle.
  • Patch-level changeset is appropriately terse (5 lines).
  • Tests updated to no longer expect the header.

APPROVE — clean focused fix.

— sophia

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.

Web-standard SSE responses override the HTTP server keep-alive lifetime

2 participants