modelcontextprotocol / modelcontextprotocol/php-sdk

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

Open
#327 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client enhancement improves spec compliance
Dominant language
PHP
Stars
1.6k
Forks
173
Avg merge
2d 49m
Merged PRs (30d)
23

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/Client/Transport/HttpTransport.php::processSSEStream and trace the existing SSE parsing and stream state handling. Add unit coverage for event ID tracking and reconnection, then run the sse-retry conformance scenario; done means reconnects resume with Last-Event-ID and the retry policy is respected.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.