Skip to content

Commit 73e57bd

Browse files
committed
chore: use a dictionary of flags with urls instead
1 parent f7dd0e7 commit 73e57bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/common/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const OPTIONS = {
8787
"greedy-arrays": true,
8888
"short-option-groups": false,
8989
},
90-
};
90+
} as const;
9191

9292
function isConnectionSpecifier(arg: string | undefined): boolean {
9393
return (
@@ -185,14 +185,15 @@ function getExportsPath(): string {
185185
// are prefixed with `MDB_MCP_` and the keys match the UserConfig keys, but are converted
186186
// to SNAKE_UPPER_CASE.
187187
function parseEnvConfig(env: Record<string, unknown>): Partial<UserConfig> {
188+
const CONFIG_WITH_URLS: Set<string> = new Set<(typeof OPTIONS)["string"][number]>(["connectionString"]);
189+
188190
function setValue(obj: Record<string, unknown>, path: string[], value: string): void {
189191
const currentField = path.shift();
190192
if (!currentField) {
191193
return;
192194
}
193195
if (path.length === 0) {
194-
// MongoDB URLs must not be preprocessed
195-
if (typeof value === "string" && (value.startsWith("mongodb://") || value.startsWith("mongodb+srv://"))) {
196+
if (CONFIG_WITH_URLS.has(currentField)) {
196197
obj[currentField] = value;
197198
return;
198199
}

0 commit comments

Comments
 (0)