diff --git a/src/mcp/server.ts b/src/mcp/server.ts index 0cfb607..4fd0d77 100644 --- a/src/mcp/server.ts +++ b/src/mcp/server.ts @@ -32,8 +32,6 @@ import { import { getConfigPath } from "../collections.js"; import { enableProductionMode } from "../store.js"; -enableProductionMode(); - // ============================================================================= // Types for structured content // ============================================================================= @@ -541,6 +539,12 @@ Intent-aware lex (C++ performance, not sports): // ============================================================================= export async function startMcpServer(): Promise { + // Opt into production mode when the MCP server is actually started, not + // when this module is merely imported for its exports. Importing the module + // at the top level flipped the global production flag and broke test + // isolation for downstream suites that expect the default (development) + // database path behaviour. + enableProductionMode(); const configPath = getConfigPath(); const store = await createStore({ dbPath: getDefaultDbPath(), @@ -566,6 +570,10 @@ 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 { + // See startMcpServer() for the rationale — flip production mode here so the + // HTTP transport resolves the real database path, without leaking state into + // callers that only import this module for its exports (e.g. tests). + enableProductionMode(); const configPath = getConfigPath(); const store = await createStore({ dbPath: getDefaultDbPath(),