fix: upgrade mcp SDK to v1.x branch to fix ClosedResourceError#84
Closed
bolinocroustibat wants to merge 3 commits intomainfrom
Closed
fix: upgrade mcp SDK to v1.x branch to fix ClosedResourceError#84bolinocroustibat wants to merge 3 commits intomainfrom
bolinocroustibat wants to merge 3 commits intomainfrom
Conversation
The mcp SDK 1.26.0 crashes stateless sessions with ClosedResourceError when a client disconnects mid-request. This causes memory leaks in production as session resources (task groups, memory streams) are not properly cleaned up. The fix (PRs #2257, #2306, backported in #2334) is on the v1.x branch but not yet released on PyPI. Pin to the branch until a new release is published. Made-with: Cursor
nicolaskempf57
approved these changes
Mar 27, 2026
Collaborator
Author
|
Thanks @nicolaskempf57 . I won't merge this until this is tested for a few days with high traffic. Fix has just been deployed to production to see if it mitigates the issue. |
This was referenced Mar 31, 2026
Collaborator
Author
|
Wrong culprit, see #86, closing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #86
In production, client disconnects during MCP requests cause
ClosedResourceErrorcrashes in stateless sessions.This is a known bug in
mcp1.26.0, fixed upstream by:Session resources/memory might not be properly cleaned up on those crashes, which could explain memory leaks that eventually OOM the container.
No PyPI release includes these fixes yet (latest is 1.26.0), so this pins to the
v1.xbranch directly. Revert to a PyPI specifier once a new release is published.