Skip to content

fix(mcp): support Windows HOME and enable production mode#334

Open
JasonOA888 wants to merge 1 commit intotobi:mainfrom
JasonOA888:fix/mcp-windows-home
Open

fix(mcp): support Windows HOME and enable production mode#334
JasonOA888 wants to merge 1 commit intotobi:mainfrom
JasonOA888:fix/mcp-windows-home

Conversation

@JasonOA888
Copy link

Problem

MCP server returns 0 documents on Windows even though CLI works correctly.

Root Cause

Two bugs:

  1. store.ts:46 - HOME fallback only checks process.env.HOME, which is undefined on Windows (uses USERPROFILE). This causes database path to resolve to /tmp/.cache/qmd/index.sqlite instead of the correct Windows path.

  2. mcp.ts - startMcpServer() and startMcpHttpServer() do not call enableProductionMode() before createStore(), causing the production database path to not be properly initialized.

Solution

  1. Change HOME fallback to: process.env.HOME || process.env.USERPROFILE || "/tmp"
  2. Add enableProductionMode() call in both MCP server functions before createStore()

Testing

  • Verified the fix maintains backward compatibility on Unix systems
  • Windows users should now see MCP server use the same database as CLI

Fixes #277

Two bugs prevented MCP server from finding the database on Windows:

1. store.ts: HOME fallback only checked process.env.HOME, which is
   undefined on Windows (uses USERPROFILE instead). Added fallback:
   process.env.HOME || process.env.USERPROFILE || "/tmp"

2. mcp.ts: startMcpServer() and startMcpHttpServer() did not call
   enableProductionMode() before createStore(), causing database
   path to resolve incorrectly.

Fixes tobi#277
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.

MCP server returns 0 documents on Windows (HOME env var not supported)

1 participant