Skip to content

Commit e8e9af8

Browse files
committed
debounce the handler calls
1 parent 2762a63 commit e8e9af8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/client/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ export class Client<
497497
this._toolListChangedOptions = toolListChangedOptions;
498498

499499
const refreshToolList = async () => {
500+
// If autoRefresh is false, call the callback for the notification, but without tools data
501+
if (!toolListChangedOptions.autoRefresh) {
502+
toolListChangedOptions.onToolListChanged?.(null, null);
503+
return;
504+
}
505+
500506
let tools: Tool[] | null = null;
501507
let error: Error | null = null;
502508
try {
@@ -509,12 +515,6 @@ export class Client<
509515
};
510516

511517
this.setNotificationHandler(ToolListChangedNotificationSchema, () => {
512-
// If autoRefresh is false, call the callback for the notification, but without tools data
513-
if (!toolListChangedOptions.autoRefresh) {
514-
toolListChangedOptions.onToolListChanged?.(null, null);
515-
return;
516-
}
517-
518518
if (toolListChangedOptions.debounceMs) {
519519
// Clear any pending debounce timer
520520
if (this._toolListChangedDebounceTimer) {

0 commit comments

Comments
 (0)