fix(mcp): call enableProductionMode before getDefaultDbPath#537
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 23, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/mcp/server.ts) callsgetDefaultDbPath()without first callingenableProductionMode(), so it cannot locate the global index at~/.cache/qmd/index.sqlite. This results in empty search results when using QMD via MCP.src/cli/qmd.ts) correctly callsenableProductionMode()at line 105, butsrc/mcp/server.tswas missed.enableProductionModefrom../store.jsand call it at module level (after imports) insrc/mcp/server.ts.Test plan
~/.cache/qmd/index.sqlite🤖 Generated with Claude Code