fix(client): reinitialize expired Streamable HTTP sessions

Closed
NA
2mo ago
+296-46

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.