From 0f3deffb1c681d14ea72666c7146f13202955d8a Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Mon, 1 Sep 2025 20:50:10 +0100 Subject: [PATCH 1/3] add more details on startup message --- src/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index ded91618..06cc566d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -20,6 +20,7 @@ import { import assert from "assert"; import type { ToolBase } from "./tools/tool.js"; import { validateConnectionString } from "./helpers/connectionOptions.js"; +import { packageInfo } from "./common/packageInfo.js"; export interface ServerOptions { session: Session; @@ -123,7 +124,7 @@ export class Server { this.session.logger.info({ id: LogId.serverInitialized, context: "server", - message: `Server started with transport ${transport.constructor.name} and agent runner ${this.session.mcpClient?.name}`, + message: `Server with version ${packageInfo.version} started with transport ${transport.constructor.name} and agent runner ${JSON.stringify(this.session.mcpClient)}`, }); this.emitServerEvent("start", Date.now() - this.startTime); From 4e0eef5ba2d40e79fa1944b0ae4d424e13dda068 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Tue, 2 Sep 2025 12:23:40 +0100 Subject: [PATCH 2/3] fix: start mcp even if connection fails --- src/server.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/server.ts b/src/server.ts index 06cc566d..bf8cd061 100644 --- a/src/server.ts +++ b/src/server.ts @@ -120,7 +120,6 @@ export class Server { this.session.setMcpClient(this.mcpServer.server.getClientVersion()); // Placed here to start the connection to the config connection string as soon as the server is initialized. void this.connectToConfigConnectionString(); - this.session.logger.info({ id: LogId.serverInitialized, context: "server", @@ -245,15 +244,21 @@ export class Server { private async connectToConfigConnectionString(): Promise { if (this.userConfig.connectionString) { try { + this.session.logger.info({ + id: LogId.serverInitialized, + context: "server", + message: `Detected a MongoDB connection string in the configuration, trying to connect...`, + }); await this.session.connectToMongoDB({ connectionString: this.userConfig.connectionString, }); } catch (error) { - console.error( - "Failed to connect to MongoDB instance using the connection string from the config: ", - error - ); - throw new Error("Failed to connect to MongoDB instance using the connection string from the config"); + // We don't throw an error here because we want to allow the server to start even if the connection string is invalid. + this.session.logger.error({ + id: LogId.mongodbConnectFailure, + context: "server", + message: `Failed to connect to MongoDB instance using the connection string from the config: ${error as string}`, + }); } } } From 369ed330e884299745695799c032f6a2f14889c8 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Tue, 2 Sep 2025 12:55:37 +0100 Subject: [PATCH 3/3] address copilot comment --- src/common/logger.ts | 1 + src/server.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/logger.ts b/src/common/logger.ts index 2535b402..03b94f31 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -41,6 +41,7 @@ export const LogId = { mongodbConnectFailure: mongoLogId(1_004_001), mongodbDisconnectFailure: mongoLogId(1_004_002), + mongodbConnectTry: mongoLogId(1_004_003), toolUpdateFailure: mongoLogId(1_005_001), resourceUpdateFailure: mongoLogId(1_005_002), diff --git a/src/server.ts b/src/server.ts index bf8cd061..76399e98 100644 --- a/src/server.ts +++ b/src/server.ts @@ -245,7 +245,7 @@ export class Server { if (this.userConfig.connectionString) { try { this.session.logger.info({ - id: LogId.serverInitialized, + id: LogId.mongodbConnectTry, context: "server", message: `Detected a MongoDB connection string in the configuration, trying to connect...`, }); @@ -257,7 +257,7 @@ export class Server { this.session.logger.error({ id: LogId.mongodbConnectFailure, context: "server", - message: `Failed to connect to MongoDB instance using the connection string from the config: ${error as string}`, + message: `Failed to connect to MongoDB instance using the connection string from the config: ${error instanceof Error ? error.message : String(error)}`, }); } }