Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -5,6 +5,7 @@ import { DbOperationType, MongoDBToolBase } from "./mongodbTool.js";
import { ToolArgs } from "../tool.js";
import { ErrorCodes, MongoDBError } from "../../errors.js";
import { saveState } from "../../state.js";
import config from "../../config.js";

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