McpClient.cancel

Cancel an in-flight request by sending notifications/cancelled for requestId (basic/utilities/cancellation: "Either side can send a cancellation notification ... to indicate that a previously-issued request should be terminated"). After this call, any response the server still sends for requestId is ignored, per "The sender of the cancellation notification SHOULD ignore any response to the request that arrives afterward". reason is an optional free-form explanation included in the notification when non-empty.

Per spec, the initialize request MUST NOT be cancelled by clients; attempting to cancel the id of the initialize request throws.

class McpClient
@safe
void
cancel
(,
string reason = null
)