Skip to content

Add cancel button for task polling#1193

Open
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Christian-Sidak:fix/cancel-polling-task
Open

Add cancel button for task polling#1193
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Christian-Sidak:fix/cancel-polling-task

Conversation

@Christian-Sidak
Copy link
Copy Markdown

Summary

Fixes #1039

When a tool is run as a task and the inspector polls for status, there is no way to cancel the polling loop. The "Run Tool" button is disabled while polling, leaving the user stuck waiting indefinitely if a task never completes.

This PR adds a "Cancel Polling" button that appears next to the disabled "Run Tool" button during active polling. Clicking it aborts the polling loop immediately using an AbortController, and the tool result area displays a message indicating that polling was cancelled (the server-side task may still be running).

Changes

  • client/src/App.tsx: Added an AbortController ref to manage the polling lifecycle. The polling sleep is now cancellable via the abort signal. A cancelPolling callback is passed to ToolsTab.
  • client/src/components/ToolsTab.tsx: Added an optional cancelPolling prop and a red "Cancel Polling" button that renders when polling is active.

Test plan

  • All 487 existing tests pass
  • Manual: run a tool as a task against a server that creates long-running tasks, verify the "Cancel Polling" button appears and stops polling when clicked
  • Verify the "Run Tool" button becomes re-enabled after cancellation

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.

Can't cancel the polling task

1 participant