Skip to content

[Client] Implement SSE reconnect with Last-Event-ID #327

@soyuka

Description

@soyuka

Context

Per the MCP Streamable HTTP transport spec, when an SSE stream disconnects the client SHOULD reconnect using Last-Event-ID to resume the stream without losing notifications. src/Client/Transport/HttpTransport.php::processSSEStream currently abandons the stream on EOF.

Scope

  • Track the most recent id: line per active stream.
  • On unexpected EOF (stream still expected open — pending request unresolved, or session active), reconnect with:
    • GET <endpoint> + Accept: text/event-stream
    • Mcp-Session-Id header
    • Last-Event-ID: <id> header
  • Configurable retry policy: backoff (1s, 2s, 4s, capped at 10s) + max attempts (default 5).
  • Respect retry: SSE field when present.

Conformance scenarios unblocked

sse-retry.

Dependencies

Independent — can run in parallel with auth work.

Acceptance

  • Unit tests for ID tracking + reconnect with Last-Event-ID.
  • Conformance: sse-retry passes.

cc @soyuka

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientIssues & PRs related to the Client componentP1Significant bug affecting many users, highly requested featureenhancementRequest for a new feature that's not currently supportedimproves spec complianceImproves consistency with other SDKs such as TyepScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions