@@ -9,7 +9,6 @@ import { Telemetry } from "./telemetry/telemetry.js";
99import { UserConfig } from "./common/config.js" ;
1010import { type ServerEvent } from "./telemetry/types.js" ;
1111import { type ServerCommand } from "./telemetry/types.js" ;
12- import ConnectionString from "mongodb-connection-string-url" ;
1312import {
1413 CallToolRequestSchema ,
1514 CallToolResult ,
@@ -100,6 +99,8 @@ export class Server {
10099
101100 this . mcpServer . server . oninitialized = ( ) : void => {
102101 this . session . setMcpClient ( this . mcpServer . server . getClientVersion ( ) ) ;
102+ // Placed here to start the connection to the config connection string as soon as the server is initialized.
103+ void this . connectToConfigConnectionString ( ) ;
103104
104105 this . session . logger . info ( {
105106 id : LogId . serverInitialized ,
@@ -108,9 +109,6 @@ export class Server {
108109 } ) ;
109110
110111 this . emitServerEvent ( "start" , Date . now ( ) - this . startTime ) ;
111-
112- // Placed here to start the connection to the config connection string as soon as the server is initialized.
113- this . connectToConfigConnectionString ( ) ;
114112 } ;
115113
116114 this . mcpServer . server . onclose = ( ) : void => {
@@ -196,10 +194,13 @@ export class Server {
196194 // Validate connection string
197195 if ( this . userConfig . connectionString ) {
198196 try {
199- await validateConnectionString ( this . userConfig . connectionString , false ) ;
197+ validateConnectionString ( this . userConfig . connectionString , false ) ;
200198 } catch ( error ) {
201199 console . error ( "Connection string validation failed with error: " , error ) ;
202- throw new Error ( "Connection string validation failed with error: " + error ) ;
200+ throw new Error (
201+ "Connection string validation failed with error: " +
202+ ( error instanceof Error ? error . message : String ( error ) )
203+ ) ;
203204 }
204205 }
205206
0 commit comments