StreamableHTTPServerTransport: option to send SSE keepalive comments on open streams

Aperta
#3,027 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Urdemonlord ci sta già lavorando.

Dal 21/11/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with the StreamableHTTPServerTransport class and its internal _webStandardTransport, where _streamMapping holds each open SSE stream's controller. Find where the standalone GET stream and POST SSE responses are created, then decide where a periodic : keepalive comment could be written and how the new option gets through the constructor. Done means the option is accepted, comments appear on open streams at the configured interval, and it is off by default. Settle the option name and default with maintainers before coding, since the issue leaves both open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

v1

Problem

StreamableHTTPServerTransport writes nothing on an open SSE stream between messages. The standalone GET stream usually carries no traffic for long periods, and a long-running tool call's POST stream can be quiet too. Proxies and load balancers with an idle timeout (AWS ALB and nginx default to 60 seconds, Cloudflare to 100) then close the connection, and clients see the stream drop and reconnect.

There is no public way to add a heartbeat. To keep streams alive today, a server has to reach into _webStandardTransport._streamMapping and enqueue an SSE comment on each stream's controller, which breaks on any internal change and forces an exact version pin.

Proposal

An option on the transport, for example:

new StreamableHTTPServerTransport({
  sessionIdGenerator: () => randomUUID(),
  keepAliveIntervalMs: 20_000, // write ": keepalive\n\n" on every open SSE stream
});
  • SSE comment lines are ignored by clients (per the SSE spec), so this needs no protocol change and no client support.
  • Applies to the standalone GET stream and to POST responses streamed as SSE.
  • Off by default, or a conservative default below common proxy timeouts.

The MCP ping request is an alternative, but it makes every client send a POST per interval per stream, where a comment costs one line on an already-open connection.

Versions

Observed on @modelcontextprotocol/sdk 1.29.0.

Lingua principale
TypeScript
Stelle
13.8k
Fork
2.5k
Merge medio
6g 23h
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/typescript-sdk

Tutte le issue di modelcontextprotocol/typescript-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.