@@ -16,8 +16,8 @@ import * as fs from "fs/promises"
1616import * as path from "path"
1717import * as vscode from "vscode"
1818import { z } from "zod"
19+ import debounce from "lodash.debounce"
1920import { t } from "../../i18n"
20- import { countdown } from "kontroll"
2121
2222import { ClineProvider } from "../../core/webview/ClineProvider"
2323import { GlobalFileNames } from "../../shared/globalFileNames"
@@ -113,6 +113,10 @@ export class McpHub {
113113 isConnecting : boolean = false
114114 private refCount : number = 0 // Reference counter for active clients
115115
116+ private debouncedReloadLogic = debounce ( ( ) => {
117+ this . reloadMcpServers ( )
118+ } , 1000 )
119+
116120 constructor ( provider : ClineProvider ) {
117121 this . providerRef = new WeakRef ( provider )
118122 this . watchMcpSettingsFile ( )
@@ -355,16 +359,7 @@ export class McpHub {
355359 }
356360
357361 public async reloadMcpServers ( ) {
358- if ( this . isConnecting ) {
359- countdown (
360- 2000 ,
361- ( ) => {
362- this . reloadMcpServers ( )
363- } ,
364- { key : "reloadMcpServers" } ,
365- )
366- return
367- }
362+ if ( this . isConnecting ) this . debouncedReloadLogic ( )
368363
369364 await this . initializeProjectMcpServers ( )
370365 await this . initializeGlobalMcpServers ( )
0 commit comments