Jeremiah Lowin commited on
Commit
4863d2f
·
unverified ·
2 Parent(s): b89bc471b886a3

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

Browse files
Files changed (1) hide show
  1. src/fastmcp/client/client.py +17 -0
src/fastmcp/client/client.py CHANGED
@@ -210,6 +210,23 @@ class Client:
210
  result = await self.session.send_ping()
211
  return isinstance(result, mcp.types.EmptyResult)
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  async def progress(
214
  self,
215
  progress_token: str | int,
 
210
  result = await self.session.send_ping()
211
  return isinstance(result, mcp.types.EmptyResult)
212
 
213
+ async def cancel(
214
+ self,
215
+ request_id: str | int,
216
+ reason: str | None = None,
217
+ ) -> None:
218
+ """Send a cancellation notification for an in-progress request."""
219
+ notification = mcp.types.ClientNotification(
220
+ mcp.types.CancelledNotification(
221
+ method="notifications/cancelled",
222
+ params=mcp.types.CancelledNotificationParams(
223
+ requestId=request_id,
224
+ reason=reason,
225
+ ),
226
+ )
227
+ )
228
+ await self.session.send_notification(notification)
229
+
230
  async def progress(
231
  self,
232
  progress_token: str | int,