Skip to content

[FEATURE]: Notify MCP servers when users cancel tool calls #24312

@wybb

Description

@wybb

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

When a user cancels an opencode turn while an MCP tool is running, opencode should notify the MCP server so the server can stop the in-flight tool work.

Problem

Today the local opencode session/tool state can be cancelled, but the MCP tool request itself may keep running on the MCP server. This can leave external work, subprocesses, browser sessions, or other long-running handlers active after the user has cancelled.

Expected behavior

User-initiated cancellation should be forwarded to the pending MCP request. The MCP server should receive the standard MCP cancellation notification for that request.

Suggested implementation

Forward the tool execution abort signal to the MCP SDK request options when calling client.callTool:

  • pass opts.abortSignal as RequestOptions.signal
  • keep existing local cancellation behavior unchanged

Acceptance criteria

  • Cancelling an opencode turn while an MCP tool is running cancels the pending MCP request.
  • The MCP server receives a cancellation notification for that request.
  • Existing local cancellation behavior still works.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions