Skip to content

Commit 27b5410

Browse files
Add support for additional notification schemas in useConnection hook
1 parent dd460bd commit 27b5410

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

client/src/lib/hooks/useConnection.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
ClientRequest,
99
CreateMessageRequestSchema,
1010
ListRootsRequestSchema,
11+
ProgressNotificationSchema,
12+
ResourceUpdatedNotificationSchema,
13+
LoggingMessageNotificationSchema,
1114
Request,
1215
Result,
1316
ServerCapabilities,
@@ -16,6 +19,10 @@ import {
1619
McpError,
1720
CompleteResultSchema,
1821
ErrorCode,
22+
CancelledNotificationSchema,
23+
ResourceListChangedNotificationSchema,
24+
ToolListChangedNotificationSchema,
25+
PromptListChangedNotificationSchema,
1926
} from "@modelcontextprotocol/sdk/types.js";
2027
import { useState } from "react";
2128
import { toast } from "react-toastify";
@@ -247,6 +254,18 @@ export function useConnection({
247254
});
248255

249256
if (onNotification) {
257+
[
258+
CancelledNotificationSchema,
259+
ProgressNotificationSchema,
260+
LoggingMessageNotificationSchema,
261+
ResourceUpdatedNotificationSchema,
262+
ResourceListChangedNotificationSchema,
263+
ToolListChangedNotificationSchema,
264+
PromptListChangedNotificationSchema,
265+
].forEach((notificationSchema) => {
266+
client.setNotificationHandler(notificationSchema, onNotification);
267+
});
268+
250269
client.fallbackNotificationHandler = (
251270
notification: Notification,
252271
): Promise<void> => {

0 commit comments

Comments
 (0)