Skip to content

fix(streamable): emit event: message in SSE proxy responses#5674

Open
syf2211 wants to merge 2 commits into
stacklok:mainfrom
syf2211:fix/sse-event-message
Open

fix(streamable): emit event: message in SSE proxy responses#5674
syf2211 wants to merge 2 commits into
stacklok:mainfrom
syf2211:fix/sse-event-message

Conversation

@syf2211

@syf2211 syf2211 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an explicit event: message line 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 where event === "message". Those clients hang on initialize against stdio servers fronted by this proxy.

Fixes #5655

Changes

  • Update success and error SSE write paths in handleSingleRequestSSE to emit event: message\ndata: ...\n\n
  • Add TestSSEResponseIncludesEventMessage regression test in streamable_proxy_spec_test.go

Tests

  • go test ./pkg/transport/proxy/streamable/... -count=1 — all passed

Notes

  • Backward compatible: clients that already accept bare data: frames continue to work
  • Batch SSE responses are out of scope (pre-existing behavior returns JSON)

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

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.36%. Comparing base (baf8050) to head (b4072a0).

Files with missing lines Patch % Lines
pkg/transport/proxy/streamable/streamable_proxy.go 0.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
@github-actions github-actions Bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

streamable-http proxy omits the SSE event name, breaking spec-lenient MCP clients

1 participant