Repository navigation
Conversation
The MCP query tool gained chunkStrategy in the previous commit, but the REST handler that serves /query and /search built its store.search() call without it, so HTTP callers could not opt into AST-aware passage selection. Accept "auto" or "regex", forward it, and reject any other value with a 400 in the same style as the filter validation. Replace the schema-only assertion with tests that prove the strategy reaches passage selection: a TypeScript fixture where regex chunking picks the "alpha" passage and AST chunking picks "beta"/"gamma", run through both the MCP tool and both REST paths. Removing either forwarding line makes the matching test fail.
rymalia
marked this pull request as ready for review
October 26, 2026 01:59
This was referenced Oct 26, 2026
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.
The CLI has had AST-aware chunking for
qmd querysince #449 (--chunk-strategy auto), but the MCPquerytool and the HTTPPOST /queryand/searchendpoints had no way to ask for it. An agent searching an indexed code collection over MCP always got regex passage boundaries, even when the vectors had been embedded withqmd embed --chunk-strategy auto.This PR adds an optional
chunkStrategy: "auto" | "regex"to all three surfaces and forwards it tostore.search(), which already supports the option.Changes
querytool: the schema gainschunkStrategy(z.enum(["auto", "regex"]).optional()), and the handler forwards it next tofilter,intentandrerank. If it's omitted, behavior is unchanged (regex).chunkStrategy: 'auto'for indexed code.POST /queryand/search: accept the same field. Any value other than"auto"or"regex"gets a 400{"error": "Invalid field: chunkStrategy (must be \"auto\" or \"regex\")"}, in the same style as the existingfiltervalidation.skills/qmd/SKILL.md, and an[Unreleased]changelog entry.Tests
test/mcp.test.tsadds a TypeScript fixture whose function boundaries put the query terms in different passages under each strategy.regexchunking selects the passage containingalpha, andauto(AST) selects the one containingbeta/gamma. Each test checks which passage was selected, not just that the call succeeded:querytool:regexandautoreturn different lines and snippets./queryand/search: the same comparison for valid values, plus a 400 with the exact error body for an invalid value.I checked that the tests fail without the change: removing either forwarding line (MCP or REST) makes the matching test fail.
The fixture relies on the default chunk size and overlap (3,600 / 540 characters) and the 300-character snippet window, so a change to those constants would need the fixture adjusted.
Verification
npx tsc --noEmit -p tsconfig.json: cleannpx oxlint: 0 diagnosticsnpx vitest run test/mcp.test.ts(Node 24.22.1): 74 passedbun test --timeout 60000 --preload ./src/test-preload.ts test/mcp.test.ts(Bun 1.4.4): 74 passedsrc/mcp/server.ts(fix(mcp): reject malformed REST /query searches with 400 (#998) #1002, fix(mcp): stream SSE responses from the HTTP adapter #1036, feat(mcp): opt-in compact response mode (QMD_MCP_COMPACT=1 / --compact) #1047, Export QMD MCP server factory #1057, feat(mcp): report document and embedding counts in HTTP health #1059); checked withgit merge-tree.test/mcp.test.tspasses 78/78.doctor vector sampling … 32 MiB SQLite budgetandlegacy fingerprint adoption … 16 MiB SQLite budget, both assertinglimitBindsunder Bun on Linux).mainpassed that job on Bun 1.4.3; both PRs ran on Bun 1.4.4, because the workflow installsbun-version: latest. Neither PR touches the store or doctor code.