@@ -941,20 +941,26 @@ export class McpHub {
941941
942942 // Update the connection object
943943 if ( connection ) {
944- try {
945- connection . server . disabled = disabled
944+ const wasDisabled = connection . server . disabled
945+ connection . server . disabled = disabled
946+
947+ // When the server is activated, reload the configuration
948+ if ( wasDisabled && ! disabled ) {
949+ await this . initializeMcpServers ( serverSource )
950+ }
946951
947- // Only refresh capabilities if connected
948- if ( connection . server . status === "connected" ) {
952+ // Only refresh capabilities if connected
953+ if ( connection . server . status === "connected" ) {
954+ try {
949955 connection . server . tools = await this . fetchToolsList ( serverName , serverSource )
950956 connection . server . resources = await this . fetchResourcesList ( serverName , serverSource )
951957 connection . server . resourceTemplates = await this . fetchResourceTemplatesList (
952958 serverName ,
953959 serverSource ,
954960 )
961+ } catch ( error ) {
962+ console . error ( `Failed to refresh capabilities for ${ serverName } :` , error )
955963 }
956- } catch ( error ) {
957- console . error ( `Failed to refresh capabilities for ${ serverName } :` , error )
958964 }
959965 }
960966
@@ -1287,4 +1293,33 @@ export class McpHub {
12871293 }
12881294 this . disposables . forEach ( ( d ) => d . dispose ( ) )
12891295 }
1296+
1297+ /**
1298+ * Enables or disables all global MCP servers at once.
1299+ * When activated, the configuration is reloaded.
1300+ * @param disabled true = disable all, false = enable all
1301+ */
1302+ public async toggleAllServersDisabled ( disabled : boolean ) : Promise < void > {
1303+ // Collect all global server names
1304+ const globalConnections = this . connections . filter (
1305+ ( conn ) => conn . server . source === "global" || ! conn . server . source ,
1306+ )
1307+ const serverNames = globalConnections . map ( ( conn ) => conn . server . name )
1308+
1309+ // Set the Disabled flag for all serversv
1310+ for ( const name of serverNames ) {
1311+ await this . updateServerConfig ( name , { disabled } , "global" )
1312+ const conn = this . findConnection ( name , "global" )
1313+ if ( conn ) {
1314+ conn . server . disabled = disabled
1315+ }
1316+ }
1317+
1318+ // If activated, reload configuration
1319+ if ( ! disabled ) {
1320+ await this . initializeMcpServers ( "global" )
1321+ }
1322+
1323+ await this . notifyWebviewOfServerChanges ( )
1324+ }
12901325}
0 commit comments