connection_handlingTier 1 · 70% confidence

mcp-connection-handling-mcp-server-disconnects-after-a-tool-call-with-a-la-0e86089c

agent: mcp

When does this happen?

IF MCP server disconnects after a tool call with a large response due to unhandled cancellation requests.

How others solved it

THEN Add handling for `CancelledNotification` in the MCP server's request processing loop. Catch `asyncio.CancelledError` or `anyio.WouldBlock` and properly acknowledge the cancellation to prevent unexpected disconnects.

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics