mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 05:24:18 +02:00
Merge pull request #563 from davenpi/client-cancel-notification
Add client method to send cancellation notifications
This commit is contained in:
commit
20df646c6f
1 changed files with 17 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue