@@ -2,13 +2,14 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
22import { DbOperationArgs , MongoDBToolBase , SearchIndexArgs } from "../mongodbTool.js" ;
33import { OperationType , ToolArgs } from "../../tool.js" ;
44
5+ const SEARCH_INDEX_TYPE = "search" ;
6+
57export class CreateSearchIndexTool extends MongoDBToolBase {
68 protected name = "create-search-index" ;
79 protected description = "Create an Atlas Search index for a collection" ;
810 protected argsShape = {
911 ...DbOperationArgs ,
1012 name : SearchIndexArgs . name ,
11- type : SearchIndexArgs . type ,
1213 analyzer : SearchIndexArgs . analyzer ,
1314 mappings : SearchIndexArgs . mappings ,
1415 } ;
@@ -19,15 +20,14 @@ export class CreateSearchIndexTool extends MongoDBToolBase {
1920 database,
2021 collection,
2122 name,
22- type,
2323 analyzer,
2424 mappings,
2525 } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
2626 const provider = await this . ensureConnected ( ) ;
2727 const indexes = await provider . createSearchIndexes ( database , collection , [
2828 {
2929 name,
30- type,
30+ type : SEARCH_INDEX_TYPE ,
3131 definition : {
3232 analyzer,
3333 mappings,
@@ -38,7 +38,7 @@ export class CreateSearchIndexTool extends MongoDBToolBase {
3838 return {
3939 content : [
4040 {
41- text : `Created the index "${ indexes [ 0 ] } " on collection "${ collection } " in database "${ database } "` ,
41+ text : `Created the search index "${ indexes [ 0 ] } " on collection "${ collection } " in database "${ database } "` ,
4242 type : "text" ,
4343 } ,
4444 ] ,
0 commit comments