Skip to content

Commit 1918562

Browse files
committed
fix: add CancelledNotification type to prevent Claude Desktop from crashing server
1 parent 2efa525 commit 1918562

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/mcp/types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ class InitializedNotification(Notification):
296296
method: Literal["notifications/initialized"]
297297
params: NotificationParams | None = None
298298

299+
class CancelledNotification(Notification):
300+
"""This notification is sent from the client to the server when it decides to
301+
cancel a request."""
302+
303+
# method: Literal["notifications/cancelled"] - this is what it should be but Claude Desktop is probably using an internal SDK
304+
method: Literal["cancelled"]
305+
params: NotificationParams | None = None
306+
299307

300308
class PingRequest(Request):
301309
"""
@@ -997,7 +1005,7 @@ class ClientRequest(
9971005

9981006
class ClientNotification(
9991007
RootModel[
1000-
ProgressNotification | InitializedNotification | RootsListChangedNotification
1008+
CancelledNotification | ProgressNotification | InitializedNotification | RootsListChangedNotification
10011009
]
10021010
):
10031011
pass

0 commit comments

Comments
 (0)