[v2] Streamable HTTP client never re-initializes after server 404 "session not found" — needs maintainer call on era architecture
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- typescript
- Domaine
- backend-api-design
Piste de recherche
Read the v2 client’s POST _send() error handling and the connect paths _connectPlainLegacy, _legacyHandshake, and _connectNegotiated; the issue gives their names and relevant dist/index.mjs locations. Check the expected-failure e2e scenario client-transport:http:session-404-reinitialize and the companion http:404-surfaces test. Done means agreeing on the recovery handshake strategy, then covering one bounded 404 recovery while retaining the unrecoverable-case coverage.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What happened?
Once a stateful Streamable HTTP server drops a session (restart, eviction, keepalive timeout without a server→client SSE stream), every subsequent client POST with the stale Mcp-Session-Id returns HTTP 404 "session not found". The v2 client never recovers: the same error is thrown verbatim on every tools/call for the rest of the process lifetime.
Reproduced on a 24h-long-lived agent harness (DeepSeek Harness) talking to a stateful Rancher MCP server nightly-restarted by cert rotation: first call succeeds, all calls from the next minute onward 404. No transport or SDK error handling re-tries a handshake. A full transport close/reconnect (or process restart) is the only recovery.
What did you expect?
MCP spec 2025-06-18, Session Management §5 (normative MUST):
When a client receives HTTP 404 in response to a request containing an
Mcp-Session-Id, it MUST start a new session by sending a newInitializeRequestwithout a session ID attached.
The client should treat a 404 carrying a session id as an expired-session signal: clear the cached id, re-run initialize session-less, and replay the failed request once (bounded, not a loop).
Code / verified in dist
On @modelcontextprotocol/client 2.0.0 (dist/index.mjs):
_sessionIdis assigned only from a successful initialize response (~L5332); nothing else mutates it.- The
if (!response.ok)branch in the POST_send()path special-cases only401(auth seam, ~L4841). A 404 falls straight through tothrow new Error(\Error POSTing to endpoint (HTTP 404): …`)`. - No "clear session id on 404 / re-initialize / retry once" path exists anywhere in the package.
The e2e scenario client-transport:http:session-404-reinitialize is still listed as an expected failure; the companion scenario http:404-surfaces covers the unrecoverable case (no recovery hook installed) and should stay.
Prior art (both authored but never merged)
- #2150 implemented exactly this on the pre-era codebase. The author closed it himself: the connect path has since been rebuilt around era negotiation (
_connectPlainLegacy/_legacyHandshake/_connectNegotiated), and he asked for one design call from maintainers before redoing it — "when a session expires mid-connection, should the client re-probe withserver/discover(full fresh negotiation) or re-run the handshake pinned to the era it originally negotiated?" He is happy to redo the PR once that direction is settled. - #2466 aligned session-id lifecycle with the spec more broadly; author withdrew it as "grew far past its purpose" and deferred the recovery part to a minimal follow-up PR that never materialized.
A search on this tracker confirms no open PR currently brings 404-reinitialize to v2.
Why I am opening an issue instead of submitting the PR myself
Per CONTRIBUTING.md, this touches the connect architecture (a "significant change"), and the open design question above makes the "what/how" unsettled as the guide asks of PR authors. First maintainer signal we need: re-probe via server/discover, or re-run pinned-era handshake? Once that is answered, #2150's author and I are both willing to produce the PR.
SDK version: @modelcontextprotocol/client 2.0.0 (consumer: DeepSeek Harness dsh-mcp-client 0.2.0-rc.2)
Area: Client / Transports
- Langage dominant
- TypeScript
- Étoiles
- 13.8k
- Forks
- 2.5k
- Merge moyen
- 6 j 23 h
- PR mergées (30 j)
- 2
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/typescript-sdk
-
v2
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`Peut-être pris @mgoldsborough l’a pris il y a 6 jours. Ouvertev2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
modelcontextprotocol/typescript-sdk#3249 ·
Les mainteneurs répondent en général sous 1 jour
-
v2
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` replyPeut-être pris @Tidehyc l’a pris il y a 7 jours. Ouvertev2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
UriTemplate.match() throws a TypeError on an empty expression it acceptsPeut-être pris @yunusemrejs l’a pris il y a 12 jours. Ouvertev1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/typescript-sdk
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Vessel9817/onion-site-template#512 ·
Les mainteneurs répondent en général sous 1 jour
-
nightly-tests
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
Les mainteneurs répondent en général sous 1 jour
-
approved
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
fritzprix/libr-agent#3266 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
better-auth/better-auth#13101 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour