@@ -2,6 +2,7 @@ import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
2
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
3
3
import { ToolArgs , OperationType } from "../../tool.js" ;
4
4
import { z } from "zod" ;
5
+ import { ListSearchIndexOutput } from "../../../common/search/listSearchIndexesOutput.js" ;
5
6
6
7
export const ListSearchIndexesArgs = {
7
8
indexName : z
@@ -12,10 +13,6 @@ export const ListSearchIndexesArgs = {
12
13
"The name of the index to return information about. Returns all indexes on collection if not provided."
13
14
) ,
14
15
} ;
15
- export interface SearchIndex {
16
- name : string ;
17
- latestDefinition : Record < string , unknown > ;
18
- }
19
16
20
17
export class CollectionSearchIndexesTool extends MongoDBToolBase {
21
18
protected name = "collection-search-indexes" ;
@@ -33,12 +30,18 @@ export class CollectionSearchIndexesTool extends MongoDBToolBase {
33
30
indexName,
34
31
} : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
35
32
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 [ ]
39
35
) . map ( ( doc ) => ( {
36
+ id : doc . id ,
40
37
name : doc . name ,
38
+ status : doc . status ,
39
+ queryable : doc . queryable ,
40
+ latestDefinitionVersion : doc . latestDefinitionVersion ,
41
41
latestDefinition : doc . latestDefinition ,
42
+ statusDetail : doc . statusDetail ,
43
+ synonymMappingStatus : doc . synonymMappingStatus ,
44
+ synonymMappingStatusDetail : doc . synonymMappingStatusDetail ,
42
45
} ) ) ;
43
46
44
47
return {
@@ -51,7 +54,17 @@ export class CollectionSearchIndexesTool extends MongoDBToolBase {
51
54
} ,
52
55
...( indexes . map ( ( indexDefinition ) => {
53
56
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" ) ,
55
68
type : "text" ,
56
69
} ;
57
70
} ) as { text : string ; type : "text" } [ ] ) ,
0 commit comments