Merge pull request #563 from davenpi/client-cancel-notification

Add client method to send cancellation notifications
This commit is contained in:
Jeremiah Lowin 2025-05-22 21:19:13 -04:00 committed by GitHub
commit 20df646c6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -210,6 +210,23 @@ class Client:
result = await self.session.send_ping()
return isinstance(result, mcp.types.EmptyResult)
async def cancel(
self,
request_id: str | int,
reason: str | None = None,
) -> None:
"""Send a cancellation notification for an in-progress request."""
notification = mcp.types.ClientNotification(
mcp.types.CancelledNotification(
method="notifications/cancelled",
params=mcp.types.CancelledNotificationParams(
requestId=request_id,
reason=reason,
),
)
)
await self.session.send_notification(notification)
async def progress(
self,
progress_token: str | int,