Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ const { localDataPath, configPath } = getLocalDataPath();

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

const defaults: UserConfig = {
Expand Down
3 changes: 2 additions & 1 deletion src/tools/mongodb/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NodeDriverServiceProvider } from "@mongosh/service-provider-node-driver
import { DbOperationType, MongoDBToolBase } from "./mongodbTool.js";
import { ToolArgs } from "../tool.js";
import { ErrorCodes, MongoDBError } from "../../errors.js";
import config from "../../config.js";

export class ConnectTool extends MongoDBToolBase {
protected name = "connect";
Expand All @@ -20,7 +21,7 @@ export class ConnectTool extends MongoDBToolBase {
protected async execute({
connectionStringOrClusterName,
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
connectionStringOrClusterName ??= this.state.credentials.connectionString;
connectionStringOrClusterName ??= config.connectionString || this.state.credentials.connectionString;
if (!connectionStringOrClusterName) {
return {
content: [
Expand Down