Skip to content

Commit a5438af

Browse files
committed
chore: throw on nodb
1 parent e3dcf83 commit a5438af

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

scripts/generateArguments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { readFileSync, writeFileSync } from "fs";
1212
import { join, dirname } from "path";
1313
import { fileURLToPath } from "url";
14-
import { UserConfigSchemaWithCliOptions, configRegistry } from "../src/common/config/userConfig.js";
14+
import { UserConfigSchema, configRegistry } from "../src/common/config/userConfig.js";
1515
import { execSync } from "child_process";
1616
import type { z as z4 } from "zod/v4";
1717

@@ -108,7 +108,7 @@ function extractZodDescriptions(): Record<string, ConfigMetadata> {
108108
const result: Record<string, ConfigMetadata> = {};
109109

110110
// Get the shape of the Zod schema
111-
const shape = UserConfigSchemaWithCliOptions.shape;
111+
const shape = UserConfigSchema.shape;
112112

113113
for (const [key, fieldSchema] of Object.entries(shape)) {
114114
const schema = fieldSchema;

src/common/config/createUserConfig.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export function createUserConfig({ args }: { args: string[] }): {
2222
return { error: parseError, warnings, parsed: undefined };
2323
}
2424

25+
if (parsed.nodb) {
26+
return {
27+
error: "Error: The --nodb argument is not supported in the MCP Server. Please remove it from your configuration.",
28+
warnings,
29+
parsed: undefined,
30+
};
31+
}
32+
2533
// If we have a connectionSpecifier, which can only appear as the positional
2634
// argument, then that has to be used on priority to construct the
2735
// connection string. In this case, if there is a connection string provided
@@ -145,12 +153,6 @@ function getWarnings(config: Partial<UserConfig>, cliArguments: string[]): strin
145153
);
146154
}
147155

148-
if (config.nodb) {
149-
warnings.push(
150-
"Warning: The nodb option is deprecated and will be removed in a future version. Please remove it from your configuration."
151-
);
152-
}
153-
154156
const searchEnabled = config.previewFeatures?.includes("search");
155157
const embeddingsProviderConfigured = !!config.voyageApiKey;
156158
if (searchEnabled && !embeddingsProviderConfigured) {

src/common/config/userConfig.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import {
1010
parseBoolean,
1111
} from "./configUtils.js";
1212
import { previewFeatureValues, similarityValues } from "../schemas.js";
13-
import { CliOptionsSchema } from "@mongosh/arg-parser/arg-parser";
13+
import { CliOptionsSchema as MongoshCliOptionsSchema } from "@mongosh/arg-parser/arg-parser";
1414

1515
export const configRegistry = z4.registry<ConfigFieldMeta>();
1616

17-
export const UserConfigSchema = z4.object({
17+
const ServerConfigSchema = z4.object({
1818
apiBaseUrl: z4
1919
.string()
2020
.default("https://cloud.mongodb.com/")
@@ -218,13 +218,11 @@ export const UserConfigSchema = z4.object({
218218
.register(configRegistry, { overrideBehavior: "not-allowed" }),
219219
});
220220

221-
export const UserConfigSchemaWithCliOptions = z4.object({
222-
...CliOptionsSchema.shape,
223-
...UserConfigSchema.shape,
221+
export const UserConfigSchema = z4.object({
222+
...MongoshCliOptionsSchema.shape,
223+
...ServerConfigSchema.shape,
224224
});
225225

226-
export type UserConfig = z4.infer<typeof UserConfigSchemaWithCliOptions>;
226+
export type UserConfig = z4.infer<typeof UserConfigSchema>;
227227

228-
export const ALL_CONFIG_KEYS: (keyof UserConfig)[] = Object.keys(
229-
UserConfigSchemaWithCliOptions.shape
230-
) as (keyof UserConfig)[];
228+
export const ALL_CONFIG_KEYS: (keyof UserConfig)[] = Object.keys(UserConfigSchema.shape) as (keyof UserConfig)[];

tests/e2e/cli.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ describe("CLI entrypoint", () => {
5757
warning:
5858
"Warning: The --connectionString argument is deprecated. Prefer using the MDB_MCP_CONNECTION_STRING environment variable or the first positional argument for the connection string.",
5959
},
60-
{
61-
cliArg: "--nodb",
62-
warning:
63-
"Warning: The nodb option is deprecated and will be removed in a future version. Please remove it from your configuration.",
64-
},
6560
] as const;
6661

6762
for (const { cliArg, value, warning } of testCases) {
@@ -86,6 +81,11 @@ describe("CLI entrypoint", () => {
8681
args: ["--wakanda", "forever"],
8782
expectedError: "Error: Invalid command line argument '--wakanda'.",
8883
},
84+
{
85+
description: "should show an error when nodb is used",
86+
args: ["--nodb"],
87+
expectedError: "Error: Invalid command line argument '--nodb'.",
88+
},
8989
{
9090
description: "should show a suggestion when is a simple typo",
9191
args: ["--readonli", ""],

0 commit comments

Comments
 (0)