File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import { z } from "zod" ;
2+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
3+ import { DbOperationArgs , MongoDBToolBase } from "../mongodbTool.js" ;
4+ import { ToolArgs , OperationType } from "../../tool.js" ;
5+
6+ export class DropSearchIndexTool extends MongoDBToolBase {
7+ protected name = "drop-search-index" ;
8+ protected description =
9+ "Deletes a text or vector search index from the database." ;
10+ protected argsShape = {
11+ ...DbOperationArgs ,
12+ indexName : z . string ( ) . describe ( "The name of the search or vector index to delete" ) ,
13+ } ;
14+ protected operationType : OperationType = "delete" ;
15+
16+ protected async execute ( { database, collection, indexName } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
17+ const provider = await this . ensureConnected ( ) ;
18+ const result = await provider . dropSearchIndex ( database , collection , indexName ) ;
19+
20+ return {
21+ content : [
22+ {
23+ text : `"Successfully dropped index "${ indexName } " from database "${ database } "` ,
24+ type : "text" ,
25+ } ,
26+ ] ,
27+ } ;
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { DropCollectionTool } from "./delete/dropCollection.js";
1818import { ExplainTool } from "./metadata/explain.js" ;
1919import { CreateCollectionTool } from "./create/createCollection.js" ;
2020import { LogsTool } from "./metadata/logs.js" ;
21+ import { DropSearchIndexTool } from "./delete/dropSearchIndex.js" ;
2122
2223export const MongoDbTools = [
2324 ConnectTool ,
@@ -40,4 +41,5 @@ export const MongoDbTools = [
4041 ExplainTool ,
4142 CreateCollectionTool ,
4243 LogsTool ,
44+ DropSearchIndexTool ,
4345] ;
You can’t perform that action at this time.
0 commit comments