Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/common/config/createUserConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,19 @@ function registerKnownSecretsInRootKeychain(userConfig: Partial<UserConfig>): 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.\
`);
}
}
2 changes: 1 addition & 1 deletion src/common/schemas.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/common/search/embeddingsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VoyageEmbeddingsProvider implements EmbeddingsProvider<VoyageModels, Voyag
}

static isConfiguredIn({ voyageApiKey, previewFeatures }: UserConfig): boolean {
return previewFeatures.includes("vectorSearch") && !!voyageApiKey;
return previewFeatures.includes("search") && !!voyageApiKey;
}

async embed<Model extends VoyageModels>(
Expand Down
4 changes: 2 additions & 2 deletions src/tools/mongodb/create/createIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export class CreateIndexTool extends MongoDBToolBase {
type: z.literal("classic"),
keys: z.object({}).catchall(z.custom<IndexDirection>()).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" : ""}.`
),
};

Expand Down
4 changes: 2 additions & 2 deletions src/tools/mongodb/create/insertMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -45,7 +45,7 @@ export class InsertManyTool extends MongoDBToolBase {
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
const provider = await this.ensureConnected();

const embeddingParameters = this.isFeatureEnabled("vectorSearch")
const embeddingParameters = this.isFeatureEnabled("search")
? (providedEmbeddingParameters as z.infer<typeof zSupportedEmbeddingParametersWithInput>)
: undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/delete/dropIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/metadata/collectionIndexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/metadata/explain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/read/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/tools/mongodb/read/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
}),
])
Expand Down
2 changes: 1 addition & 1 deletion tests/accuracy/createIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describeAccuracyTests(
},
],
{
userConfig: { previewFeatures: "vectorSearch" },
userConfig: { previewFeatures: "search" },
clusterConfig: {
search: true,
},
Expand Down
2 changes: 1 addition & 1 deletion tests/accuracy/dropIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describeAccuracyTests(
],
{
userConfig: {
previewFeatures: "vectorSearch",
previewFeatures: "search",
},
clusterConfig: { search: true },
}
Expand Down
2 changes: 1 addition & 1 deletion tests/accuracy/insertMany.embeddings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describeAccuracyTests(
},
],
{
userConfig: { voyageApiKey: "valid-key", previewFeatures: "vectorSearch" },
userConfig: { voyageApiKey: "valid-key", previewFeatures: "search" },
clusterConfig: {
search: true,
},
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/tools/mongodb/create/createIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -100,7 +100,7 @@ describeWithMongoDB(
getUserConfig: () => {
return {
...defaultTestConfig,
previewFeatures: ["vectorSearch"],
previewFeatures: ["search"],
};
},
}
Expand Down Expand Up @@ -408,7 +408,7 @@ describeWithMongoDB(
getUserConfig: () => {
return {
...defaultTestConfig,
previewFeatures: ["vectorSearch"],
previewFeatures: ["search"],
};
},
}
Expand Down Expand Up @@ -629,7 +629,7 @@ describeWithMongoDB(
{
getUserConfig: () => ({
...defaultTestConfig,
previewFeatures: ["vectorSearch"],
previewFeatures: ["search"],
}),
downloadOptions: {
search: true,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/tools/mongodb/create/insertMany.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
}
Expand Down Expand Up @@ -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"],
}),
}
);
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/tools/mongodb/delete/dropIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])(
{
getUserConfig: () => ({
...defaultTestConfig,
previewFeatures: vectorSearchEnabled ? ["vectorSearch"] : [],
previewFeatures: vectorSearchEnabled ? ["search"] : [],
}),
}
);
Expand Down Expand Up @@ -244,7 +244,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])(
{
getUserConfig: () => ({
...defaultTestConfig,
previewFeatures: vectorSearchEnabled ? ["vectorSearch"] : [],
previewFeatures: vectorSearchEnabled ? ["search"] : [],
}),
}
);
Expand Down Expand Up @@ -311,7 +311,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])(
{
getUserConfig: () => ({
...defaultTestConfig,
previewFeatures: vectorSearchEnabled ? ["vectorSearch"] : [],
previewFeatures: vectorSearchEnabled ? ["search"] : [],
}),
getMockElicitationInput: () => mockElicitInput,
}
Expand All @@ -335,7 +335,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])(
});
},
{
getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["vectorSearch"] }),
getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["search"] }),
}
);

Expand Down Expand Up @@ -409,7 +409,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])(
});
},
{
getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["vectorSearch"] }),
getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["search"] }),
downloadOptions: { search: true },
}
);
Expand Down Expand Up @@ -485,7 +485,7 @@ describe.each([{ vectorSearchEnabled: false }, { vectorSearchEnabled: true }])(
});
},
{
getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["vectorSearch"] }),
getUserConfig: () => ({ ...defaultTestConfig, previewFeatures: ["search"] }),
downloadOptions: { search: true },
getMockElicitationInput: () => mockElicitInput,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describeWithMongoDB(
{
getUserConfig: () => ({
...defaultTestConfig,
previewFeatures: ["vectorSearch"],
previewFeatures: ["search"],
}),
downloadOptions: { search: true },
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tools/mongodb/read/aggregate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/common/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/toolBase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down