Skip to content

Conversation

@patvice
Copy link
Owner

@patvice patvice commented Nov 24, 2025

Add MCP Cancellation Notification Support

Implements support for the MCP protocol's notifications/cancelled message, enabling servers to cancel long-running client operations.

Changes

  • CancellableOperation - Thread-safe wrapper for cancellable operations that executes work in separate threads
  • Notifications::Cancelled - Sends cancellation notifications to servers with request ID and reason
  • NotificationHandler - Processes incoming notifications/cancelled messages and triggers cancellation
  • Client#cancel_in_flight_request - Cancels in-flight operations by request ID
  • Errors::RequestCancelled - New error type for signaling cancelled requests
  • Integration and unit tests covering cancellation flows

Enables servers to interrupt client operations like sampling requests that are taking too long or are no longer needed.

@patvice patvice merged commit f5e9b4f into main Nov 25, 2025
4 checks passed
@patvice patvice deleted the cancelation-notification-support branch November 25, 2025 01:51
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.

2 participants