Title: fix: clean up SSE session on client disconnect by Varun6578 · Pull Request #2200 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix: clean up SSE session on client disconnect by Varun6578 · Pull Request #2200 · modelcontextprotocol/python-sdk
X Title: fix: clean up SSE session on client disconnect by Varun6578 · Pull Request #2200 · modelcontextprotocol/python-sdk
Description: NoteEDIT from @maxisbey: Retargeting to Fixes #1227 — see #2200 (comment) for details. The fix is correct and useful, but #423 is a different bug (client-side EventSource auto-reconnect without re-initialize) already mitigated by #822 and #1478. The "server reload" claim below is inaccurate — a uvicorn restart gives a fresh empty dict; this leak only occurs within a single process lifetime. Summary Fixes #1227 After a client disconnects from the SSE endpoint, the session entry was never removed from _read_stream_writers. This caused stale sessions to accumulate, and after a server reload old session IDs could still be found in the dict (with closed streams), leading to confusing behavior. Changes src/mcp/server/sse.py: Added self._read_stream_writers.pop(session_id, None) in the disconnect handler (response_wrapper) to clean up the session entry when a client disconnects This is a one-line fix. The streams were already being closed on disconnect; this ensures the session dict entry is also removed so that subsequent POST requests to the old session ID correctly receive a 404 response.
Open Graph Description: NoteEDIT from @maxisbey: Retargeting to Fixes #1227 — see #2200 (comment) for details. The fix is correct and useful, but #423 is a different bug (client-side EventSource auto-reconnect without re-...
X Description: NoteEDIT from @maxisbey: Retargeting to Fixes #1227 — see #2200 (comment) for details. The fix is correct and useful, but #423 is a different bug (client-side EventSource auto-reconnect without re-...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2200
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0a112a84-8a55-7d72-7d58-bf7064a5172d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8134:3E5F8B:12EA91A:1AF16C3:6A5F997C |
| html-safe-nonce | 1560e5d9874c79fa2723239122e6b32e958572b0ca4e873580c90c14bc7ddd37 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTM0OjNFNUY4QjoxMkVBOTFBOjFBRjE2QzM6NkE1Rjk5N0MiLCJ2aXNpdG9yX2lkIjoiODE1MDMwMDk1MTA5MjEwNzY0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cfa63e8d8fca7cf21ffe9c6b438a368cd74066d3bb110a8c7bb52aedcf64dfa8 |
| hovercard-subject-tag | pull_request:3343854254 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2200/files |
| twitter:image | https://avatars.githubusercontent.com/u/34965159?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/34965159?s=400&v=4 |
| og:image:alt | NoteEDIT from @maxisbey: Retargeting to Fixes #1227 — see #2200 (comment) for details. The fix is correct and useful, but #423 is a different bug (client-side EventSource auto-reconnect without re-... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9353cc7b48460319d80daeeb399e4919b4abcfe6f78d37c7b457924d164a40b1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 755d210ae728fcf699d7ab1cdd9866592be6ad35 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width