Skip to content

feat(mcp): lean output mode for search_documents (full | locations)#10

Merged
exbuf merged 1 commit into
mainfrom
feat/mcp-lean-output
Jul 20, 2026
Merged

feat(mcp): lean output mode for search_documents (full | locations)#10
exbuf merged 1 commit into
mainfrom
feat/mcp-lean-output

Conversation

@exbuf

@exbuf exbuf commented Jul 20, 2026

Copy link
Copy Markdown
Owner

What

Adds a detail output mode to the MCP search_documents tool. Slice 1 of the "lean output" idea discussed in-session.

  • full (default) — unchanged: each match returns {file, line, text}.
  • locations — returns only {file, line}, dropping the (often paragraph-sized) matched text.

Why

Directly addresses the context-overflow we hit while testing the local stack: on a paragraph-heavy corpus, 25 full matches + tool definitions overflowed an 8192-token window even at --max-results 25. locations attacks it from peekdocs's side — a small local model fits far more results — and enables a clean two-phase pattern: broad locations sweep → read the few that matter with get_document_context.

Design choices (per discussion)

  • Default stays full — the model only sees less when a request explicitly asks for locations. The tool description tells it to say so when it does, to avoid "answered confidently from a partial picture."
  • Not auto-triggered. Lean is opt-in (human-asked or, later, host-set). Discoverability comes from the truncation note, which now points at detail=locations — but only on search_documents (gated via _cap(..., detail_hint=True)), so the note never suggests a param the other tools don't accept.
  • _match_dicts is the single chokepoint; unknown detail values fall back to full.

Scope

search_documents only (MVP). Deliberate follow-up slices: snippet mode (centered window; needs term relocation + fuzzy fallback) and threading detail into run_search_suite / run_regex_collection.

Verification

  • 780 passed / 8 skipped; new TestDetailModes + detail_hint gating test.
  • mypy clean (14 files); doc-links clean.
  • detail confirmed present in the live tool schema.
  • No version bump — Unreleased.

Docs

CHANGELOG (Unreleased), USER_GUIDE (Tools row + "want to see more" third lever), LOCAL_AI_SETUP (overflow troubleshooting option c).

🤖 Generated with Claude Code

…ions)

Lean output slice 1: `locations` returns only file + line per match, dropping
the (often paragraph-sized) matched text. Far more token-efficient — a small
local model fits many more results in its context window, and it's a natural
"which files mention X?" first pass before reading specific ones with
get_document_context. Attacks the context-overflow problem from peekdocs's side
rather than only via LM Studio settings.

Design (per discussion):
- Default is `full` (unchanged behavior); the model only sees less when a
  request explicitly asks for `locations`, and the tool description tells it to
  say so when it does — avoids "answered confidently from a partial picture".
- `_match_dicts(matches, detail)` is the single chokepoint; unknown values fall
  back to full.
- Truncation `note` now points at `detail=locations` as a way to fit more —
  gated by `_cap(..., detail_hint=True)` so it appears ONLY on search_documents
  (the tool that accepts the param), never on get_document_context / suite /
  collection notes (which would be an invent-a-param trap).

Scope: search_documents only (MVP). `snippet` mode and suite/collection
fan-out are deliberate follow-up slices.

Tests: full-includes-text, locations-omits-text, unknown-falls-back,
detail-hint-gating. Docs: USER_GUIDE Tools row + "want to see more" third lever;
LOCAL_AI_SETUP overflow troubleshooting (c); CHANGELOG. No version bump.

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-lean-output branch from 1ff07cc to 9d9713c Compare July 20, 2026 21:04
@exbuf
exbuf marked this pull request as ready for review July 20, 2026 21:09
@exbuf
exbuf merged commit 14ca0bc into main Jul 20, 2026
20 checks passed
@exbuf
exbuf deleted the feat/mcp-lean-output branch July 20, 2026 21:09
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