@@ -42,10 +42,17 @@ const stdioCommand = new Command("stdio")
4242 store = await CompositeStoreReader . fromSpecs ( specs ) ;
4343 discovery = false ;
4444 } else {
45- // Discovery mode only: use FilesystemStore
45+ // No flags: restore original behavior - fail fast if no indexes
4646 store = new FilesystemStore ( ) ;
47- indexNames = undefined ;
48- discovery = true ;
47+ const availableIndexes = await store . list ( ) ;
48+ if ( availableIndexes . length === 0 ) {
49+ console . error ( "Error: No indexes found." ) ;
50+ console . error ( "The MCP server requires at least one index to operate." ) ;
51+ console . error ( "Run 'ctxc index --help' to see how to create an index." ) ;
52+ process . exit ( 1 ) ;
53+ }
54+ indexNames = availableIndexes ;
55+ discovery = false ;
4956 }
5057
5158 // Start MCP server (writes to stdout, reads from stdin)
@@ -103,10 +110,17 @@ const httpCommand = new Command("http")
103110 store = await CompositeStoreReader . fromSpecs ( specs ) ;
104111 discovery = false ;
105112 } else {
106- // Discovery mode only: use FilesystemStore
113+ // No flags: restore original behavior - fail fast if no indexes
107114 store = new FilesystemStore ( ) ;
108- indexNames = undefined ;
109- discovery = true ;
115+ const availableIndexes = await store . list ( ) ;
116+ if ( availableIndexes . length === 0 ) {
117+ console . error ( "Error: No indexes found." ) ;
118+ console . error ( "The MCP server requires at least one index to operate." ) ;
119+ console . error ( "Run 'ctxc index --help' to see how to create an index." ) ;
120+ process . exit ( 1 ) ;
121+ }
122+ indexNames = availableIndexes ;
123+ discovery = false ;
110124 }
111125
112126 // Parse CORS option
0 commit comments