StreamableHTTPServerTransport: option to send SSE keepalive comments on open streams

Aberta
#3,027 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Urdemonlord já está trabalhando nisso.

Desde 21/11/2026.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
45/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
backend, networking

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
13.8k
Forks
2.5k
Merge médio
6d 23h
PRs com merge (30d)
2

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de modelcontextprotocol/typescript-sdk

Todas as issues de modelcontextprotocol/typescript-sdk

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.