Skip to content

fix(client): ignore unknown SSE fields instead of erroring the stream#1051

Open
imankhadiv wants to merge 2 commits into
modelcontextprotocol:mainfrom
imankhadiv:fix/sse-retry-field-timing
Open

fix(client): ignore unknown SSE fields instead of erroring the stream#1051
imankhadiv wants to merge 2 commits into
modelcontextprotocol:mainfrom
imankhadiv:fix/sse-retry-field-timing

Conversation

@imankhadiv

Copy link
Copy Markdown

Summary

The client SSE line parser in ResponseSubscribers errored the whole stream on any line it didn't recognize — e.g. the standard retry: field — throwing:

io.modelcontextprotocol.spec.McpTransportException: Invalid SSE response. Status code: 200 Line: retry: 500

Per the SSE spec, a client must ignore fields it does not recognize rather than treat them as an invalid response. This change makes the parser log unrecognized lines at debug and continue.

This addresses the "ignore unknown fields" ask in #1047. As discussed there, resumability / retry: reconnection timing is intentionally not implemented (it is being removed in the 2026-07-28 spec).

Changes

  • ResponseSubscribers.SseLineSubscriber: the fall-through else now ignores unrecognized SSE lines instead of emitting McpTransportException. Removed the now-unused import.
  • No API change.

Testing

  • New ResponseSubscribersTests (2 tests): a retry: line no longer errors the stream and the event still parses; an arbitrary unknown field is ignored.
  • ./mvnw test -pl mcp-core → green.

Notes

  • The conformance sse-retry scenario stays listed in conformance-tests/conformance-baseline.yml: this fix removes the crash, but the scenario's retry-timing check is a resumability behavior that is intentionally out of scope.

Refs #1047

imankhadiv and others added 2 commits July 2, 2026 09:32
The SSE line parser rejected any line it did not recognize (e.g. the
standard `retry:` field), throwing McpTransportException and tearing
down an otherwise valid stream. Per the SSE spec, unknown fields must
be ignored. Log such lines at debug and continue.

Refs modelcontextprotocol#1047
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.

1 participant