Skip to content

Commit 741147a

Browse files
committed
Merge remote-tracking branch 'origin/search-skunkworks-2025' into skunkworks/create-add-vector-search
2 parents fe66ee7 + fa62241 commit 741147a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2+
import { SearchIndexOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
3+
import { ToolArgs, OperationType } from "../../tool.js";
4+
5+
export class DropSearchIndexTool extends MongoDBToolBase {
6+
protected name = "drop-search-index";
7+
protected description = "Deletes a text or vector search index from the database.";
8+
protected argsShape = {
9+
...SearchIndexOperationArgs,
10+
};
11+
protected operationType: OperationType = "delete";
12+
13+
protected async execute({
14+
database,
15+
collection,
16+
searchIndexName,
17+
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
18+
const provider = await this.ensureConnected();
19+
await provider.dropSearchIndex(database, collection, searchIndexName);
20+
return {
21+
content: [
22+
{
23+
text: `Successfully dropped index ${searchIndexName} from database ${database}`,
24+
type: "text",
25+
},
26+
],
27+
};
28+
}
29+
}

src/tools/mongodb/mongodbTool.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ export function buildVectorFields(vectorDefinition: VectorDefinitionType, filter
6868
return [typedVectorField, ...typedFilterFields];
6969
}
7070

71+
export const SearchIndexOperationArgs = {
72+
database: z.string().describe("Database name"),
73+
collection: z.string().describe("Collection name"),
74+
searchIndexName: z.string().describe("Search Index or Vector Search Index name"),
75+
};
76+
7177
export abstract class MongoDBToolBase extends ToolBase {
7278
protected category: ToolCategory = "mongodb";
7379

src/tools/mongodb/tools.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { LogsTool } from "./metadata/logs.js";
2121
import { CreateVectorIndexTool } from "./create/createVectorIndex.js";
2222
import { UpdateVectorIndexTool } from "./update/updateVectorIndex.js";
2323
import { CollectionSearchIndexesTool } from "./read/collectionSearchIndexes.js";
24+
import { DropSearchIndexTool } from "./delete/dropSearchIndex.js";
2425

2526
export const MongoDbTools = [
2627
ConnectTool,
@@ -46,4 +47,5 @@ export const MongoDbTools = [
4647
LogsTool,
4748
CreateVectorIndexTool,
4849
UpdateVectorIndexTool,
50+
DropSearchIndexTool,
4951
];

0 commit comments

Comments
 (0)