Skip to content

MCP tool calls do not honor abort_controller; ESC during a long-running MCP tool hangs until completion #277

Description

@ericleepi314

Files: src/services/mcp/client.py, src/services/mcp/transport.py

Background: PR #135 explicitly defers MCP cancellation:

MCP tools: out-of-process JSON-RPC; transport-level cancellation is a cross-cutting change across the entire MCP client.

Verification: grep -rln abort_controller src/services/mcp/ returns nothing on current main.

Impact: A slow MCP tool (database query, remote API exposed by a plugin) cannot be cancelled mid-call. If the server hangs, the REPL hangs with it until the (often generous) MCP request timeout.

Fix sketch: JSON-RPC 2.0 supports $/cancelRequest. Plumb the abort signal through McpClient.call_tool, send $/cancelRequest with the in-flight request id on abort, then return an AbortError. Servers that ignore the notification still leak a request but the client unblocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions