swift-sdk/Sources/MCP/Base/Utilities/Cancellation.swift
yehorsobko 973b46b8f7
feat: 2025-11-25 review fixes (#201)
* fix: review fixes of the latest changes

* fix: updated unit tests

* chore: more conformance compliance improvements

* chore: reverted protocol changes

* chore: more compliance improvements

* chore: more conformance compliance improvements

* chore: improvements to the backcompat and updated to Tool unit tests

* chore: ci update
2026-03-03 17:33:28 +02:00

29 lines
1.1 KiB
Swift

import Foundation
/// The Model Context Protocol supports cancellation of requests through
/// notification messages. Either side can send a cancellation notification
/// to indicate that a previously-issued request should be cancelled.
///
/// Cancellation is advisory: the receiver should make a best-effort attempt
/// to cancel the operation, but may not always be able to do so.
///
/// - SeeAlso: https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/cancellation
public struct CancelledNotification: Notification {
public static let name: String = "notifications/cancelled"
public struct Parameters: Hashable, Codable, Sendable {
/// The ID of the request to cancel.
///
/// This MUST correspond to the ID of a request previously issued
/// in the same direction. Optional per the spec (`requestId?`).
public let requestId: ID?
/// An optional human-readable reason for the cancellation.
public let reason: String?
public init(requestId: ID? = nil, reason: String? = nil) {
self.requestId = requestId
self.reason = reason
}
}
}