diff --git a/src/mcp/server.ts b/src/mcp/server.ts index 9f9f5a4..8f29f9c 100644 --- a/src/mcp/server.ts +++ b/src/mcp/server.ts @@ -18,6 +18,7 @@ import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js"; import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js"; import { z } from "zod"; +import { existsSync } from "fs"; import { createStore, extractSnippet, @@ -28,6 +29,7 @@ import { type ExpandedQuery, type IndexStatus, } from "../index.js"; +import { getConfigPath } from "../collections.js"; // ============================================================================= // Types for structured content @@ -536,7 +538,11 @@ Intent-aware lex (C++ performance, not sports): // ============================================================================= export async function startMcpServer(): Promise { - const store = await createStore({ dbPath: getDefaultDbPath() }); + const configPath = getConfigPath(); + const store = await createStore({ + dbPath: getDefaultDbPath(), + ...(existsSync(configPath) ? { configPath } : {}), + }); const server = await createMcpServer(store); const transport = new StdioServerTransport(); await server.connect(transport); @@ -557,7 +563,11 @@ export type HttpServerHandle = { * Binds to localhost only. Returns a handle for shutdown and port discovery. */ export async function startMcpHttpServer(port: number, options?: { quiet?: boolean }): Promise { - const store = await createStore({ dbPath: getDefaultDbPath() }); + const configPath = getConfigPath(); + const store = await createStore({ + dbPath: getDefaultDbPath(), + ...(existsSync(configPath) ? { configPath } : {}), + }); // Pre-fetch default collection names for REST endpoint const defaultCollectionNames = await store.getDefaultCollectionNames();