Skip to content

Commit efc3649

Browse files
committed
only apply transport.start for stdio
1 parent c673569 commit efc3649

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/services/mcp/McpHub.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,23 @@ export class McpHub {
598598
}
599599
await this.notifyWebviewOfServerChanges()
600600
}
601+
602+
transport.onclose = async () => {
603+
const connection = this.findConnection(name, source)
604+
if (connection) {
605+
connection.server.status = "disconnected"
606+
}
607+
await this.notifyWebviewOfServerChanges()
608+
}
601609
} else {
602-
// Correctly placed "unsupported type" else block
603610
// Should not happen if validateServerConfig is correct
604611
throw new Error(`Unsupported MCP server type: ${(configInjected as any).type}`)
605612
}
606-
// transport.start assignment moved after all type-specific initializations
607-
transport.start = async () => {} // No-op now, .connect() won't fail
613+
614+
// Only override transport.start for stdio transports that have already been started
615+
if (configInjected.type === "stdio") {
616+
transport.start = async () => {}
617+
}
608618

609619
const connection: McpConnection = {
610620
server: {
@@ -625,7 +635,6 @@ export class McpHub {
625635
await client.connect(transport)
626636
connection.server.status = "connected"
627637
connection.server.error = ""
628-
connection.server.instructions = client.getInstructions()
629638

630639
// Initial fetch of tools and resources
631640
connection.server.tools = await this.fetchToolsList(name, source)

0 commit comments

Comments
 (0)