1+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
12import { DbOperationArgs , MongoDBToolBase , SearchIndexArgs } from "../mongodbTool.js" ;
3+ import { OperationType , ToolArgs } from "../../tool.js" ;
24
35export class CreateSearchIndexTool extends MongoDBToolBase {
4- constructor ( ) {
5- super ( ...arguments ) ;
6- this . name = "create-search-index" ;
7- this . description = "Create an Atlas Search index for a collection" ;
8- this . argsShape = {
9- ...DbOperationArgs ,
10- name : SearchIndexArgs . name ,
11- type : SearchIndexArgs . type ,
12- analyzer : SearchIndexArgs . analyzer ,
13- mappings : SearchIndexArgs . mappings ,
14- } ;
15- this . operationType = "create" ;
16- }
17- async execute ( { database, collection, name, type, analyzer, mappings, } ) {
6+ protected name = "create-search-index" ;
7+ protected description = "Create an Atlas Search index for a collection" ;
8+ protected argsShape = {
9+ ...DbOperationArgs ,
10+ name : SearchIndexArgs . name ,
11+ type : SearchIndexArgs . type ,
12+ analyzer : SearchIndexArgs . analyzer ,
13+ mappings : SearchIndexArgs . mappings ,
14+ } ;
15+
16+ protected operationType : OperationType = "create" ;
17+
18+ protected async execute ( {
19+ database,
20+ collection,
21+ name,
22+ type,
23+ analyzer,
24+ mappings,
25+ } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
1826 const provider = await this . ensureConnected ( ) ;
1927 const indexes = await provider . createSearchIndexes ( database , collection , [
2028 {
@@ -26,6 +34,7 @@ export class CreateSearchIndexTool extends MongoDBToolBase {
2634 } ,
2735 } ,
2836 ] ) ;
37+
2938 return {
3039 content : [
3140 {
@@ -35,4 +44,4 @@ export class CreateSearchIndexTool extends MongoDBToolBase {
3544 ] ,
3645 } ;
3746 }
38- }
47+ }
0 commit comments