Skip to content

fix: upgrade mcp SDK to v1.x branch to fix ClosedResourceError#84

Closed
bolinocroustibat wants to merge 3 commits intomainfrom
fix/upgrade-mcp-sdk-closedresource
Closed

fix: upgrade mcp SDK to v1.x branch to fix ClosedResourceError#84
bolinocroustibat wants to merge 3 commits intomainfrom
fix/upgrade-mcp-sdk-closedresource

Conversation

@bolinocroustibat
Copy link
Copy Markdown
Collaborator

@bolinocroustibat bolinocroustibat commented Mar 27, 2026

Related to #86

In production, client disconnects during MCP requests cause ClosedResourceError crashes in stateless sessions.

This is a known bug in mcp 1.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.x branch directly. Revert to a PyPI specifier once a new release is published.

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
@bolinocroustibat
Copy link
Copy Markdown
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.

@bolinocroustibat
Copy link
Copy Markdown
Collaborator Author

Wrong culprit, see #86, closing

@github-project-automation github-project-automation Bot moved this from 📝 Todo to ✅ Done in 🚀 Produit data.gouv.fr Apr 2, 2026
@bolinocroustibat bolinocroustibat deleted the fix/upgrade-mcp-sdk-closedresource branch April 2, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 - High priority Important and urgent bug Something isn't working

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants