Skip to content

Propagate MCP tool cancellation to host executors - #803

Merged
Aymericr merged 1 commit into
mainfrom
fix/mcp-execution-cancellation-20260909
Sep 9, 2026
Merged

Propagate MCP tool cancellation to host executors#803
Aymericr merged 1 commit into
mainfrom
fix/mcp-execution-cancellation-20260909

Conversation

@Aymericr

@Aymericr Aymericr commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

MCP hosts that queue tool handlers need the SDK request cancellation signal before executing queued work. The server wrapper now passes each handler's AbortSignal to executeTool and applies the wrapper to both registerTool() and the deprecated tool() registration surface, so tools added after server creation cannot bypass host sequencing or cancellation policy.

Validation

  • bun test packages/mcp/src — 359 tests, 1,361 assertions passed.
  • bunx ultracite check packages/mcp/src/server.ts packages/mcp/src/server.test.ts
  • git diff --check

Note

Medium Risk
Extends the public executeTool contract and changes when queued hosts may run or skip tool callbacks on cancellation.

Overview
MCP hosts that wrap tool execution (e.g. to queue work) can now observe request cancellation before the underlying handler runs.

PascalMcpToolExecutor gains a required signal: AbortSignal, and installToolExecutor forwards the SDK request signal from handler arguments for both registerTool and the deprecated tool() path so late-registered tools still go through the host wrapper. Tests cover signal presence, abort-before-callback (tool body never runs), and legacy registration.

Reviewed by Cursor Bugbot for commit 6ac73da. Bugbot is set up for automated code reviews on this repo. Configure here.

@pascal

pascal Bot commented Sep 9, 2026

Copy link
Copy Markdown

I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…).

Please try again, rephrase, or reach out if it keeps failing.

Error id: 180318f6-425c-46ee-acfc-1d58c991f3d9

@Aymericr
Aymericr merged commit 0419601 into main Sep 9, 2026
4 checks passed
@Aymericr
Aymericr deleted the fix/mcp-execution-cancellation-20260909 branch September 9, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant