-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add toggle functionality for enabling/disabling/reloading all MCP servers #3737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4dce299
6a015ab
74384e2
783cbc6
ac26ff6
03d96ab
a7a96fb
e8f99e2
7d5dd40
cc278a6
0123cad
8856dab
8d937c3
fe0a70e
999d27b
442ad40
fe34086
f0596ac
77e9ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1306,4 +1306,52 @@ export class McpHub { | |
| } | ||
| this.disposables.forEach((d) => d.dispose()) | ||
| } | ||
|
|
||
| /** | ||
| * Enables or disables all global MCP servers at once. | ||
| * When activated, the configuration is reloaded. | ||
| * @param disabled true = disable all, false = enable all | ||
| */ | ||
| public async toggleAllServersDisabled(disabled: boolean): Promise<void> { | ||
| // Collect all global server names | ||
| const allServers = this.getAllServers() | ||
|
|
||
| // Set the Disabled flag for all servers | ||
| for (const server of allServers) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As also noted by a previous comment, updating server configurations sequentially in this loop: It might be a good idea to use |
||
| await this.updateServerConfig(server.name, { disabled }, server.source) | ||
| const conn = this.findConnection(server.name, server.source) | ||
| if (conn) { | ||
| conn.server.disabled = disabled | ||
| } | ||
| } | ||
|
|
||
| // If activated, reload configuration | ||
| if (!disabled) { | ||
| // Re-initialize all servers, both global and project | ||
| await this.initializeMcpServers("global") | ||
| await this.initializeMcpServers("project") | ||
| } | ||
|
|
||
| await this.notifyWebviewOfServerChanges() | ||
| } | ||
|
|
||
| /** | ||
| * Restarts all currently active MCP servers. | ||
| * This will trigger a popup for each server being restarted. | ||
| */ | ||
| public async restartAllMcpServers(): Promise<void> { | ||
| const allServers = this.getAllServers() // Get all servers, regardless of disabled state | ||
| const restartPromises = allServers.map(async (server) => { | ||
| // Only restart if not disabled | ||
| if (!server.disabled) { | ||
| try { | ||
| await this.restartConnection(server.name, server.source) | ||
| } catch (error) { | ||
| this.showErrorMessage(`Failed to restart MCP server ${server.name}`, error) | ||
| } | ||
| } | ||
| }) | ||
| await Promise.all(restartPromises) | ||
| await this.notifyWebviewOfServerChanges() | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.