You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37Lines changed: 37 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -913,6 +913,43 @@ const transport = new StdioServerTransport();
913
913
awaitserver.connect(transport);
914
914
```
915
915
916
+
### Improving Network Efficiency with Notification Debouncing
917
+
918
+
When performing bulk updates that trigger notifications (e.g., enabling or disabling multiple tools in a loop), the SDK can send a large number of messages in a short period. To improve performance and reduce network traffic, you can enable notification debouncing.
919
+
920
+
This feature coalesces multiple, rapid calls for the same notification type into a single message. For example, if you disable five tools in a row, only one `notifications/tools/list_changed` message will be sent instead of five.
921
+
922
+
> [!IMPORTANT]
923
+
> This feature is designed for "simple" notifications that do not carry unique data in their parameters. To prevent silent data loss, debouncing is **automatically bypassed** for any notification that contains a `params` object or a `relatedRequestId`. Such notifications will always be sent immediately.
924
+
925
+
This is an opt-in feature configured during server initialization.
Copy file name to clipboardExpand all lines: src/shared/protocol.ts
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,13 @@ export type ProtocolOptions = {
45
45
* Currently this defaults to false, for backwards compatibility with SDK versions that did not advertise capabilities correctly. In future, this will default to true.
46
46
*/
47
47
enforceStrictCapabilities?: boolean;
48
+
/**
49
+
* An array of notification method names that should be automatically debounced.
50
+
* Any notifications with a method in this list will be coalesced if they
51
+
* occur in the same tick of the event loop.
52
+
* e.g., ['notifications/tools/list_changed']
53
+
*/
54
+
debouncedNotificationMethods?: string[];
48
55
};
49
56
50
57
/**
@@ -191,6 +198,7 @@ export abstract class Protocol<
0 commit comments