Skip to content

Commit 198b36e

Browse files
chore: add additional tests for metadata validation
1 parent 454e816 commit 198b36e

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/tools/mongodb/create/createIndex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class CreateIndexTool extends MongoDBToolBase {
8080
])
8181
)
8282
.describe(
83-
"The index definition. Use 'classic' for standard indexes and 'vectorSearch' for vector search indexes"
83+
`The index definition. Use 'classic' for standard indexes${this.isFeatureEnabled("vectorSearch") ? " and 'vectorSearch' for vector search indexes" : ""}.`
8484
),
8585
};
8686

tests/integration/tools/mongodb/create/createIndex.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ import { ObjectId, type Collection, type Document, type IndexDirection } from "m
1313
import { afterEach, beforeEach, describe, expect, it } from "vitest";
1414

1515
describeWithMongoDB("createIndex tool when search is not enabled", (integration) => {
16+
validateToolMetadata(integration, "create-index", "Create an index for a collection", [
17+
...databaseCollectionParameters,
18+
{
19+
name: "definition",
20+
type: "array",
21+
description: "The index definition. Use 'classic' for standard indexes.",
22+
required: true,
23+
},
24+
{
25+
name: "name",
26+
type: "string",
27+
description: "The name of the index",
28+
required: false,
29+
},
30+
]);
31+
1632
it("doesn't allow creating vector search indexes", async () => {
1733
expect(integration.mcpServer().userConfig.previewFeatures).to.not.include("vectorSearch");
1834

@@ -99,7 +115,7 @@ describeWithMongoDB(
99115
name: "definition",
100116
type: "array",
101117
description:
102-
"The index definition. Use 'classic' for standard indexes and 'vectorSearch' for vector search indexes",
118+
"The index definition. Use 'classic' for standard indexes and 'vectorSearch' for vector search indexes.",
103119
required: true,
104120
},
105121
{

tests/integration/tools/mongodb/create/insertMany.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ describeWithMongoDB(
124124
await collection.drop();
125125
});
126126

127+
validateToolMetadata(integration, "insert-many", "Insert an array of documents into a MongoDB collection", [
128+
...databaseCollectionParameters,
129+
{
130+
name: "documents",
131+
type: "array",
132+
description:
133+
"The array of documents to insert, matching the syntax of the document argument of db.collection.insertMany().",
134+
required: true,
135+
},
136+
{
137+
name: "embeddingParameters",
138+
type: "object",
139+
description:
140+
"The embedding model and its parameters to use to generate embeddings for fields with vector search indexes. Note to LLM: If unsure which embedding model to use, ask the user before providing one.",
141+
required: false,
142+
},
143+
]);
144+
127145
it("inserts a document when the embedding is correct", async () => {
128146
await createVectorSearchIndexAndWait(integration.mongoClient(), database, "test", [
129147
{

0 commit comments

Comments
 (0)