StreamableHTTPServerTransport: option to send SSE keepalive comments on open streams

Đang mở
#3,027 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Urdemonlord đang làm issue này rồi.

Từ ngày 21/11/2026.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend, networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
13.8k
Fork
2.5k
Merge trung bình
6 ngày 23 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/typescript-sdk

Tất cả issue của modelcontextprotocol/typescript-sdk

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.