Skip to content

Commit 9505342

Browse files
committed
Add config option for connection string
1 parent c8f9257 commit 9505342

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ const { localDataPath, configPath } = getLocalDataPath();
88

99
// If we decide to support non-string config options, we'll need to extend the mechanism for parsing
1010
// env variables.
11-
interface UserConfig extends Record<string, string> {
11+
interface UserConfig extends Record<string, string | undefined> {
1212
apiBaseUrl: string;
1313
clientId: string;
1414
stateFile: string;
15+
connectionString?: string;
1516
}
1617

1718
const defaults: UserConfig = {

src/tools/mongodb/connect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DbOperationType, MongoDBToolBase } from "./mongodbTool.js";
55
import { ToolArgs } from "../tool.js";
66
import { ErrorCodes, MongoDBError } from "../../errors.js";
77
import { saveState } from "../../state.js";
8+
import config from "../../config.js";
89

910
export class ConnectTool extends MongoDBToolBase {
1011
protected name = "connect";
@@ -21,7 +22,7 @@ export class ConnectTool extends MongoDBToolBase {
2122
protected async execute({
2223
connectionStringOrClusterName,
2324
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
24-
connectionStringOrClusterName ??= this.state.connectionString;
25+
connectionStringOrClusterName ??= config.connectionString || this.state.connectionString;
2526
if (!connectionStringOrClusterName) {
2627
return {
2728
content: [

0 commit comments

Comments
 (0)