8000 Add config option for connection string (#53) · mongodb-js/mongodb-mcp-server@38a0f1e · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38a0f1e

Browse files
authored
Add config option for connection string (#53)
1 parent b1fbd3f commit 38a0f1e

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
@@ -4,6 +4,7 @@ import { NodeDriverServiceProvider } from "@mongosh/service-provider-node-driver
44
import { DbOperationType, MongoDBToolBase } from "./mongodbTool.js";
55
import { ToolArgs } from "../tool.js";
66
import { ErrorCodes, MongoDBError } from "../../errors.js";
7+
import config from "../../config.js";
78

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

0 commit comments

Comments
 (0)
0