@@ -12,6 +12,10 @@ export const ListSearchIndexesArgs = {
1212 "The name of the index to return information about. Returns all indexes on collection if not provided."
1313 ) ,
1414} ;
15+ export interface SearchIndex {
16+ name : string ;
17+ latestDefinition : Record < string , unknown > ;
18+ }
1519
1620export class CollectionSearchIndexesTool extends MongoDBToolBase {
1721 protected name = "collection-search-indexes" ;
@@ -29,7 +33,13 @@ export class CollectionSearchIndexesTool extends MongoDBToolBase {
2933 indexName,
3034 } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
3135 const provider = await this . ensureConnected ( ) ;
32- const indexes = await provider . getSearchIndexes ( database , collection , indexName ) ;
36+
37+ const indexes : SearchIndex [ ] = ( await provider . getSearchIndexes ( database , collection , indexName ) ) . map (
38+ ( doc ) => ( {
39+ name : doc . name ,
40+ latestDefinition : doc . latestDefinition ,
41+ } )
42+ ) ;
3343
3444 return {
3545 content : [
@@ -41,7 +51,7 @@ export class CollectionSearchIndexesTool extends MongoDBToolBase {
4151 } ,
4252 ...( indexes . map ( ( indexDefinition ) => {
4353 return {
44- text : `Name "${ indexDefinition . name } ", definition : ${ JSON . stringify ( indexDefinition . latestDefinition ) } ` ,
54+ text : `\nName: "${ indexDefinition . name } "\nDefinition : ${ JSON . stringify ( indexDefinition . latestDefinition , null , 2 ) } \n ` ,
4555 type : "text" ,
4656 } ;
4757 } ) as { text : string ; type : "text" } [ ] ) ,
0 commit comments