Skip to content

Commit da4bb95

Browse files
committed
chore: warn on --nodb
1 parent 1068d03 commit da4bb95

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/common/config/createUserConfig.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export function createUserConfig({ args }: { args: string[] }): {
4646
// TODO: Separate correctly parsed user config from all other valid
4747
// arguments relevant to mongosh's args-parser.
4848
const userConfig: UserConfig = { ...parsed, ...configParseResult.data };
49-
warnings.push(...warnIfVectorSearchNotEnabledCorrectly(userConfig));
5049
registerKnownSecretsInRootKeychain(userConfig);
5150
return {
5251
parsed: userConfig,
@@ -101,11 +100,7 @@ function parseUserConfigSources(cliArguments: string[]): {
101100
}
102101

103102
const deprecationWarnings = [
104-
...(cliArguments.find((argument: string) => argument.startsWith("--connectionString"))
105-
? [
106-
"Warning: The --connectionString argument is deprecated. Prefer using the MDB_MCP_CONNECTION_STRING environment variable or the first positional argument for the connection string.",
107-
]
108-
: []),
103+
...getWarnings(parsed, cliArguments),
109104
...Object.entries(deprecated).map(([deprecated, replacement]) => {
110105
return `Warning: The --${deprecated} argument is deprecated. Use --${replacement} instead.`;
111106
}),
@@ -141,10 +136,23 @@ function registerKnownSecretsInRootKeychain(userConfig: Partial<UserConfig>): vo
141136
maybeRegister(userConfig.username, "user");
142137
}
143138

144-
function warnIfVectorSearchNotEnabledCorrectly(config: UserConfig): string[] {
145-
const searchEnabled = config.previewFeatures.includes("search");
146-
const embeddingsProviderConfigured = !!config.voyageApiKey;
139+
function getWarnings(config: Partial<UserConfig>, cliArguments: string[]): string[] {
147140
const warnings = [];
141+
142+
if (cliArguments.find((argument: string) => argument.startsWith("--connectionString"))) {
143+
warnings.push(
144+
"Warning: The --connectionString argument is deprecated. Prefer using the MDB_MCP_CONNECTION_STRING environment variable or the first positional argument for the connection string."
145+
);
146+
}
147+
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+
154+
const searchEnabled = config.previewFeatures?.includes("search");
155+
const embeddingsProviderConfigured = !!config.voyageApiKey;
148156
if (searchEnabled && !embeddingsProviderConfigured) {
149157
warnings.push(`\
150158
Warning: Vector search is enabled but no embeddings provider is configured.

tests/e2e/cli.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,29 @@ describe("CLI entrypoint", () => {
5050
"- Refer to https://www.mongodb.com/docs/mcp-server/get-started/ for setting up the MCP Server.";
5151

5252
describe("Deprecated CLI arguments", () => {
53-
const testCases = [
53+
const testCases: { readonly cliArg: string; readonly value?: string; readonly warning: string }[] = [
5454
{
5555
cliArg: "--connectionString",
5656
value: "mongodb://localhost:27017",
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+
},
6065
] as const;
6166

6267
for (const { cliArg, value, warning } of testCases) {
6368
describe(`deprecation behaviour of ${cliArg}`, () => {
6469
it(`warns the usage of ${cliArg} as it is deprecated`, async () => {
65-
const { stderr } = await runServer({ args: [cliArg, value] });
70+
const { stderr } = await runServer({ args: [cliArg, ...(value ? [value] : [])] });
6671
expect(stderr).toContain(warning);
6772
});
6873

6974
it(`shows the reference message when ${cliArg} was passed`, async () => {
70-
const { stderr } = await runServer({ args: [cliArg, value] });
75+
const { stderr } = await runServer({ args: [cliArg, ...(value ? [value] : [])] });
7176
expect(stderr).toContain(referDocMessage);
7277
});
7378
});

0 commit comments

Comments
 (0)