Title: Close server session after handle stateless request by hopeful0 · Pull Request #1116 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Close server session after handle stateless request by hopeful0 · Pull Request #1116 · modelcontextprotocol/python-sdk
X Title: Close server session after handle stateless request by hopeful0 · Pull Request #1116 · modelcontextprotocol/python-sdk
Description: Motivation and Context The ServerSession created by stateless Streamable HTTP requests is not being properly cleaned up, leading to memory leaks, which may be related to #1076. This PR allows the transport to immediately close the session after handling the request, which I believe is reasonable, as the session will no longer be needed once the request has been processed. How Has This Been Tested? Breaking Changes Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context At the same time, for stateful requests, when the client does not send a DELETE request due to abnormal termination or network issues, the service session will not be cleaned up either, which similarly leads to memory leaks. I think a heartbeat mechanism can be used to determine whether the client is alive. allowing the server to timely clean up expired sessions. I would be happy to open a new PR for this or continue addressing this issue in the current PR.
Open Graph Description: Motivation and Context The ServerSession created by stateless Streamable HTTP requests is not being properly cleaned up, leading to memory leaks, which may be related to #1076. This PR allows the ...
X Description: Motivation and Context The ServerSession created by stateless Streamable HTTP requests is not being properly cleaned up, leading to memory leaks, which may be related to #1076. This PR allows the ...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/1116
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:02993ba1-c188-8055-581c-23cd7a5464c0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8D8E:B1DCB:392156:4D7193:6A5A6EC9 |
| html-safe-nonce | 5766fd85cc49f07f5c701243e15013b2f8d99ee4dc9286a4b9af6f8812b2b50c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDhFOkIxRENCOjM5MjE1Njo0RDcxOTM6NkE1QTZFQzkiLCJ2aXNpdG9yX2lkIjoiNzgyNzM5MTc4OTIyMTQ0MTIyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b73ca4f08bdded42033872b3087e5ccb69fdc111e79edf9c0da73324b67c5b15 |
| hovercard-subject-tag | pull_request:2654672496 |
| 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/1116/files |
| twitter:image | https://avatars.githubusercontent.com/u/13890191?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13890191?s=400&v=4 |
| og:image:alt | Motivation and Context The ServerSession created by stateless Streamable HTTP requests is not being properly cleaned up, leading to memory leaks, which may be related to #1076. This PR allows the ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 922bdba685ea48400234d557977f0e32d9adbae6f5125725b4f48cacc6801106 |
| 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 | 03575fc589c0e2692de839d7ca2b3aa5b5179f52 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width