diff --git a/README.md b/README.md index d530141b6..225cdbea2 100644 --- a/README.md +++ b/README.md @@ -499,12 +499,12 @@ You can disable telemetry using: The MongoDB MCP Server may offer functionality that is still in development and may change in future releases. These features are considered "preview features" and are not enabled by default. Generally, these features are well tested, but may not offer the complete functionality we intend to provide in the final release or we'd like to gather feedback before making them generally available. To enable one or more preview features, use the `previewFeatures` configuration option. -- For **environment variable** configuration, use a comma-separated string: `export MDB_MCP_PREVIEW_FEATURES="vectorSearch,feature1,feature2"`. -- For **command-line argument** configuration, use a space-separated string: `--previewFeatures vectorSearch feature1 feature2`. +- For **environment variable** configuration, use a comma-separated string: `export MDB_MCP_PREVIEW_FEATURES="search,feature1,feature2"`. +- For **command-line argument** configuration, use a space-separated string: `--previewFeatures search feature1 feature2`. List of available preview features: -- `vectorSearch` - Enables tools or functionality related to Vector Search in MongoDB Atlas: +- `search` - Enables tools or functionality related to Atlas Search and Vector Search in MongoDB Atlas: - Index management, such as creating, listing, and dropping search and vector search indexes. - Querying collections using vector search capabilities. This requires a configured embedding model that will be used to generate vector representations of the query data. Currently, only [Voyage AI](https://www.voyageai.com) embedding models are supported. Set the `voyageApiKey` configuration option with your Voyage AI API key to use this feature. diff --git a/package.json b/package.json index ca9faad2d..95a637fbd 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "pretest:accuracy": "pnpm run build", "test:accuracy": "sh ./scripts/accuracy/runAccuracyTests.sh", "test:long-running-tests": "vitest --project long-running-tests --coverage", + "test:local": "SKIP_ATLAS_TESTS=true SKIP_ATLAS_LOCAL_TESTS=true pnpm run test", "atlas:cleanup": "vitest --project atlas-cleanup" }, "license": "Apache-2.0", diff --git a/src/common/config/createUserConfig.ts b/src/common/config/createUserConfig.ts index 335eeed66..cbf06fb2d 100644 --- a/src/common/config/createUserConfig.ts +++ b/src/common/config/createUserConfig.ts @@ -170,19 +170,19 @@ function registerKnownSecretsInRootKeychain(userConfig: Partial): vo } function warnIfVectorSearchNotEnabledCorrectly(config: UserConfig, warn: (message: string) => void): void { - const vectorSearchEnabled = config.previewFeatures.includes("vectorSearch"); + const searchEnabled = config.previewFeatures.includes("search"); const embeddingsProviderConfigured = !!config.voyageApiKey; - if (vectorSearchEnabled && !embeddingsProviderConfigured) { + if (searchEnabled && !embeddingsProviderConfigured) { warn(`\ Warning: Vector search is enabled but no embeddings provider is configured. - Set an embeddings provider configuration option to enable auto-embeddings during document insertion and text-based queries with $vectorSearch.\ `); } - if (!vectorSearchEnabled && embeddingsProviderConfigured) { + if (!searchEnabled && embeddingsProviderConfigured) { warn(`\ -Warning: An embeddings provider is configured but the 'vectorSearch' preview feature is not enabled. -- Enable vector search by adding 'vectorSearch' to the 'previewFeatures' configuration option, or remove the embeddings provider configuration if not needed.\ +Warning: An embeddings provider is configured but the 'search' preview feature is not enabled. +- Enable vector search by adding 'search' to the 'previewFeatures' configuration option, or remove the embeddings provider configuration if not needed.\ `); } } diff --git a/src/common/schemas.ts b/src/common/schemas.ts index 6375d25c6..678fdf786 100644 --- a/src/common/schemas.ts +++ b/src/common/schemas.ts @@ -1,4 +1,4 @@ -export const previewFeatureValues = ["vectorSearch"] as const; +export const previewFeatureValues = ["search"] as const; export type PreviewFeature = (typeof previewFeatureValues)[number]; export const similarityValues = ["cosine", "euclidean", "dotProduct"] as const; diff --git a/src/common/search/embeddingsProvider.ts b/src/common/search/embeddingsProvider.ts index 7a40f3588..ae287f9cd 100644 --- a/src/common/search/embeddingsProvider.ts +++ b/src/common/search/embeddingsProvider.ts @@ -41,7 +41,7 @@ class VoyageEmbeddingsProvider implements EmbeddingsProvider( diff --git a/src/tools/mongodb/create/createIndex.ts b/src/tools/mongodb/create/createIndex.ts index fcbc12ee7..d0aca2469 100644 --- a/src/tools/mongodb/create/createIndex.ts +++ b/src/tools/mongodb/create/createIndex.ts @@ -76,11 +76,11 @@ export class CreateIndexTool extends MongoDBToolBase { type: z.literal("classic"), keys: z.object({}).catchall(z.custom()).describe("The index definition"), }), - ...(this.isFeatureEnabled("vectorSearch") ? [this.vectorSearchIndexDefinition] : []), + ...(this.isFeatureEnabled("search") ? [this.vectorSearchIndexDefinition] : []), ]) ) .describe( - `The index definition. Use 'classic' for standard indexes${this.isFeatureEnabled("vectorSearch") ? " and 'vectorSearch' for vector search indexes" : ""}.` + `The index definition. Use 'classic' for standard indexes${this.isFeatureEnabled("search") ? " and 'vectorSearch' for vector search indexes" : ""}.` ), }; diff --git a/src/tools/mongodb/create/insertMany.ts b/src/tools/mongodb/create/insertMany.ts index fcde13164..61c24303e 100644 --- a/src/tools/mongodb/create/insertMany.ts +++ b/src/tools/mongodb/create/insertMany.ts @@ -25,7 +25,7 @@ export class InsertManyTool extends MongoDBToolBase { .describe( "The array of documents to insert, matching the syntax of the document argument of db.collection.insertMany()." ), - ...(this.isFeatureEnabled("vectorSearch") + ...(this.isFeatureEnabled("search") ? { embeddingParameters: zSupportedEmbeddingParametersWithInput .optional() @@ -45,7 +45,7 @@ export class InsertManyTool extends MongoDBToolBase { }: ToolArgs): Promise { const provider = await this.ensureConnected(); - const embeddingParameters = this.isFeatureEnabled("vectorSearch") + const embeddingParameters = this.isFeatureEnabled("search") ? (providedEmbeddingParameters as z.infer) : undefined; diff --git a/src/tools/mongodb/delete/dropIndex.ts b/src/tools/mongodb/delete/dropIndex.ts index a6f28d0db..7c62dd0b9 100644 --- a/src/tools/mongodb/delete/dropIndex.ts +++ b/src/tools/mongodb/delete/dropIndex.ts @@ -10,7 +10,7 @@ export class DropIndexTool extends MongoDBToolBase { protected argsShape = { ...DbOperationArgs, indexName: z.string().nonempty().describe("The name of the index to be dropped."), - type: this.isFeatureEnabled("vectorSearch") + type: this.isFeatureEnabled("search") ? z .enum(["classic", "search"]) .describe( diff --git a/src/tools/mongodb/metadata/collectionIndexes.ts b/src/tools/mongodb/metadata/collectionIndexes.ts index 19007c4f1..7f2df71ea 100644 --- a/src/tools/mongodb/metadata/collectionIndexes.ts +++ b/src/tools/mongodb/metadata/collectionIndexes.ts @@ -31,7 +31,7 @@ export class CollectionIndexesTool extends MongoDBToolBase { })); const searchIndexDefinitions: SearchIndexStatus[] = []; - if (this.isFeatureEnabled("vectorSearch") && (await this.session.isSearchSupported())) { + if (this.isFeatureEnabled("search") && (await this.session.isSearchSupported())) { const searchIndexes = await provider.getSearchIndexes(database, collection); searchIndexDefinitions.push(...this.extractSearchIndexDetails(searchIndexes)); } diff --git a/src/tools/mongodb/metadata/explain.ts b/src/tools/mongodb/metadata/explain.ts index a98d4f6e1..89cb5f356 100644 --- a/src/tools/mongodb/metadata/explain.ts +++ b/src/tools/mongodb/metadata/explain.ts @@ -20,7 +20,7 @@ export class ExplainTool extends MongoDBToolBase { z.discriminatedUnion("name", [ z.object({ name: z.literal("aggregate"), - arguments: z.object(getAggregateArgs(this.isFeatureEnabled("vectorSearch"))), + arguments: z.object(getAggregateArgs(this.isFeatureEnabled("search"))), }), z.object({ name: z.literal("find"), diff --git a/src/tools/mongodb/read/aggregate.ts b/src/tools/mongodb/read/aggregate.ts index c7bd439a8..ad4eb33a5 100644 --- a/src/tools/mongodb/read/aggregate.ts +++ b/src/tools/mongodb/read/aggregate.ts @@ -52,7 +52,7 @@ export class AggregateTool extends MongoDBToolBase { protected description = "Run an aggregation against a MongoDB collection"; protected argsShape = { ...DbOperationArgs, - ...getAggregateArgs(this.isFeatureEnabled("vectorSearch")), + ...getAggregateArgs(this.isFeatureEnabled("search")), }; public operationType: OperationType = "read"; diff --git a/src/tools/mongodb/read/export.ts b/src/tools/mongodb/read/export.ts index a12ed9fba..6f24aa889 100644 --- a/src/tools/mongodb/read/export.ts +++ b/src/tools/mongodb/read/export.ts @@ -33,7 +33,7 @@ export class ExportTool extends MongoDBToolBase { .literal("aggregate") .describe("The literal name 'aggregate' to represent an aggregation cursor as target."), arguments: z - .object(getAggregateArgs(this.isFeatureEnabled("vectorSearch"))) + .object(getAggregateArgs(this.isFeatureEnabled("search"))) .describe("The arguments for 'aggregate' operation."), }), ]) diff --git a/tests/accuracy/createIndex.test.ts b/tests/accuracy/createIndex.test.ts index 9a3a4f90c..410464c99 100644 --- a/tests/accuracy/createIndex.test.ts +++ b/tests/accuracy/createIndex.test.ts @@ -137,7 +137,7 @@ describeAccuracyTests( }, ], { - userConfig: { previewFeatures: "vectorSearch" }, + userConfig: { previewFeatures: "search" }, clusterConfig: { search: true, }, diff --git a/tests/accuracy/dropIndex.test.ts b/tests/accuracy/dropIndex.test.ts index 0c9b6803d..93cf4321a 100644 --- a/tests/accuracy/dropIndex.test.ts +++ b/tests/accuracy/dropIndex.test.ts @@ -127,7 +127,7 @@ describeAccuracyTests( ], { userConfig: { - previewFeatures: "vectorSearch", + previewFeatures: "search", }, clusterConfig: { search: true }, } diff --git a/tests/accuracy/insertMany.embeddings.test.ts b/tests/accuracy/insertMany.embeddings.test.ts index 6445b8458..1968c76a0 100644 --- a/tests/accuracy/insertMany.embeddings.test.ts +++ b/tests/accuracy/insertMany.embeddings.test.ts @@ -187,7 +187,7 @@ describeAccuracyTests( }, ], { - userConfig: { voyageApiKey: "valid-key", previewFeatures: "vectorSearch" }, + userConfig: { voyageApiKey: "valid-key", previewFeatures: "search" }, clusterConfig: { search: true, }, diff --git a/tests/integration/tools/mongodb/create/createIndex.test.ts b/tests/integration/tools/mongodb/create/createIndex.test.ts index ee344b7d5..463a2dbd3 100644 --- a/tests/integration/tools/mongodb/create/createIndex.test.ts +++ b/tests/integration/tools/mongodb/create/createIndex.test.ts @@ -30,7 +30,7 @@ describeWithMongoDB("createIndex tool when search is not enabled", (integration) ]); it("doesn't allow creating vector search indexes", async () => { - expect(integration.mcpServer().userConfig.previewFeatures).to.not.include("vectorSearch"); + expect(integration.mcpServer().userConfig.previewFeatures).to.not.include("search"); const { tools } = await integration.mcpClient().listTools(); const createIndexTool = tools.find((tool) => tool.name === "create-index"); @@ -54,7 +54,7 @@ describeWithMongoDB( "createIndex tool when search is enabled", (integration) => { it("allows creating vector search indexes", async () => { - expect(integration.mcpServer().userConfig.previewFeatures).includes("vectorSearch"); + expect(integration.mcpServer().userConfig.previewFeatures).includes("search"); const { tools } = await integration.mcpClient().listTools(); const createIndexTool = tools.find((tool) => tool.name === "create-index"); @@ -100,7 +100,7 @@ describeWithMongoDB( getUserConfig: () => { return { ...defaultTestConfig, - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], }; }, } @@ -408,7 +408,7 @@ describeWithMongoDB( getUserConfig: () => { return { ...defaultTestConfig, - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], }; }, } @@ -629,7 +629,7 @@ describeWithMongoDB( { getUserConfig: () => ({ ...defaultTestConfig, - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], }), downloadOptions: { search: true, diff --git a/tests/integration/tools/mongodb/create/insertMany.test.ts b/tests/integration/tools/mongodb/create/insertMany.test.ts index 95fd6cbb1..dda4ae71b 100644 --- a/tests/integration/tools/mongodb/create/insertMany.test.ts +++ b/tests/integration/tools/mongodb/create/insertMany.test.ts @@ -635,7 +635,7 @@ describeWithMongoDB( // This is expected to be set through the CI env. When not set we // get a warning in the run logs. voyageApiKey: process.env.TEST_MDB_MCP_VOYAGE_API_KEY ?? "", - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], }), downloadOptions: { search: true }, } @@ -674,7 +674,7 @@ describeWithMongoDB( // This is expected to be set through the CI env. When not set we // get a warning in the run logs. voyageApiKey: process.env.TEST_MDB_MCP_VOYAGE_API_KEY ?? "", - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], }), } ); diff --git a/tests/integration/tools/mongodb/delete/dropIndex.test.ts b/tests/integration/tools/mongodb/delete/dropIndex.test.ts index 0b9369938..032a07690 100644 --- a/tests/integration/tools/mongodb/delete/dropIndex.test.ts +++ b/tests/integration/tools/mongodb/delete/dropIndex.test.ts @@ -158,7 +158,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])( { getUserConfig: () => ({ ...defaultTestConfig, - previewFeatures: vectorSearchEnabled ? ["vectorSearch"] : [], + previewFeatures: vectorSearchEnabled ? ["search"] : [], }), } ); @@ -244,7 +244,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])( { getUserConfig: () => ({ ...defaultTestConfig, - previewFeatures: vectorSearchEnabled ? ["vectorSearch"] : [], + previewFeatures: vectorSearchEnabled ? ["search"] : [], }), } ); @@ -311,7 +311,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])( { getUserConfig: () => ({ ...defaultTestConfig, - previewFeatures: vectorSearchEnabled ? ["vectorSearch"] : [], + previewFeatures: vectorSearchEnabled ? ["search"] : [], }), getMockElicitationInput: () => mockElicitInput, } @@ -335,7 +335,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])( }); }, { - getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["vectorSearch"] }), + getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["search"] }), } ); @@ -409,7 +409,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])( }); }, { - getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["vectorSearch"] }), + getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["search"] }), downloadOptions: { search: true }, } ); @@ -485,7 +485,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])( }); }, { - getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["vectorSearch"] }), + getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["search"] }), downloadOptions: { search: true }, getMockElicitationInput: () => mockElicitInput, } diff --git a/tests/integration/tools/mongodb/metadata/collectionIndexes.test.ts b/tests/integration/tools/mongodb/metadata/collectionIndexes.test.ts index 8170b71d0..333ff0feb 100644 --- a/tests/integration/tools/mongodb/metadata/collectionIndexes.test.ts +++ b/tests/integration/tools/mongodb/metadata/collectionIndexes.test.ts @@ -316,7 +316,7 @@ describeWithMongoDB( { getUserConfig: () => ({ ...defaultTestConfig, - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], }), downloadOptions: { search: true }, } diff --git a/tests/integration/tools/mongodb/read/aggregate.test.ts b/tests/integration/tools/mongodb/read/aggregate.test.ts index a18654fb2..ff45433d1 100644 --- a/tests/integration/tools/mongodb/read/aggregate.test.ts +++ b/tests/integration/tools/mongodb/read/aggregate.test.ts @@ -926,7 +926,7 @@ If the user requests additional filtering, include filters in \`$vectorSearch.fi getUserConfig: () => ({ ...defaultTestConfig, voyageApiKey: process.env.TEST_MDB_MCP_VOYAGE_API_KEY ?? "", - previewFeatures: ["vectorSearch"], + previewFeatures: ["search"], maxDocumentsPerQuery: -1, maxBytesPerQuery: -1, indexCheck: true, diff --git a/tests/unit/common/config.test.ts b/tests/unit/common/config.test.ts index 372445c79..2fc10beaa 100644 --- a/tests/unit/common/config.test.ts +++ b/tests/unit/common/config.test.ts @@ -874,7 +874,7 @@ describe("Warning and Error messages", () => { describe("vector search misconfiguration", () => { it("should warn if vectorSearch is enabled but embeddings provider is not configured", () => { createUserConfig({ - cliArguments: ["--previewFeatures", "vectorSearch"], + cliArguments: ["--previewFeatures", "search"], onWarning: warn, onError: error, closeProcess: exit, @@ -894,14 +894,14 @@ Warning: Vector search is enabled but no embeddings provider is configured. }); expect(warn).toBeCalledWith(`\ -Warning: An embeddings provider is configured but the 'vectorSearch' preview feature is not enabled. -- Enable vector search by adding 'vectorSearch' to the 'previewFeatures' configuration option, or remove the embeddings provider configuration if not needed.\ +Warning: An embeddings provider is configured but the 'search' preview feature is not enabled. +- Enable vector search by adding 'search' to the 'previewFeatures' configuration option, or remove the embeddings provider configuration if not needed.\ `); }); it("should not warn if vectorSearch is enabled correctly", () => { createUserConfig({ - cliArguments: ["--voyageApiKey", "1FOO", "--previewFeatures", "vectorSearch"], + cliArguments: ["--voyageApiKey", "1FOO", "--previewFeatures", "search"], onWarning: warn, onError: error, closeProcess: exit, diff --git a/tests/unit/toolBase.test.ts b/tests/unit/toolBase.test.ts index b88bebae6..002b04266 100644 --- a/tests/unit/toolBase.test.ts +++ b/tests/unit/toolBase.test.ts @@ -121,13 +121,13 @@ describe("ToolBase", () => { describe("isFeatureEnabled", () => { it("should return false for any feature by default", () => { - expect(testTool["isFeatureEnabled"]("vectorSearch")).to.equal(false); + expect(testTool["isFeatureEnabled"]("search")).to.equal(false); expect(testTool["isFeatureEnabled"]("someOtherFeature" as PreviewFeature)).to.equal(false); }); it("should return true for enabled features", () => { - mockConfig.previewFeatures = ["vectorSearch", "someOtherFeature" as PreviewFeature]; - expect(testTool["isFeatureEnabled"]("vectorSearch")).to.equal(true); + mockConfig.previewFeatures = ["search", "someOtherFeature" as PreviewFeature]; + expect(testTool["isFeatureEnabled"]("search")).to.equal(true); expect(testTool["isFeatureEnabled"]("someOtherFeature" as PreviewFeature)).to.equal(true); expect(testTool["isFeatureEnabled"]("anotherFeature" as PreviewFeature)).to.equal(false);