Skip to content

Commit 94488b6

Browse files
chipgptmattzcarey
authored andcommitted
debounce the handler calls
1 parent 3c55425 commit 94488b6

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
@@ -820,6 +820,12 @@ export class Client<
820820
this._toolListChangedOptions = toolListChangedOptions;
821821

822822
const refreshToolList = async () => {
823+
// If autoRefresh is false, call the callback for the notification, but without tools data
824+
if (!toolListChangedOptions.autoRefresh) {
825+
toolListChangedOptions.onToolListChanged?.(null, null);
826+
return;
827+
}
828+
823829
let tools: Tool[] | null = null;
824830
let error: Error | null = null;
825831
try {
@@ -832,12 +838,6 @@ export class Client<
832838
};
833839

834840
this.setNotificationHandler(ToolListChangedNotificationSchema, () => {
835-
// If autoRefresh is false, call the callback for the notification, but without tools data
836-
if (!toolListChangedOptions.autoRefresh) {
837-
toolListChangedOptions.onToolListChanged?.(null, null);
838-
return;
839-
}
840-
841841
if (toolListChangedOptions.debounceMs) {
842842
// Clear any pending debounce timer
843843
if (this._toolListChangedDebounceTimer) {

0 commit comments

Comments
 (0)