Skip to content

feat: expose candidateLimit as MCP tool parameter and CLI flag#255

Open
pandysp wants to merge 1 commit intotobi:mainfrom
pandysp:feat/expose-candidate-limit
Open

feat: expose candidateLimit as MCP tool parameter and CLI flag#255
pandysp wants to merge 1 commit intotobi:mainfrom
pandysp:feat/expose-candidate-limit

Conversation

@pandysp
Copy link

@pandysp pandysp commented Feb 24, 2026

Summary

  • Add optional candidateLimit param to MCP query tool, REST /query endpoint, and CLI (--candidate-limit / -C)
  • Default stays 40 (no behavior change) — users can lower for speed tradeoff on CPU-only machines
  • Reranking is the bottleneck (~2 min for 40 chunks on 8 vCPU); lowering candidate count cuts it proportionally

Closes #254. Complements #231.

Changes (2 files, +13/-1)

src/mcp.ts

  • Add candidateLimit to query tool inputSchema (zod z.number().optional())
  • Pass through to structuredSearch() in both MCP handler and REST /query endpoint

src/qmd.ts

  • Add --candidate-limit / -C to parseCLI() options
  • Add candidateLimit to OutputOptions type
  • Pass through to both structuredSearch() and hybridQuery() in querySearch()
  • Add to --help output

Test plan

  • npm run build compiles without errors
  • npm test — 539/545 pass (6 failures are pre-existing LLM-dependent timeouts)
  • Manual: qmd query --candidate-limit 10 "test query" on indexed data
  • Manual: MCP tool call with candidateLimit: 10 via adapter

🤖 Generated with Claude Code

Reranking 40 chunks takes ~2 min on CPU (the default candidateLimit).
The option already exists in hybridQuery()/structuredSearch() but was
never surfaced to users. This adds:

- `candidateLimit` param to the MCP `query` tool inputSchema
- `candidateLimit` field to the REST /query endpoint
- `--candidate-limit` / `-C` CLI flag for `qmd query`

Default stays 40 (no behavior change). Users on CPU-only machines can
lower it for a speed/recall tradeoff. Complements tobi#231.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pandysp pandysp force-pushed the feat/expose-candidate-limit branch from 863849a to 87bd968 Compare February 26, 2026 12:31
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.

feat: expose candidateLimit as MCP tool parameter and CLI flag

1 participant