Skip to content

Commit 35f06b1

Browse files
committed
Allow MCP server to start with zero indexes
Remove the empty-index check from the CLI so the MCP server can start even when no indexes exist. This enables the dynamic indexing workflow where users can call list_indexes (empty) then index_repo to create indexes on-demand.
1 parent 2ea4cdf commit 35f06b1

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/bin/cmd-mcp.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const stdioCommand = new Command("stdio")
2121
const indexSpecs: string[] | undefined = options.index;
2222

2323
let store;
24-
let indexNames: string[];
24+
let indexNames: string[] | undefined;
2525

2626
if (indexSpecs && indexSpecs.length > 0) {
2727
// Parse index specs and create composite store
@@ -31,13 +31,9 @@ const stdioCommand = new Command("stdio")
3131
} else {
3232
// No --index: use default store, list all indexes
3333
store = new FilesystemStore();
34-
indexNames = await store.list();
35-
if (indexNames.length === 0) {
36-
console.error("Error: No indexes found.");
37-
console.error("The MCP server requires at least one index to operate.");
38-
console.error("Run 'ctxc index --help' to see how to create an index.");
39-
process.exit(1);
40-
}
34+
// Dynamic indexing: server can start with zero indexes
35+
// Use list_indexes to see available indexes, index_repo to create new ones
36+
indexNames = undefined;
4137
}
4238

4339
// Start MCP server (writes to stdout, reads from stdin)
@@ -84,13 +80,8 @@ const httpCommand = new Command("http")
8480
} else {
8581
// No --index: use default store, serve all
8682
store = new FilesystemStore();
87-
const availableIndexes = await store.list();
88-
if (availableIndexes.length === 0) {
89-
console.error("Error: No indexes found.");
90-
console.error("The MCP server requires at least one index to operate.");
91-
console.error("Run 'ctxc index --help' to see how to create an index.");
92-
process.exit(1);
93-
}
83+
// Dynamic indexing: server can start with zero indexes
84+
// Use list_indexes to see available indexes, index_repo to create new ones
9485
indexNames = undefined;
9586
}
9687

0 commit comments

Comments
 (0)