modelcontextprotocol / modelcontextprotocol/php-sdk
[Client] Implement SSE reconnect with Last-Event-ID
Nobody has claimed this yet.
- 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-streamMcp-Session-IdheaderLast-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-retrypasses.
cc @soyuka
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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