Skip to content

MCP server crashes: missing enableProductionMode() call in mcp.js #411

@reggiechan74

Description

@reggiechan74

Bug

The MCP server (dist/mcp.js) fails to start with:

Error: Database path not set. Tests must set INDEX_PATH env var or use createStore() with explicit path.
This prevents tests from accidentally writing to the global index.

Root Cause

dist/store.js has a _productionMode flag (default false) that gates access to the default database path (~/.cache/qmd/index.sqlite). The CLI entrypoint (dist/qmd.js) calls enableProductionMode() at startup, but dist/mcp.js does not — so getDefaultDbPath() throws at line 334 instead of resolving the path.

Fix

One-line addition in mcp.js — import and call enableProductionMode() before createStore():

- import { createStore, extractSnippet, addLineNumbers, structuredSearch, DEFAULT_MULTI_GET_MAX_BYTES, } from "./store.js";
+ import { createStore, extractSnippet, addLineNumbers, structuredSearch, DEFAULT_MULTI_GET_MAX_BYTES, enableProductionMode, } from "./store.js";
+ enableProductionMode();

Environment

  • qmd v0.1.0 (installed via Claude Code plugin system)
  • Node.js on Linux (GitHub Codespace)
  • CLI works fine (qmd search resolves the path correctly)
  • MCP server crashes on every invocation

Workaround

Either:

  1. Apply the patch above to dist/mcp.js in the plugin cache
  2. Set INDEX_PATH=~/.cache/qmd/index.sqlite in the environment before the MCP server starts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions