fix(streamable): emit event: message in SSE proxy responses#5674
Open
syf2211 wants to merge 2 commits into
Open
fix(streamable): emit event: message in SSE proxy responses#5674syf2211 wants to merge 2 commits into
syf2211 wants to merge 2 commits into
Conversation
The streamable-http proxy wrote JSON-RPC responses as data-only SSE frames. Clients such as @ai-sdk/mcp require an explicit event: message line and silently drop event-less frames, causing initialize to hang. Add event: message to both success and error SSE write paths and a regression test that verifies the frame format. Fixes stacklok#5655 Signed-off-by: syf2211 <syf2211@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5674 +/- ##
==========================================
- Coverage 70.43% 70.36% -0.07%
==========================================
Files 651 651
Lines 66305 66305
==========================================
- Hits 46700 46654 -46
- Misses 16231 16290 +59
+ Partials 3374 3361 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move nolint comment to its own line so the Fprintf stays within the 130-character limit enforced by golangci-lint. Signed-off-by: syf2211 <syf2211@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add an explicit
event: messageline to JSON-RPC SSE frames emitted by the streamable-http proxy, matching reference MCP server transports and fixing clients that require named events.Motivation
The streamable proxy wrote
data:-only SSE frames. While valid per the WHATWG SSE spec, this diverges from MCP reference transports and breaks spec-lenient clients such as@ai-sdk/mcp, which only dispatch frames whereevent === "message". Those clients hang oninitializeagainst stdio servers fronted by this proxy.Fixes #5655
Changes
handleSingleRequestSSEto emitevent: message\ndata: ...\n\nTestSSEResponseIncludesEventMessageregression test instreamable_proxy_spec_test.goTests
go test ./pkg/transport/proxy/streamable/... -count=1— all passedNotes
data:frames continue to work