Skip to content

fix(mcp): call enableProductionMode before getDefaultDbPath#537

Merged
tobi merged 1 commit into
tobi:mainfrom
fenrire:fix/mcp-production-mode
Apr 9, 2026
Merged

fix(mcp): call enableProductionMode before getDefaultDbPath#537
tobi merged 1 commit into
tobi:mainfrom
fenrire:fix/mcp-production-mode

Conversation

@fenrire

@fenrire fenrire commented Apr 8, 2026

Copy link
Copy Markdown

Summary

  • Bug: The MCP server (src/mcp/server.ts) calls getDefaultDbPath() without first calling enableProductionMode(), so it cannot locate the global index at ~/.cache/qmd/index.sqlite. This results in empty search results when using QMD via MCP.
  • Root cause: The CLI entry point (src/cli/qmd.ts) correctly calls enableProductionMode() at line 105, but src/mcp/server.ts was missed.
  • Fix: Import enableProductionMode from ../store.js and call it at module level (after imports) in src/mcp/server.ts.

Test plan

  • Run QMD MCP server and verify it finds the global index at ~/.cache/qmd/index.sqlite
  • Confirm search results are returned correctly via MCP tools
  • Verify CLI behavior is unchanged

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tobi tobi merged commit 33bdf9a into tobi:main Apr 9, 2026
idanariav referenced this pull request in idanariav/qmd Apr 24, 2026
The top-level enableProductionMode() call added in #537 fixed a real issue
(MCP server resolving the wrong database path at startup) but introduced
test-isolation breakage as a side effect: merely importing src/mcp/server.ts
flipped the global _productionMode flag, which then broke unrelated tests
that depend on the default (development) database path resolution.

This shows up concretely as "Store Creation > createStore throws without
explicit path in test mode" failing on Bun (ubuntu-latest) in CI, because
test/mcp.test.ts imports startMcpHttpServer from this module.

Move the enableProductionMode() call from module scope into the two server
entry points (startMcpServer and startMcpHttpServer). The fix originally
intended by #537 — ensuring production mode is active before getDefaultDbPath
runs — is preserved because both call sites still flip the flag before
createStore / getDefaultDbPath. Importing the module for its exports no longer
mutates global state.

Verified locally against current main: CI failure on Bun (ubuntu-latest)
reproduces on unmodified upstream main (14+ consecutive failed runs since
#537 merged on 2026-04-09) and is resolved by this change.

Refs: #537
lucndm pushed a commit to lucndm/qmd that referenced this pull request Jun 7, 2026
lucndm pushed a commit to lucndm/qmd that referenced this pull request Jun 7, 2026
The top-level enableProductionMode() call added in tobi#537 fixed a real issue
(MCP server resolving the wrong database path at startup) but introduced
test-isolation breakage as a side effect: merely importing src/mcp/server.ts
flipped the global _productionMode flag, which then broke unrelated tests
that depend on the default (development) database path resolution.

This shows up concretely as "Store Creation > createStore throws without
explicit path in test mode" failing on Bun (ubuntu-latest) in CI, because
test/mcp.test.ts imports startMcpHttpServer from this module.

Move the enableProductionMode() call from module scope into the two server
entry points (startMcpServer and startMcpHttpServer). The fix originally
intended by tobi#537 — ensuring production mode is active before getDefaultDbPath
runs — is preserved because both call sites still flip the flag before
createStore / getDefaultDbPath. Importing the module for its exports no longer
mutates global state.

Verified locally against current main: CI failure on Bun (ubuntu-latest)
reproduces on unmodified upstream main (14+ consecutive failed runs since
tobi#537 merged on 2026-04-09) and is resolved by this change.

Refs: tobi#537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants