fix: pass --index flag through to MCP server#344
fix: pass --index flag through to MCP server#344fourcolors wants to merge 3 commits intotobi:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug (#343) where the --index CLI flag was silently ignored by the MCP server. Previously, both startMcpServer() and startMcpHttpServer() always called createStore() with no arguments, bypassing the storeDbPathOverride set when --index is parsed in qmd.ts.
Changes:
startMcpServer()andstartMcpHttpServer()insrc/mcp.tsnow accept an optionaldbPathparameter passed through tocreateStore()src/qmd.tspasses the resolvedstoreDbPathOverrideto both MCP entry points; daemon mode forwards--indexin spawned child process args- A new integration test in
test/mcp.test.tsverifies the HTTP server uses an explicitdbPath(withINDEX_PATHunset)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/mcp.ts |
Added optional dbPath parameter to both exported MCP server start functions |
src/qmd.ts |
Passes storeDbPathOverride to MCP functions; adds --index forwarding in daemon spawn args |
test/mcp.test.ts |
New describe block tests that startMcpHttpServer uses the provided dbPath instead of defaulting to INDEX_PATH |
CHANGELOG.md |
[Unreleased] entry documenting the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey! I was excited to try this fix since I'm hitting the same issue (#343). Cloned the branch and ran Haven't dug super deep into it though, so I might be missing something! Just wanted to flag it in case it helps. |
|
@danil09234 ah shoot Ill fix this up one moment. Thanks for the feedback! |
startMcpServer() and startMcpHttpServer() called createStore() with no arguments, ignoring the --index flag set via setIndexName() in the CLI. Both functions now accept an optional dbPath parameter, and the CLI passes the resolved path when dispatching to MCP. Daemon mode also forwards --index to the spawned child process. Fixes tobi#343
- Use consistent options bag for both startMcpServer() and startMcpHttpServer() instead of mixing positional and bag styles - Use getDbPath() instead of raw storeDbPathOverride for robustness - Move env snapshot into beforeAll to avoid stale module-load captures - Add local mcpReq helper instead of duplicating fetch boilerplate
indexName was a local variable inside parseCLI() but was referenced in the main CLI block. Use cli.values.index instead, which is the parsed value already available in scope. Fixes TS2552 build error.
6d48a9d to
7e14b1c
Compare
|
@danil09234 can you try again, this should be working now |
Summary
startMcpServer()andstartMcpHttpServer()now accept an optionaldbPathparameter instead of always callingcreateStore()with no argumentsstoreDbPathOverride(set by--index) when dispatching to MCP stdio and HTTP transports--daemon) forwards--indexto the spawned child process argsProblem
qmd --index myproject mcpsilently ignores the--indexflag. The MCP server always opens~/.cache/qmd/index.sqliteinstead of~/.cache/qmd/myproject.sqlite.Root cause:
src/mcp.tsimportscreateStoredirectly fromstore.tsand calls it with no arguments, bypassing thestoreDbPathOverridethatsetIndexName()sets inqmd.ts.Changes
src/mcp.tsdbPathparam tostartMcpServer()andstartMcpHttpServer()src/qmd.tsstoreDbPathOverrideto both MCP entry points; forward--indexin daemon spawn argstest/mcp.test.tsdbPath(noINDEX_PATHenv), verifies search worksCHANGELOG.md[Unreleased]Test plan
"server uses dbPath instead of default index.sqlite"— starts HTTP MCP server withdbPath, clearsINDEX_PATHenv, searches seeded dataqmd --index foo mcpopensfoo.sqlitevia stdioqmd --index foo mcp --httpopensfoo.sqlitevia HTTPqmd --index foo mcp --http --daemonspawns child with--index fooFixes #343