Skip to content

Parse multi-line Modern SSE events - #6126

Open
kocaemre wants to merge 1 commit into
stacklok:mainfrom
kocaemre:fix/vmcp-multiline-sse
Open

Parse multi-line Modern SSE events#6126
kocaemre wants to merge 1 commit into
stacklok:mainfrom
kocaemre:fix/vmcp-multiline-sse

Conversation

@kocaemre

Copy link
Copy Markdown

Summary

  • vMCP's Modern backend client parsed each SSE data: line as a standalone JSON-RPC envelope, but the SSE spec defines one event as all data: lines up to the blank-line boundary joined with \n.
  • This meant a conformant Modern backend that split one JSON response across multiple data: lines could be misread as not-Modern and fall back to Legacy.
  • Update readModernSSE to accumulate one SSE event at a time, join multi-line data: fields, ignore interleaved server-to-client messages, and flush the final event even without a trailing blank line.
  • Extend the Modern SSE response tests to cover single-line events, multi-line data:, CRLF line endings, interleaved notifications, and EOF without a trailing blank line.

Fixes #6102

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Manual testing:

  • RED before fix: PATH=/usr/local/go/bin:/root/go/bin:$PATH go test ./pkg/vmcp/client -run TestModernCall_SSEResponse failed on multi-line data response with backend response is not a Modern (2026-07-28) MCP response.
  • GREEN after fix: PATH=/usr/local/go/bin:/root/go/bin:$PATH go test ./pkg/vmcp/client -run TestModernCall_SSEResponse
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH go test ./pkg/vmcp/client -run 'TestModernCall_SSEResponse|TestModernCall_ErrorMapping|TestModernCall_Decode'
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH go test -race ./pkg/vmcp/client -run TestModernCall_SSEResponse
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH go test ./pkg/vmcp/client
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH task lint
  • git diff --check

I also ran PATH=/usr/local/go/bin:/root/go/bin:$PATH task test. It failed in unrelated packages (cmd/thv/app, pkg/client, and pkg/skills/skillsvc) outside this PR's two touched files, including a panic in pkg/client/config_test.go; the targeted pkg/vmcp/client package and lint checks above passed.

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

Does this introduce a user-facing change?

No direct user-facing CLI/API change. It fixes vMCP's backend revision detection for conformant Modern streamable-HTTP servers that split SSE data: fields.

Special notes for reviewers

The parser keeps the existing behavior of only returning the response matching the JSON-RPC id requested by modernCall; server-to-client requests/notifications and other response ids are still ignored.

Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
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.

vMCP backend client cannot parse multi-line SSE data, silently downgrades Modern backends

1 participant