Skip to content

feat(mcp): expose plain query parameter for auto-expand search#432

Open
fxstein wants to merge 1 commit intotobi:mainfrom
fxstein:feat/mcp-expand-query
Open

feat(mcp): expose plain query parameter for auto-expand search#432
fxstein wants to merge 1 commit intotobi:mainfrom
fxstein:feat/mcp-expand-query

Conversation

@fxstein
Copy link

@fxstein fxstein commented Mar 18, 2026

Problem

The SDK search() method accepts either query (plain string → auto-expanded by the trained model) or queries (pre-expanded typed sub-queries). The CLI qmd query "text" uses the query path, triggering the full pipeline: expansion → parallel BM25 + vector → RRF → reranking.

However, the MCP query tool only exposes the queries path via the searches parameter. There is no way to send a plain text query through MCP and get the full auto-expand pipeline.

The tool description Strategy table even says: "Unknown vocabulary | Use a standalone natural-language query (no typed lines) so the server can auto-expand it" — but the tool schema doesn't accept a standalone query.

Fix

Add an optional query string parameter to the MCP query tool. When provided, route to store.search({ query }) which calls hybridQuery() with auto-expansion. query and searches are mutually exclusive — providing both returns an error.

The searches parameter is made optional (was required). Validation ensures at least one of query or searches is provided.

Tool description Strategy table updated to recommend query as the default approach.

Testing

Built and tested locally against a 7,791 document index:

Query type Latency Results Notes
query: "how does authentication work" (cold) 961ms 5 Expansion model loading
query: "how does authentication work" (warm) 259ms 5 Cached — 3.7× faster
query: "DEC-0054 sub-agent spawn protocol" 273ms 5 93% top hit ✅
searches: [{type: "lex", query: "\"DEC-0054\""}] 197ms 5 Existing path, unchanged
searches: [{type: "vec", query: "..."}] 622ms 5 Existing path, unchanged

Existing searches parameter works identically to before — no breaking changes.

Environment

  • QMD: v2.0.1
  • Platform: macOS (Apple Silicon)
  • Node: v24.2.0

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.

1 participant