Skip to content

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

Description

@JAORMX

Problem

readModernSSE (pkg/vmcp/client/modern.go:366-397) scans an SSE response line by line and json.Unmarshals each data: line independently. The SSE spec frames one event as all data: lines up to a blank-line boundary, joined with \n — a single JSON object may legally span multiple data: lines.

Against a conformant streamable-HTTP backend that splits its JSON that way, no single line unmarshals, readModernSSE never matches a response, and the probe falls through to errWrongEra — vMCP concludes the backend is not Modern and silently downgrades it to Legacy.

Fix

The correct algorithm already exists in-tree: sseResponsePayload (test/e2e/mcp_raw_client.go, added in #6033) accumulates data: lines to the blank-line boundary, joins with \n, skips interleaved notifications, and handles EOF without a trailing blank line. Port that into readModernSSE (with unit tests covering multi-line data:, CRLF, interleaved notifications, and EOF-without-blank-line).

Surfaced by review on #6033 (the reviewer verified the e2e helper is correct and flagged the production counterpart as the naive version). Refs #5743.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs initial triage by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions