Skip to content

feat(mcp): rank option for search_documents#12

Merged
exbuf merged 1 commit into
mainfrom
feat/mcp-ranking
Jul 21, 2026
Merged

feat(mcp): rank option for search_documents#12
exbuf merged 1 commit into
mainfrom
feat/mcp-ranking

Conversation

@exbuf

@exbuf exbuf commented Jul 21, 2026

Copy link
Copy Markdown
Owner

What

Slice 2 of relevance ranking — wires --rank (merged in #11) into the MCP path. search_documents gains a rank option so, when results are capped, the assistant's window is the most relevant matches instead of just the first ones. This was the original motivation for ranking.

Honest handling of the index gate

Ranking needs the on-disk index, but the MCP server defaults to read-only / no index. So:

  • rank is opt-in (default off), consistent with detail.
  • If rank is requested but the search didn't use the index (result.used_index is False), the response carries a rank_note stating the results are in file order, not ranked — and the docstring tells the model to relay it. This prevents the model from presenting first-N as best-N (the same partial-picture guard we applied to detail/truncation).

Verified

  • rank without index → rank_note present, matches stay in file order.
  • rank with index (allow_index_write) → reordered, most-relevant first, no note.
  • Default (no rank) → no note.
  • 788 passed / 8 skipped; new TestRankParam; rank present in the tool schema; mypy + doc-links clean; no version bump.

Docs

CHANGELOG (Unreleased), USER_GUIDE search_documents row + a fourth "want to see more" lever (rank makes the capped set the best, not more).

Remaining

GUI checkbox is the last slice.

🤖 Generated with Claude Code

…ed window)

Slice 2 of ranking — wire it into the AI path. When results are capped, ranking
makes the returned window the most-relevant matches instead of the first ones
(the original motivation for ranking).

- search_documents gains rank: bool = False, threaded to api.search(rank=...).
- Index-gated and honest about it: ranking needs the on-disk index, but the MCP
  server defaults to read-only/no-index. If rank is requested and the search
  didn't use the index (result.used_index False), the response carries a
  rank_note saying results are in file order, not ranked — so the model won't
  present first-N as best-N. Docstring tells it to relay that note.
- Default off (opt-in), consistent with detail; the model ranks for
  "most relevant..." style questions.
- tests: rank-without-index adds note + stays file order; rank-with-index
  reorders (dense first) with no note; default has no note.
- docs: CHANGELOG, USER_GUIDE Tools row + a fourth "want to see more" lever.

Remaining slice: GUI checkbox. No version bump (Unreleased).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Robert D. Schoening <bobschoening@gmail.com>
@exbuf
exbuf force-pushed the feat/mcp-ranking branch from 708cda9 to d7e22af Compare July 21, 2026 00:59
@exbuf
exbuf marked this pull request as ready for review July 21, 2026 01:01
@exbuf
exbuf merged commit 019aa5e into main Jul 21, 2026
20 checks passed
@exbuf
exbuf deleted the feat/mcp-ranking branch July 21, 2026 01:01
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