notifyCancelled method

void notifyCancelled(
  1. String requestId, {
  2. String? reason,
})

Cancel an in-flight server-side operation.

Per spec, cancellation is a NOTIFICATION (notifications/cancelled), not a request — fire-and-forget with requestId and an optional reason.

Implementation

void notifyCancelled(String requestId, {String? reason}) {
  if (!_initialized) {
    throw McpError('Client is not initialized');
  }
  _sendNotification('notifications/cancelled', {
    'requestId': requestId,
    if (reason != null) 'reason': reason,
  });
}