Skip to content

Commit ac26ff6

Browse files
committed
revert mcp changes
1 parent 783cbc6 commit ac26ff6

File tree

2 files changed

+6
-113
lines changed

2 files changed

+6
-113
lines changed

src/services/mcp/McpHub.ts

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -960,26 +960,20 @@ export class McpHub {
960960

961961
// Update the connection object
962962
if (connection) {
963-
const wasDisabled = connection.server.disabled
964-
connection.server.disabled = disabled
965-
966-
// When the server is activated, reload the configuration
967-
if (wasDisabled && !disabled) {
968-
await this.initializeMcpServers(serverSource)
969-
}
963+
try {
964+
connection.server.disabled = disabled
970965

971-
// Only refresh capabilities if connected
972-
if (connection.server.status === "connected") {
973-
try {
966+
// Only refresh capabilities if connected
967+
if (connection.server.status === "connected") {
974968
connection.server.tools = await this.fetchToolsList(serverName, serverSource)
975969
connection.server.resources = await this.fetchResourcesList(serverName, serverSource)
976970
connection.server.resourceTemplates = await this.fetchResourceTemplatesList(
977971
serverName,
978972
serverSource,
979973
)
980-
} catch (error) {
981-
console.error(`Failed to refresh capabilities for ${serverName}:`, error)
982974
}
975+
} catch (error) {
976+
console.error(`Failed to refresh capabilities for ${serverName}:`, error)
983977
}
984978
}
985979

@@ -1312,33 +1306,4 @@ export class McpHub {
13121306
}
13131307
this.disposables.forEach((d) => d.dispose())
13141308
}
1315-
1316-
/**
1317-
* Enables or disables all global MCP servers at once.
1318-
* When activated, the configuration is reloaded.
1319-
* @param disabled true = disable all, false = enable all
1320-
*/
1321-
public async toggleAllServersDisabled(disabled: boolean): Promise<void> {
1322-
// Collect all global server names
1323-
const globalConnections = this.connections.filter(
1324-
(conn) => conn.server.source === "global" || !conn.server.source,
1325-
)
1326-
const serverNames = globalConnections.map((conn) => conn.server.name)
1327-
1328-
// Set the Disabled flag for all servers
1329-
for (const name of serverNames) {
1330-
await this.updateServerConfig(name, { disabled }, "global")
1331-
const conn = this.findConnection(name, "global")
1332-
if (conn) {
1333-
conn.server.disabled = disabled
1334-
}
1335-
}
1336-
1337-
// If activated, reload configuration
1338-
if (!disabled) {
1339-
await this.initializeMcpServers("global")
1340-
}
1341-
1342-
await this.notifyWebviewOfServerChanges()
1343-
}
13441309
}

src/services/mcp/__tests__/McpHub.test.ts

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -560,77 +560,5 @@ describe("McpHub", () => {
560560
)
561561
})
562562
})
563-
describe("toggleServerDisabled (Configuration reload)", () => {
564-
it("should reload configuration when enabling a server (calls initializeMcpServers)", async () => {
565-
const mockConfig: any = {
566-
mcpServers: {
567-
"test-server": {
568-
type: "stdio",
569-
command: "node",
570-
args: ["test.js"],
571-
disabled: true,
572-
},
573-
},
574-
}
575-
576-
;(fs.readFile as jest.Mock).mockResolvedValueOnce(JSON.stringify(mockConfig))
577-
578-
mcpHub.connections = [
579-
{
580-
server: {
581-
name: "test-server",
582-
config: JSON.stringify(mockConfig.mcpServers["test-server"]),
583-
status: "connected",
584-
disabled: true,
585-
},
586-
client: { request: jest.fn() },
587-
transport: { close: jest.fn() },
588-
} as any,
589-
]
590-
591-
const spy = jest.spyOn(mcpHub as any, "initializeMcpServers").mockResolvedValue(undefined)
592-
593-
await mcpHub.toggleServerDisabled("test-server", false)
594-
// Expectation: initializeMcpServers was called
595-
expect(spy).toHaveBeenCalledWith("global")
596-
spy.mockRestore()
597-
})
598-
})
599-
describe("toggleAllServersDisabled (global enable/disable)", () => {
600-
it("should reload configuration when globally enabling all servers (calls initializeMcpServers)", async () => {
601-
// Two global servers, both disabled
602-
mcpHub.connections = [
603-
{
604-
server: {
605-
name: "server1",
606-
config: JSON.stringify({ type: "stdio", command: "node", args: ["a.js"], disabled: true }),
607-
status: "disconnected",
608-
disabled: true,
609-
source: "global",
610-
},
611-
client: { request: jest.fn() },
612-
transport: { close: jest.fn() },
613-
} as any,
614-
{
615-
server: {
616-
name: "server2",
617-
config: JSON.stringify({ type: "stdio", command: "node", args: ["b.js"], disabled: true }),
618-
status: "disconnected",
619-
disabled: true,
620-
source: "global",
621-
},
622-
client: { request: jest.fn() },
623-
transport: { close: jest.fn() },
624-
} as any,
625-
]
626-
627-
const spy = jest.spyOn(mcpHub as any, "initializeMcpServers").mockResolvedValue(undefined)
628-
629-
await mcpHub.toggleAllServersDisabled(false) // activate global
630-
631-
expect(spy).toHaveBeenCalledWith("global")
632-
spy.mockRestore()
633-
})
634-
})
635563
})
636564
})

0 commit comments

Comments
 (0)