Skip to content

Commit 6436b35

Browse files
chore: should switch connection if a server is running
1 parent ce927f5 commit 6436b35

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/mcp/mcpController.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,26 +336,25 @@ ${jsonConfig}`,
336336
private async onActiveConnectionChanged(): Promise<void> {
337337
const autoStartConfig = this.getMCPAutoStartConfig();
338338

339+
const shouldSendMCPServerNotification =
340+
this.connectionController.getActiveConnectionId() !== null &&
341+
(autoStartConfig === 'Ask' ||
342+
autoStartConfig === null ||
343+
autoStartConfig === undefined);
344+
339345
logger.info('Active connection changed, should update MCP server', {
340346
'mdb.mcp.server': autoStartConfig,
341347
serverStarted: !!this.server,
348+
shouldSendMCPServerNotification,
342349
});
343350

344-
if (
345-
this.connectionController.getActiveConnectionId() &&
346-
(autoStartConfig === 'Ask' ||
347-
autoStartConfig === null ||
348-
autoStartConfig === undefined)
349-
) {
351+
if (shouldSendMCPServerNotification) {
350352
await this.requestAutoStartPermission();
351-
return;
352353
}
353354

354-
if (!this.server) {
355-
return;
355+
if (this.server) {
356+
await this.switchConnectionManagerToCurrentConnection();
356357
}
357-
358-
await this.switchConnectionManagerToCurrentConnection();
359358
}
360359

361360
private async switchConnectionManagerToCurrentConnection(): Promise<void> {

0 commit comments

Comments
 (0)