Skip to content

Conversation

@felixweinberger
Copy link
Contributor

Summary

  • Adds closeStandaloneSSEStream() method to close standalone GET SSE streams
  • Exposes extra.closeStandaloneSSEStream() callback in request handlers
  • Fixes event storage to persist events while stream is disconnected for replay on reconnect

This enables SEP-1699 polling behavior for standalone GET streams, complementing the existing closeSSEStream() for POST streams.

Motivation and Context

SEP-1699 allows servers to disconnect SSE streams at will to implement polling patterns. The existing closeSSEStream() only works for POST-based streams. This PR adds support for closing the standalone GET stream as well.

How Has This Been Tested?

  • New tests for closeStandaloneSSEStream callback availability
  • New tests for stream closure via extra.closeStandaloneSSEStream()
  • New tests for client reconnection with Last-Event-ID after server-initiated disconnect
  • Updated existing closeSSEStream test to use extra.closeSSEStream() for consistency

Breaking Changes

None - this is additive functionality.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Depends on #1166 (closeSSEStream callback PR).

@felixweinberger felixweinberger requested a review from a team as a code owner December 1, 2025 15:38
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 1, 2025

Open in StackBlitz

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

commit: 0f71c6b

Base automatically changed from fweinberger/closeSSEStream-callback to main December 1, 2025 16:18
TDD setup for closing standalone GET SSE streams via extra callback.

Tests added:
- should provide closeStandaloneSSEStream callback in extra (passes)
- should close standalone GET SSE stream when extra.closeStandaloneSSEStream is called (fails)
- should allow client to reconnect after standalone SSE stream is closed (fails)

Also updated existing closeSSEStream test to use extra.closeSSEStream()
for consistency (all stream close tests now use the extra callback API).

Stub implementation added - tests fail with "Stream did not close in time"
Implement the ability to close standalone GET SSE streams, enabling
polling behavior for server-initiated notifications (SEP-1699).

Changes:
- closeStandaloneSSEStream() now closes the GET stream by ending
  the response and removing from stream mapping
- Events are now stored even when standalone stream is disconnected,
  allowing replay on client reconnect with Last-Event-ID

This complements the existing closeSSEStream() for POST streams.
@felixweinberger felixweinberger force-pushed the fweinberger/closeSSEStream-standalone branch from 310d3b2 to de41e47 Compare December 1, 2025 16:24
@felixweinberger felixweinberger merged commit 4b651b8 into main Dec 1, 2025
10 checks passed
@felixweinberger felixweinberger deleted the fweinberger/closeSSEStream-standalone branch December 1, 2025 17:01
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.

3 participants