@@ -19,6 +19,10 @@ import {
19
19
McpError ,
20
20
CompleteResultSchema ,
21
21
ErrorCode ,
22
+ CancelledNotificationSchema ,
23
+ ResourceListChangedNotificationSchema ,
24
+ ToolListChangedNotificationSchema ,
25
+ PromptListChangedNotificationSchema ,
22
26
} from "@modelcontextprotocol/sdk/types.js" ;
23
27
import { useState } from "react" ;
24
28
import { toast } from "react-toastify" ;
@@ -250,20 +254,24 @@ export function useConnection({
250
254
} ) ;
251
255
252
256
if ( onNotification ) {
253
- client . setNotificationHandler (
257
+ [
258
+ CancelledNotificationSchema ,
254
259
ProgressNotificationSchema ,
255
- onNotification ,
256
- ) ;
257
-
258
- client . setNotificationHandler (
260
+ LoggingMessageNotificationSchema ,
259
261
ResourceUpdatedNotificationSchema ,
260
- onNotification ,
261
- ) ;
262
+ ResourceListChangedNotificationSchema ,
263
+ ToolListChangedNotificationSchema ,
264
+ PromptListChangedNotificationSchema ,
265
+ ] . forEach ( ( notificationSchema ) => {
266
+ client . setNotificationHandler ( notificationSchema , onNotification ) ;
267
+ } ) ;
262
268
263
- client . setNotificationHandler (
264
- LoggingMessageNotificationSchema ,
265
- onNotification ,
266
- ) ;
269
+ client . fallbackNotificationHandler = (
270
+ notification : Notification ,
271
+ ) : Promise < void > => {
272
+ onNotification ( notification ) ;
273
+ return Promise . resolve ( ) ;
274
+ } ;
267
275
}
268
276
269
277
if ( onStdErrNotification ) {
0 commit comments