File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ export const DbOperationArgs = {
10
10
collection : z . string ( ) . describe ( "Collection name" ) ,
11
11
} ;
12
12
13
+ export const SearchIndexOperationArgs = {
14
+ database : z . string ( ) . describe ( "Database name" ) ,
15
+ collection : z . string ( ) . describe ( "Collection name" ) ,
16
+ searchIndexName : z . string ( ) . describe ( "Search Index or Vector Search Index name" ) ,
17
+ } ;
18
+
13
19
export abstract class MongoDBToolBase extends ToolBase {
14
20
protected category : ToolCategory = "mongodb" ;
15
21
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { ExplainTool } from "./metadata/explain.js";
19
19
import { CreateCollectionTool } from "./create/createCollection.js" ;
20
20
import { LogsTool } from "./metadata/logs.js" ;
21
21
import { CollectionSearchIndexesTool } from "./read/collectionSearchIndexes.js" ;
22
+ import { DropSearchIndexTool } from "./delete/dropSearchIndex.js" ;
22
23
23
24
export const MongoDbTools = [
24
25
ConnectTool ,
@@ -42,4 +43,5 @@ export const MongoDbTools = [
42
43
ExplainTool ,
43
44
CreateCollectionTool ,
44
45
LogsTool ,
46
+ DropSearchIndexTool ,
45
47
] ;
You can’t perform that action at this time.
0 commit comments