@@ -45,6 +45,7 @@ import {
4545 LIST_FILES_DESCRIPTION ,
4646 READ_FILE_DESCRIPTION ,
4747 withListIndexesReference ,
48+ withIndexList ,
4849} from "./tool-descriptions.js" ;
4950
5051/**
@@ -72,6 +73,13 @@ export interface MCPServerConfig {
7273 * @default "0.1.0"
7374 */
7475 version ?: string ;
76+ /**
77+ * Agent-managed mode flag.
78+ * When true: use withListIndexesReference (no enum in schemas)
79+ * When false/undefined: use withIndexList (include enum in schemas)
80+ * @default false
81+ */
82+ agentManaged ?: boolean ;
7583}
7684
7785/**
@@ -132,10 +140,23 @@ export async function createMCPServer(
132140 } ;
133141 } ;
134142
135- // Tool descriptions with reference to list_indexes
136- const searchDescription = withListIndexesReference ( SEARCH_DESCRIPTION ) ;
137- const listFilesDescription = withListIndexesReference ( LIST_FILES_DESCRIPTION ) ;
138- const readFileDescription = withListIndexesReference ( READ_FILE_DESCRIPTION ) ;
143+ // Tool descriptions: use enum in fixed mode, reference in agent-managed mode
144+ let searchDescription : string ;
145+ let listFilesDescription : string ;
146+ let readFileDescription : string ;
147+
148+ if ( config . agentManaged ) {
149+ // Agent-managed mode: use reference to list_indexes (no enum)
150+ searchDescription = withListIndexesReference ( SEARCH_DESCRIPTION ) ;
151+ listFilesDescription = withListIndexesReference ( LIST_FILES_DESCRIPTION ) ;
152+ readFileDescription = withListIndexesReference ( READ_FILE_DESCRIPTION ) ;
153+ } else {
154+ // Fixed mode: include enum with index list
155+ const indexListStr = runner . getIndexListString ( ) ;
156+ searchDescription = withIndexList ( SEARCH_DESCRIPTION , indexListStr ) ;
157+ listFilesDescription = withIndexList ( LIST_FILES_DESCRIPTION , indexListStr ) ;
158+ readFileDescription = withIndexList ( READ_FILE_DESCRIPTION , indexListStr ) ;
159+ }
139160
140161 // List available tools
141162 server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
@@ -158,6 +179,7 @@ export async function createMCPServer(
158179 index_name : {
159180 type : "string" ,
160181 description : "Name of the index to search." ,
182+ ...( config . agentManaged ? { } : { enum : runner . indexes . map ( i => i . name ) } ) ,
161183 } ,
162184 query : {
163185 type : "string" ,
@@ -250,6 +272,7 @@ export async function createMCPServer(
250272 index_name : {
251273 type : "string" ,
252274 description : "Name of the index." ,
275+ ...( config . agentManaged ? { } : { enum : runner . indexes . map ( i => i . name ) } ) ,
253276 } ,
254277 directory : {
255278 type : "string" ,
@@ -280,6 +303,7 @@ export async function createMCPServer(
280303 index_name : {
281304 type : "string" ,
282305 description : "Name of the index." ,
306+ ...( config . agentManaged ? { } : { enum : runner . indexes . map ( i => i . name ) } ) ,
283307 } ,
284308 path : {
285309 type : "string" ,
0 commit comments