Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
61453a6
docs: update contributors list [skip ci]
taylorwilsdon Jun 2, 2025
fd5c1fc
add refresh all mcp button & supporting logic
taylorwilsdon Jun 2, 2025
f91cc5b
fully working, clean up debug
taylorwilsdon Jun 2, 2025
3b2b5d7
begin cleanup
taylorwilsdon Jun 2, 2025
34d28cb
console debug logging cleanup
taylorwilsdon Jun 2, 2025
ef16d37
more logging
taylorwilsdon Jun 2, 2025
9ed7924
Merge pull request #1 from taylorwilsdon/update-contributors
taylorwilsdon Jun 2, 2025
d3b0121
Merge branch 'RooCodeInc:main' into main
taylorwilsdon Jun 2, 2025
43e416a
Revert "Update contributors list"
taylorwilsdon Jun 2, 2025
e113f6f
Merge pull request #2 from taylorwilsdon/revert-1-update-contributors
taylorwilsdon Jun 2, 2025
8c64d5f
Merge branch 'main' of github.com:taylorwilsdon/Roo-Code into refresh…
taylorwilsdon Jun 2, 2025
aeac9e4
cleanup
taylorwilsdon Jun 2, 2025
8724b8d
add missing translations
taylorwilsdon Jun 2, 2025
0d4292c
Merge branch 'RooCodeInc:main' into main
taylorwilsdon Jun 3, 2025
23e39fa
Merge branch 'main' of github.com:taylorwilsdon/Roo-Code into refresh…
taylorwilsdon Jun 4, 2025
b3f680e
global and project level i18n strings
taylorwilsdon Jun 4, 2025
cdce3b0
refactor: move translations
daniel-lxs Jun 6, 2025
efe7363
fix: improve MCP settings buttons layout for responsive design
daniel-lxs Jun 6, 2025
c8d16ca
fix: Add missing vscode mock method and execa mock for McpHub tests
daniel-lxs Jun 6, 2025
7cc5305
fix: watch changes on project mcp settings file
daniel-lxs Jun 7, 2025
fa8887f
Merge branch 'main' into refresh_mcp
mrubens Jun 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
await updateGlobalState("enableMcpServerCreation", message.bool ?? true)
await provider.postStateToWebview()
break
case "refreshAllMcpServers": {
const mcpHub = provider.getMcpHub()
if (mcpHub) {
await mcpHub.refreshAllConnections()
}
break
}
// playSound handler removed - now handled directly in the webview
case "soundEnabled":
const soundEnabled = message.bool ?? true
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/ca/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
"mcp_server_not_found": "Servidor \"{{serverName}}\" no trobat a la configuració",
"custom_storage_path_set": "Ruta d'emmagatzematge personalitzada establerta: {{path}}",
"default_storage_path": "S'ha reprès l'ús de la ruta d'emmagatzematge predeterminada",
"settings_imported": "Configuració importada correctament."
"settings_imported": "Configuració importada correctament.",
"mcp_servers_active": "Servidors MCP actius: {{mcpServers}}",
"mcp_already_refreshing": "Els servidors MCP ja s'estan actualitzant.",
"mcp_refreshing_all": "Actualitzant tots els servidors MCP...",
"mcp_all_refreshed": "Tots els servidors MCP han estat actualitzats."
},
"answers": {
"yes": "Sí",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Server \"{{serverName}}\" nicht in der Konfiguration gefunden",
"custom_storage_path_set": "Benutzerdefinierter Speicherpfad festgelegt: {{path}}",
"default_storage_path": "Auf Standardspeicherpfad zurückgesetzt",
"settings_imported": "Einstellungen erfolgreich importiert."
"settings_imported": "Einstellungen erfolgreich importiert.",
"mcp_servers_active": "Aktive MCP-Server: {{mcpServers}}",
"mcp_already_refreshing": "MCP-Server werden bereits aktualisiert.",
"mcp_refreshing_all": "Alle MCP-Server werden aktualisiert...",
"mcp_all_refreshed": "Alle MCP-Server wurden aktualisiert."
},
"answers": {
"yes": "Ja",
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
"mcp_server_restarting": "Restarting {{serverName}} MCP server...",
"mcp_server_connected": "{{serverName}} MCP server connected",
"mcp_server_deleted": "Deleted MCP server: {{serverName}}",
"mcp_servers_active": "Active MCP Servers: {{mcpServers}}",
"mcp_server_not_found": "Server \"{{serverName}}\" not found in configuration",
"mcp_already_refreshing": "MCP servers are already refreshing.",
"mcp_refreshing_all": "Refreshing all MCP servers...",
"mcp_all_refreshed": "All MCP servers have been refreshed.",
"custom_storage_path_set": "Custom storage path set: {{path}}",
"default_storage_path": "Reverted to using default storage path",
"settings_imported": "Settings imported successfully."
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Servidor \"{{serverName}}\" no encontrado en la configuración",
"custom_storage_path_set": "Ruta de almacenamiento personalizada establecida: {{path}}",
"default_storage_path": "Se ha vuelto a usar la ruta de almacenamiento predeterminada",
"settings_imported": "Configuración importada correctamente."
"settings_imported": "Configuración importada correctamente.",
"mcp_servers_active": "Servidores MCP activos: {{mcpServers}}",
"mcp_already_refreshing": "Los servidores MCP ya se están actualizando.",
"mcp_refreshing_all": "Actualizando todos los servidores MCP...",
"mcp_all_refreshed": "Todos los servidores MCP han sido actualizados."
},
"answers": {
"yes": "Sí",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Serveur \"{{serverName}}\" introuvable dans la configuration",
"custom_storage_path_set": "Chemin de stockage personnalisé défini : {{path}}",
"default_storage_path": "Retour au chemin de stockage par défaut",
"settings_imported": "Paramètres importés avec succès."
"settings_imported": "Paramètres importés avec succès.",
"mcp_servers_active": "Serveurs MCP actifs : {{mcpServers}}",
"mcp_already_refreshing": "Les serveurs MCP sont déjà en cours de rafraîchissement.",
"mcp_refreshing_all": "Rafraîchissement de tous les serveurs MCP...",
"mcp_all_refreshed": "Tous les serveurs MCP ont été rafraîchis."
},
"answers": {
"yes": "Oui",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "सर्वर \"{{serverName}}\" कॉन्फ़िगरेशन में नहीं मिला",
"custom_storage_path_set": "कस्टम स्टोरेज पाथ सेट किया गया: {{path}}",
"default_storage_path": "डिफ़ॉल्ट स्टोरेज पाथ का उपयोग पुनः शुरू किया गया",
"settings_imported": "सेटिंग्स सफलतापूर्वक इम्पोर्ट की गईं।"
"settings_imported": "सेटिंग्स सफलतापूर्वक इम्पोर्ट की गईं.",
"mcp_servers_active": "सक्रिय एमसीपी सर्वर: {{mcpServers}}",
"mcp_already_refreshing": "एमसीपी सर्वर पहले से ही रीफ्रेश हो रहे हैं।",
"mcp_refreshing_all": "सभी एमसीपी सर्वर रीफ्रेश हो रहे हैं...",
"mcp_all_refreshed": "सभी एमसीपी सर्वर रीफ्रेश हो गए हैं।"
},
"answers": {
"yes": "हां",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/it/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Server \"{{serverName}}\" non trovato nella configurazione",
"custom_storage_path_set": "Percorso di archiviazione personalizzato impostato: {{path}}",
"default_storage_path": "Tornato al percorso di archiviazione predefinito",
"settings_imported": "Impostazioni importate con successo."
"settings_imported": "Impostazioni importate con successo.",
"mcp_servers_active": "Server MCP attivi: {{mcpServers}}",
"mcp_already_refreshing": "I server MCP sono già in aggiornamento.",
"mcp_refreshing_all": "Aggiornamento di tutti i server MCP...",
"mcp_all_refreshed": "Tutti i server MCP sono stati aggiornati."
},
"answers": {
"yes": "Sì",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/ja/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "サーバー\"{{serverName}}\"が設定内に見つかりません",
"custom_storage_path_set": "カスタムストレージパスが設定されました:{{path}}",
"default_storage_path": "デフォルトのストレージパスに戻りました",
"settings_imported": "設定が正常にインポートされました。"
"settings_imported": "設定が正常にインポートされました。",
"mcp_servers_active": "アクティブなMCPサーバー: {{mcpServers}}",
"mcp_already_refreshing": "MCPサーバーはすでに更新中です。",
"mcp_refreshing_all": "すべてのMCPサーバーを更新しています...",
"mcp_all_refreshed": "すべてのMCPサーバーが更新されました。"
},
"answers": {
"yes": "はい",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/ko/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "구성에서 서버 \"{{serverName}}\"을(를) 찾을 수 없습니다",
"custom_storage_path_set": "사용자 지정 저장 경로 설정됨: {{path}}",
"default_storage_path": "기본 저장 경로로 되돌아갔습니다",
"settings_imported": "설정이 성공적으로 가져와졌습니다."
"settings_imported": "설정이 성공적으로 가져와졌습니다.",
"mcp_servers_active": "활성 MCP 서버: {{mcpServers}}",
"mcp_already_refreshing": "MCP 서버가 이미 새로 고쳐지고 있습니다.",
"mcp_refreshing_all": "모든 MCP 서버를 새로 고치는 중...",
"mcp_all_refreshed": "모든 MCP 서버가 새로 고쳐졌습니다."
},
"answers": {
"yes": "예",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/nl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Server \"{{serverName}}\" niet gevonden in configuratie",
"custom_storage_path_set": "Aangepast opslagpad ingesteld: {{path}}",
"default_storage_path": "Terug naar standaard opslagpad",
"settings_imported": "Instellingen succesvol geïmporteerd."
"settings_imported": "Instellingen succesvol geïmporteerd.",
"mcp_servers_active": "Actieve MCP-servers: {{mcpServers}}",
"mcp_already_refreshing": "MCP-servers worden al vernieuwd.",
"mcp_refreshing_all": "Alle MCP-servers worden vernieuwd...",
"mcp_all_refreshed": "Alle MCP-servers zijn vernieuwd."
},
"answers": {
"yes": "Ja",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/pl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Serwer \"{{serverName}}\" nie znaleziony w konfiguracji",
"custom_storage_path_set": "Ustawiono niestandardową ścieżkę przechowywania: {{path}}",
"default_storage_path": "Wznowiono używanie domyślnej ścieżki przechowywania",
"settings_imported": "Ustawienia zaimportowane pomyślnie."
"settings_imported": "Ustawienia zaimportowane pomyślnie.",
"mcp_servers_active": "Aktywne serwery MCP: {{mcpServers}}",
"mcp_already_refreshing": "Serwery MCP są już odświeżane.",
"mcp_refreshing_all": "Odświeżanie wszystkich serwerów MCP...",
"mcp_all_refreshed": "Wszystkie serwery MCP zostały odświeżone."
},
"answers": {
"yes": "Tak",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/pt-BR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
"mcp_server_not_found": "Servidor \"{{serverName}}\" não encontrado na configuração",
"custom_storage_path_set": "Caminho de armazenamento personalizado definido: {{path}}",
"default_storage_path": "Retornado ao caminho de armazenamento padrão",
"settings_imported": "Configurações importadas com sucesso."
"settings_imported": "Configurações importadas com sucesso.",
"mcp_servers_active": "Servidores MCP ativos: {{mcpServers}}",
"mcp_already_refreshing": "Os servidores MCP já estão atualizando.",
"mcp_refreshing_all": "Atualizando todos os servidores MCP...",
"mcp_all_refreshed": "Todos os servidores MCP foram atualizados."
},
"answers": {
"yes": "Sim",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Сервер \"{{serverName}}\" не найден в конфигурации",
"custom_storage_path_set": "Установлен пользовательский путь хранения: {{path}}",
"default_storage_path": "Возвращено использование пути хранения по умолчанию",
"settings_imported": "Настройки успешно импортированы."
"settings_imported": "Настройки успешно импортированы.",
"mcp_servers_active": "Активные MCP серверы: {{mcpServers}}",
"mcp_already_refreshing": "MCP серверы уже обновляются.",
"mcp_refreshing_all": "Обновление всех MCP серверов...",
"mcp_all_refreshed": "Все MCP серверы обновлены."
},
"answers": {
"yes": "Да",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/tr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Yapılandırmada \"{{serverName}}\" sunucusu bulunamadı",
"custom_storage_path_set": "Özel depolama yolu ayarlandı: {{path}}",
"default_storage_path": "Varsayılan depolama yoluna geri dönüldü",
"settings_imported": "Ayarlar başarıyla içe aktarıldı."
"settings_imported": "Ayarlar başarıyla içe aktarıldı.",
"mcp_servers_active": "Aktif MCP Sunucuları: {{mcpServers}}",
"mcp_already_refreshing": "MCP sunucuları zaten yenileniyor.",
"mcp_refreshing_all": "Tüm MCP sunucuları yenileniyor...",
"mcp_all_refreshed": "Tüm MCP sunucuları yenilendi."
},
"answers": {
"yes": "Evet",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/vi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "Không tìm thấy máy chủ \"{{serverName}}\" trong cấu hình",
"custom_storage_path_set": "Đã thiết lập đường dẫn lưu trữ tùy chỉnh: {{path}}",
"default_storage_path": "Đã quay lại sử dụng đường dẫn lưu trữ mặc định",
"settings_imported": "Cài đặt đã được nhập thành công."
"settings_imported": "Cài đặt đã được nhập thành công.",
"mcp_servers_active": "Các máy chủ MCP đang hoạt động: {{mcpServers}}",
"mcp_already_refreshing": "Các máy chủ MCP đã đang làm mới.",
"mcp_refreshing_all": "Đang làm mới tất cả các máy chủ MCP...",
"mcp_all_refreshed": "Tất cả các máy chủ MCP đã được làm mới."
},
"answers": {
"yes": "Có",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/zh-CN/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "在配置中未找到服务器\"{{serverName}}\"",
"custom_storage_path_set": "自定义存储路径已设置:{{path}}",
"default_storage_path": "已恢复使用默认存储路径",
"settings_imported": "设置已成功导入。"
"settings_imported": "设置已成功导入。",
"mcp_servers_active": "活动的 MCP 服务器: {{mcpServers}}",
"mcp_already_refreshing": "MCP 服务器已在刷新中。",
"mcp_refreshing_all": "正在刷新所有 MCP 服务器...",
"mcp_all_refreshed": "所有 MCP 服务器已刷新。"
},
"answers": {
"yes": "是",
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/locales/zh-TW/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
"mcp_server_not_found": "在設定中沒有找到伺服器\"{{serverName}}\"",
"custom_storage_path_set": "自訂儲存路徑已設定:{{path}}",
"default_storage_path": "已恢復使用預設儲存路徑",
"settings_imported": "設定已成功匯入。"
"settings_imported": "設定已成功匯入。",
"mcp_servers_active": "活動的 MCP 伺服器: {{mcpServers}}",
"mcp_already_refreshing": "MCP 伺服器已在重新整理中。",
"mcp_refreshing_all": "正在重新整理所有 MCP 伺服器...",
"mcp_all_refreshed": "所有 MCP 伺服器已重新整理。"
},
"answers": {
"yes": "是",
Expand Down
118 changes: 110 additions & 8 deletions src/services/mcp/McpHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class McpHub {
const result = McpSettingsSchema.safeParse(config)

if (result.success) {
await this.updateServerConnections(result.data.mcpServers || {}, source)
await this.updateServerConnections(result.data.mcpServers || {}, source, false)
} else {
const errorMessages = result.error.errors
.map((err) => `${err.path.join(".")}: ${err.message}`)
Expand All @@ -409,7 +409,7 @@ export class McpHub {
if (source === "global") {
// Still try to connect with the raw config, but show warnings
try {
await this.updateServerConnections(config.mcpServers || {}, source)
await this.updateServerConnections(config.mcpServers || {}, source, false)
} catch (error) {
this.showErrorMessage(`Failed to initialize ${source} MCP servers with raw config`, error)
}
Expand Down Expand Up @@ -816,8 +816,11 @@ export class McpHub {
async updateServerConnections(
newServers: Record<string, any>,
source: "global" | "project" = "global",
manageConnectingState: boolean = true,
): Promise<void> {
this.isConnecting = true
if (manageConnectingState) {
this.isConnecting = true
}
this.removeAllFileWatchers()
// Filter connections by source
const currentConnections = this.connections.filter(
Expand Down Expand Up @@ -868,7 +871,9 @@ export class McpHub {
// If server exists with same config, do nothing
}
await this.notifyWebviewOfServerChanges()
this.isConnecting = false
if (manageConnectingState) {
this.isConnecting = false
}
}

private setupFileWatcher(
Expand Down Expand Up @@ -978,6 +983,73 @@ export class McpHub {
this.isConnecting = false
}

public async refreshAllConnections(): Promise<void> {
if (this.isConnecting) {
vscode.window.showInformationMessage(t("common:info.mcp_already_refreshing"))
return
}

this.isConnecting = true
vscode.window.showInformationMessage(t("common:info.mcp_refreshing_all"))

try {
const globalPath = await this.getMcpSettingsFilePath()
let globalServers: Record<string, any> = {}
try {
const globalContent = await fs.readFile(globalPath, "utf-8")
const globalConfig = JSON.parse(globalContent)
globalServers = globalConfig.mcpServers || {}
const globalServerNames = Object.keys(globalServers)
vscode.window.showInformationMessage(
t("common:info.mcp_servers_active", {
mcpServers: `Global: ${globalServerNames.join(", ") || "none"}`,
}),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nitpicks on the internationalization that I can help out with later:

  1. I think this would probably be better in another namespace - is there something better suited than common?
  2. Ideally we can also translate "Global", "Project", and "none". I think maybe I would have a global_mcp_servers_active and project_mcp_servers_active strings in case the order is different in any languages. "none" can probably live under common .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ the i18n is always a little different project to project, figured there would be a little bit of a learning curve. Happy to expand any coverage as needed!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mrubens, just circling back here to clean these up - should have some time after work tonight. I'm thinking todo items are:

  • add global_mcp_servers_active and project_mcp_servers_active in place of the general mcp_servers_active where applicable
  • refac mcp related i18n strings from common.json into mcp.json (clarifying question below)

The pattern I was following was where the existing mcp server related information messages lived ie "common:info.mcp_server_connected" based on #3865582 but I see there's also the mcp.json in each locale so I'm thinking that is probably the right home? Let me know if that's the correct landing spot more than happy to handle the refac. I can move all the mcp related ones into mcp.json unless you'd prefer otherwise!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added global and project level + i18n in current location and pushed up, will hold off until I hear otherwise as far as moving them into a different locale file. Looking at the structure, it appears you've got two different approaches:

  • /src/i18n/locales/{locale}/ with common.json & tools.json as the only options
  • /webview-ui/src/i18n/locales/{locale} with account.json chat.json common.json mcp.json etc

The existing i18n in McpHub all pull from the former source so if approved I will refac to place all of those in mcp.json in their relevant webview-ui locale

)
} catch (error) {
console.log("Error reading global MCP config:", error)
}

const projectPath = await this.getProjectMcpPath()
let projectServers: Record<string, any> = {}
if (projectPath) {
try {
const projectContent = await fs.readFile(projectPath, "utf-8")
const projectConfig = JSON.parse(projectContent)
projectServers = projectConfig.mcpServers || {}
const projectServerNames = Object.keys(projectServers)
vscode.window.showInformationMessage(
t("common:info.mcp_servers_active", {
mcpServers: `Project: ${projectServerNames.join(", ") || "none"}`,
}),
)
} catch (error) {
console.log("Error reading project MCP config:", error)
}
}

// Clear all existing connections first
const existingConnections = [...this.connections]
for (const conn of existingConnections) {
await this.deleteConnection(conn.server.name, conn.server.source)
}

// Re-initialize all servers from scratch
// This ensures proper initialization including fetching tools, resources, etc.
await this.initializeMcpServers("global")
await this.initializeMcpServers("project")

await delay(100)

await this.notifyWebviewOfServerChanges()

vscode.window.showInformationMessage(t("common:info.mcp_all_refreshed"))
} catch (error) {
this.showErrorMessage("Failed to refresh MCP servers", error)
} finally {
this.isConnecting = false
}
}

private async notifyWebviewOfServerChanges(): Promise<void> {
// Get global server order from settings file
const settingsPath = await this.getMcpSettingsFilePath()
Expand Down Expand Up @@ -1020,10 +1092,40 @@ export class McpHub {
})

// Send sorted servers to webview
await this.providerRef.deref()?.postMessageToWebview({
type: "mcpServers",
mcpServers: sortedConnections.map((connection) => connection.server),
})
// Try to get the currently visible ClineProvider instance first
let targetProvider: ClineProvider | undefined = undefined
try {
// ClineProvider.getInstance() can focus the view if not visible,
// and returns a Promise<ClineProvider | undefined>
const instancePromise = ClineProvider.getInstance()
if (instancePromise) {
targetProvider = await instancePromise
}
} catch (error) {}

// Fallback to the providerRef if getInstance didn't yield a provider
if (!targetProvider) {
targetProvider = this.providerRef.deref()
}

if (targetProvider) {
const serversToSend = sortedConnections.map((connection) => connection.server)

const message = {
type: "mcpServers" as const,
mcpServers: serversToSend,
}

try {
await targetProvider.postMessageToWebview(message)
} catch (error) {
console.error("[McpHub] Error calling targetProvider.postMessageToWebview:", error)
}
} else {
console.error(
"[McpHub] No target provider available (neither from getInstance nor providerRef) - cannot send mcpServers message to webview",
)
}
}

public async toggleServerDisabled(
Expand Down
Loading
Loading