From efc36498cba339e1dcc7efaba4465b52cceee8a6 Mon Sep 17 00:00:00 2001 From: Taylor Wilsdon Date: Mon, 2 Jun 2025 07:28:02 -0400 Subject: [PATCH 1/3] only apply transport.start for stdio --- src/services/mcp/McpHub.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 68f4f6aba2..d2bf4d399f 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -598,13 +598,23 @@ export class McpHub { } await this.notifyWebviewOfServerChanges() } + + transport.onclose = async () => { + const connection = this.findConnection(name, source) + if (connection) { + connection.server.status = "disconnected" + } + await this.notifyWebviewOfServerChanges() + } } else { - // Correctly placed "unsupported type" else block // Should not happen if validateServerConfig is correct throw new Error(`Unsupported MCP server type: ${(configInjected as any).type}`) } - // transport.start assignment moved after all type-specific initializations - transport.start = async () => {} // No-op now, .connect() won't fail + + // Only override transport.start for stdio transports that have already been started + if (configInjected.type === "stdio") { + transport.start = async () => {} + } const connection: McpConnection = { server: { @@ -625,7 +635,6 @@ export class McpHub { await client.connect(transport) connection.server.status = "connected" connection.server.error = "" - connection.server.instructions = client.getInstructions() // Initial fetch of tools and resources connection.server.tools = await this.fetchToolsList(name, source) From 8dd4442f2ee760494d2e35c9304200c679b071f6 Mon Sep 17 00:00:00 2001 From: Taylor Wilsdon Date: Mon, 2 Jun 2025 07:34:53 -0400 Subject: [PATCH 2/3] instructions --- src/services/mcp/McpHub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index d2bf4d399f..341a0e74cc 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -635,7 +635,7 @@ export class McpHub { await client.connect(transport) connection.server.status = "connected" connection.server.error = "" - + connection.server.instructions = client.getInstructions() // Initial fetch of tools and resources connection.server.tools = await this.fetchToolsList(name, source) connection.server.resources = await this.fetchResourcesList(name, source) From 6ab30b2420be9caf76284638cc41a8d5e3559c83 Mon Sep 17 00:00:00 2001 From: Taylor Wilsdon Date: Mon, 2 Jun 2025 07:35:30 -0400 Subject: [PATCH 3/3] formatting --- src/services/mcp/McpHub.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 341a0e74cc..cae2bf3c85 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -636,6 +636,7 @@ export class McpHub { connection.server.status = "connected" connection.server.error = "" connection.server.instructions = client.getInstructions() + // Initial fetch of tools and resources connection.server.tools = await this.fetchToolsList(name, source) connection.server.resources = await this.fetchResourcesList(name, source)