From 6423fc301c17ff6913fa4f07bbb8f77202ee56e6 Mon Sep 17 00:00:00 2001 From: Taylor Wilsdon Date: Mon, 2 Jun 2025 07:41:36 -0400 Subject: [PATCH] fix: SSE MCP Invocation (#4251) * only apply transport.start for stdio * instructions * formatting --- src/services/mcp/McpHub.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 68f4f6aba2..cae2bf3c85 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: {