Description
When adding a remote streamable-http MCP server to config.yaml (e.g. GitHub's hosted MCP at https://api.githubcopilot.com/mcp/), LiteLLM crashes during startup with:
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
This prevents the server from initializing MCP tool discovery and the tools are never registered.
Config
mcp_servers:
github:
url: https://api.githubcopilot.com/mcp/
transport: sse # also tried: http
allow_all_keys: true
headers:
Authorization: "Bearer os.environ/GITHUB_PAT"
Error (from docker compose logs)
LiteLLM:WARNING: client.py:385 - MCP client list_tools was cancelled
LiteLLM:WARNING: mcp_server_manager.py:1610 - Task cancelled while listing tools from github
File "/usr/lib/python3.13/site-packages/mcp/server/streamable_http_manager.py", line 117, in run
yield # Let the application run
^^^^^
GeneratorExit
...
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
Root Cause
This is an upstream bug in the MCP Python SDK. AnyIO requires cancel scopes to be entered and exited in the same task. ClientSessionGroup attempts concurrent teardown of session exit stacks from a different task context, violating this constraint.
Upstream tracking:
Environment
- LiteLLM image:
ghcr.io/berriai/litellm:main-stable
- Python: 3.13
- Transport tried:
sse, http
- Remote server:
https://api.githubcopilot.com/mcp/
Request
Track upstream PR modelcontextprotocol/python-sdk #2443 and update the mcp SDK dependency once the fix is merged.
Description
When adding a remote streamable-http MCP server to
config.yaml(e.g. GitHub's hosted MCP athttps://api.githubcopilot.com/mcp/), LiteLLM crashes during startup with:This prevents the server from initializing MCP tool discovery and the tools are never registered.
Config
Error (from
docker compose logs)Root Cause
This is an upstream bug in the MCP Python SDK. AnyIO requires cancel scopes to be entered and exited in the same task.
ClientSessionGroupattempts concurrent teardown of session exit stacks from a different task context, violating this constraint.Upstream tracking:
ClientSessionGroupteardown to sequentiallyawait aclose()instead of concurrent closure.Environment
ghcr.io/berriai/litellm:main-stablesse,httphttps://api.githubcopilot.com/mcp/Request
Track upstream PR modelcontextprotocol/python-sdk #2443 and update the
mcpSDK dependency once the fix is merged.