Skip to content

Commit 69609b4

Browse files
committed
lint
1 parent 565ca2b commit 69609b4

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/helpers/connectionOptions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ export async function setAppNameParamIfMissing({
4848
* @returns void
4949
* @throws Error if the connection string is invalid
5050
*/
51-
export async function validateConnectionString(connectionString: string, looseValidation: boolean): Promise<void> {
51+
export function validateConnectionString(connectionString: string, looseValidation: boolean): void {
5252
try {
5353
new ConnectionString(connectionString, { looseValidation });
5454
} catch (error) {
55-
throw new Error(`Invalid connection string with error: ${error}`);
55+
throw new Error(
56+
`Invalid connection string with error: ${error instanceof Error ? error.message : String(error)}`
57+
);
5658
}
5759
}

src/server.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Telemetry } from "./telemetry/telemetry.js";
99
import { UserConfig } from "./common/config.js";
1010
import { type ServerEvent } from "./telemetry/types.js";
1111
import { type ServerCommand } from "./telemetry/types.js";
12-
import ConnectionString from "mongodb-connection-string-url";
1312
import {
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

Comments
 (0)