@@ -2,6 +2,7 @@ import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
22import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
33import { ToolArgs , OperationType } from "../../tool.js" ;
44import { z } from "zod" ;
5+ import { ListSearchIndexOutput } from "../../../common/search/listSearchIndexesOutput.js" ;
56
67export const ListSearchIndexesArgs = {
78 indexName : z
@@ -12,10 +13,6 @@ export const ListSearchIndexesArgs = {
1213 "The name of the index to return information about. Returns all indexes on collection if not provided."
1314 ) ,
1415} ;
15- export interface SearchIndex {
16- name : string ;
17- latestDefinition : Record < string , unknown > ;
18- }
1916
2017export class CollectionSearchIndexesTool extends MongoDBToolBase {
2118 protected name = "collection-search-indexes" ;
@@ -33,12 +30,18 @@ export class CollectionSearchIndexesTool extends MongoDBToolBase {
3330 indexName,
3431 } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
3532 const provider = await this . ensureConnected ( ) ;
36-
37- const indexes : SearchIndex [ ] = (
38- ( await provider . getSearchIndexes ( database , collection , indexName ) ) as SearchIndex [ ]
33+ const indexes : ListSearchIndexOutput [ ] = (
34+ ( await provider . getSearchIndexes ( database , collection , indexName ) ) as ListSearchIndexOutput [ ]
3935 ) . map ( ( doc ) => ( {
36+ id : doc . id ,
4037 name : doc . name ,
38+ status : doc . status ,
39+ queryable : doc . queryable ,
40+ latestDefinitionVersion : doc . latestDefinitionVersion ,
4141 latestDefinition : doc . latestDefinition ,
42+ statusDetail : doc . statusDetail ,
43+ synonymMappingStatus : doc . synonymMappingStatus ,
44+ synonymMappingStatusDetail : doc . synonymMappingStatusDetail ,
4245 } ) ) ;
4346
4447 return {
@@ -51,7 +54,17 @@ export class CollectionSearchIndexesTool extends MongoDBToolBase {
5154 } ,
5255 ...( indexes . map ( ( indexDefinition ) => {
5356 return {
54- text : `\nName: "${ indexDefinition . name } "\nDefinition: ${ JSON . stringify ( indexDefinition . latestDefinition , null , 2 ) } \n` ,
57+ text : [
58+ `Name: "${ indexDefinition . name } "` ,
59+ `Definition: ${ JSON . stringify ( indexDefinition . latestDefinition , null , 2 ) } ` ,
60+ `Queryable: ${ indexDefinition . queryable } ` ,
61+ `Status: "${ indexDefinition . status } "` ,
62+ `Status Detail: ${ JSON . stringify ( indexDefinition . statusDetail , null , 2 ) } ` ,
63+ `Definition Version: ${ JSON . stringify ( indexDefinition . latestDefinitionVersion , null , 2 ) } ` ,
64+ `Synonym Mapping Status: ${ indexDefinition . synonymMappingStatus } ` ,
65+ `Synonym Mapping Status Detail: ${ JSON . stringify ( indexDefinition . synonymMappingStatusDetail , null , 2 ) } ` ,
66+ `ID: ${ indexDefinition . id } ` ,
67+ ] . join ( "\n" ) ,
5568 type : "text" ,
5669 } ;
5770 } ) as { text : string ; type : "text" } [ ] ) ,
0 commit comments