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 = {
1010 collection : z . string ( ) . describe ( "Collection name" ) ,
1111} ;
1212
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+
1319export abstract class MongoDBToolBase extends ToolBase {
1420 protected category : ToolCategory = "mongodb" ;
1521
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { ExplainTool } from "./metadata/explain.js";
1919import { CreateCollectionTool } from "./create/createCollection.js" ;
2020import { LogsTool } from "./metadata/logs.js" ;
2121import { CollectionSearchIndexesTool } from "./read/collectionSearchIndexes.js" ;
22+ import { DropSearchIndexTool } from "./delete/dropSearchIndex.js" ;
2223
2324export const MongoDbTools = [
2425 ConnectTool ,
@@ -42,4 +43,5 @@ export const MongoDbTools = [
4243 ExplainTool ,
4344 CreateCollectionTool ,
4445 LogsTool ,
46+ DropSearchIndexTool ,
4547] ;
You can’t perform that action at this time.
0 commit comments