Skip to content

fix(client): reinitialize expired Streamable HTTP sessions - #3327

Closed
nankingjing wants to merge 5 commits into
modelcontextprotocol:mainfrom
nankingjing:fix/reinitialize-expired-session
Closed

fix(client): reinitialize expired Streamable HTTP sessions#3327
nankingjing wants to merge 5 commits into
modelcontextprotocol:mainfrom
nankingjing:fix/reinitialize-expired-session

Conversation

@nankingjing

Copy link
Copy Markdown

Fixes #1676

Summary

  • convert a bare HTTP 404 for a request that actually carried an MCP session id into a private transport session-expired signal
  • clear only the matching transport session id, so a delayed old 404 cannot erase a newer recovered session
  • reinitialize legacy sessions once under a generation lock and retry the original request once
  • preserve pre-session 404 -> METHOD_NOT_FOUND behavior, modern discovery behavior, and bounded failure after a second 404

Validation

  • uv run --frozen pytest tests/client/test_notification_response.py tests/client/test_streamable_http.py tests/client/test_session.py tests/interaction/transports/test_client_transport_http.py -q (119 passed)
  • uv run --frozen ruff check ..., ruff format --check ..., and pyright ... pass
  • Full suite was exercised on Windows. The new interaction requirement passes; unrelated existing inline-snapshot compatibility failures occur across baseline client/server tests (_meta attribute lookups), so the full Windows suite is not clean in this environment.

AI assistance disclosure: I used Claude for codebase research and test scaffolding. I reviewed and own the design, implementation, and follow-up.

@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #1676.

If a maintainer would like this change as a PR from you, they'll assign you to #1676 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.)

There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten.

Maintainers: reopening this PR, removing the missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP client doesn't not initialize new session when getting 404 session not found

1 participant