@@ -188,13 +188,14 @@ export class McpEventHandler {
188188 ] ,
189189 }
190190
191- // if (mcpManager.isServerDisabled(serverName)) {
192- // disabledItems.push(item)
193- // } else {
194- activeItems . push ( {
195- ...item ,
196- description : `${ toolsCount } ` ,
197- } )
191+ if ( mcpManager . isServerDisabled ( serverName ) ) {
192+ disabledItems . push ( item )
193+ } else {
194+ activeItems . push ( {
195+ ...item ,
196+ description : `${ toolsCount } ` ,
197+ } )
198+ }
198199 } )
199200
200201 // Create the groups
@@ -865,8 +866,10 @@ export class McpEventHandler {
865866 return { id : params . id }
866867 }
867868
869+ const mcpManager = McpManager . instance
870+
868871 // Get the appropriate agent path
869- const agentPath = await this . #getAgentPath ( )
872+ const agentPath = mcpManager . getAllServerConfigs ( ) . get ( serverName ) ?. __configPath__
870873
871874 const perm : MCPServerPermission = {
872875 enabled : true ,
@@ -878,12 +881,12 @@ export class McpEventHandler {
878881 this . #isProgrammaticChange = true
879882
880883 try {
881- await McpManager . instance . updateServerPermission ( serverName , perm )
884+ await mcpManager . updateServerPermission ( serverName , perm )
882885 this . #emitMCPConfigEvent( )
883886 } catch ( error ) {
884887 this . #features. logging . error ( `Failed to enable MCP server: ${ error } ` )
888+ this . #isProgrammaticChange = false
885889 }
886- this . #isProgrammaticChange = false
887890 return { id : params . id }
888891 }
889892
@@ -896,8 +899,9 @@ export class McpEventHandler {
896899 return { id : params . id }
897900 }
898901
902+ const mcpManager = McpManager . instance
899903 // Get the appropriate agent path
900- const agentPath = await this . #getAgentPath ( )
904+ const agentPath = mcpManager . getAllServerConfigs ( ) . get ( serverName ) ?. __configPath__
901905
902906 const perm : MCPServerPermission = {
903907 enabled : false ,
@@ -909,13 +913,13 @@ export class McpEventHandler {
909913 this . #isProgrammaticChange = true
910914
911915 try {
912- await McpManager . instance . updateServerPermission ( serverName , perm )
916+ await mcpManager . updateServerPermission ( serverName , perm )
913917 this . #emitMCPConfigEvent( )
914918 } catch ( error ) {
915919 this . #features. logging . error ( `Failed to disable MCP server: ${ error } ` )
920+ this . #isProgrammaticChange = false
916921 }
917922
918- this . #isProgrammaticChange = false
919923 return { id : params . id }
920924 }
921925
@@ -1229,7 +1233,9 @@ export class McpEventHandler {
12291233 // Emit MCP config event after reinitialization
12301234 const mcpManager = McpManager . instance
12311235 const serverConfigs = mcpManager . getAllServerConfigs ( )
1232- const activeServers = Array . from ( serverConfigs . entries ( ) )
1236+ const activeServers = Array . from ( serverConfigs . entries ( ) ) . filter (
1237+ ( [ name , _ ] ) => ! mcpManager . isServerDisabled ( name )
1238+ )
12331239
12341240 // Get the global agent path
12351241 const globalAgentPath = getGlobalAgentConfigPath ( this . #features. workspace . fs . getUserHomeDir ( ) )
@@ -1267,12 +1273,12 @@ export class McpEventHandler {
12671273 // Emit server initialize events for all active servers
12681274 for ( const [ serverName , config ] of serverConfigs . entries ( ) ) {
12691275 const transportType = config . command ? 'stdio' : 'http'
1270- // const enabled = !mcpManager.isServerDisabled(serverName)
1276+ const enabled = ! mcpManager . isServerDisabled ( serverName )
12711277 this . #telemetryController?. emitMCPServerInitializeEvent ( {
12721278 source : 'reload' ,
12731279 command : transportType === 'stdio' ? config . command : undefined ,
12741280 url : transportType === 'http' ? config . url : undefined ,
1275- enabled : true ,
1281+ enabled : enabled ,
12761282 numTools : mcpManager . getAllToolsWithPermissions ( serverName ) . length ,
12771283 scope : config . __configPath__ === globalAgentPath ? 'global' : 'workspace' ,
12781284 transportType : 'stdio' ,
@@ -1319,12 +1325,10 @@ export class McpEventHandler {
13191325 * @returns The agent path to use (workspace if exists, otherwise global)
13201326 */
13211327 async #getAgentPath( isGlobal : boolean = true ) : Promise < string > {
1328+ const globalAgentPath = getGlobalAgentConfigPath ( this . #features. workspace . fs . getUserHomeDir ( ) )
13221329 if ( isGlobal ) {
1323- return getGlobalAgentConfigPath ( this . #features . workspace . fs . getUserHomeDir ( ) )
1330+ return globalAgentPath
13241331 }
1325-
1326- const globalAgentPath = getGlobalAgentConfigPath ( this . #features. workspace . fs . getUserHomeDir ( ) )
1327-
13281332 // Get workspace folders and check for workspace agent path
13291333 const workspaceFolders = this . #features. workspace . getAllWorkspaceFolders ( )
13301334 if ( workspaceFolders && workspaceFolders . length > 0 ) {
0 commit comments