fix: skip priming events and close_sse_stream for old protocol versions #1719
+174
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes backwards compatibility issue where SEP-1699 priming events break old clients.
Motivation and Context
SEP-1699 introduced "priming events" - SSE events with an ID but empty data (
data: \n). Old clients (SDK versions before the empty-data fix) try toJSON.parse("")and crash with "Unexpected end of JSON input".Additionally, the
close_sse_streamcallbacks should not be provided to old clients because they can't resume if the stream is closed early (they never received a priming event with an event ID).How Has This Been Tested?
Breaking Changes
None. This is a backwards-compatible fix that makes new servers work correctly with old clients.
Types of changes
Checklist
Additional context
The fix gates on protocol version >= 2025-11-25:
params.protocolVersionmcp-protocol-versionheaderChanges:
_maybe_send_priming_event: renamed from_send_priming_event, now checks protocol version_create_session_message: only providesclose_sse_streamcallbacks when protocol version supports resumabilityString comparison works for ISO date format versions (e.g.,
'2025-03-26' < '2025-11-25'→ true).