Repository navigation
Make MCP search query results concise - #362
Conversation
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
📝 WalkthroughWalkthroughSearch result output was changed to produce compact, single-line ranked markdown entries while moving detailed auxiliary information (warnings, memories, README/connector details) into structuredContent. Package README enrichment for ranked matches was removed and maxResponseSize trimming now targets low-ranked matches. ChangesSearch Result Formatting Refactor
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Handler as SearchHandler
participant Formatter as formatSearchMarkdown
participant Structured as structuredContent
Client->>Handler: send query (maybe entity, maxResponseSize)
Handler->>Handler: collect matches, warnings, memories
Handler->>Structured: assemble structuredWarnings, memories, match details
Handler->>Formatter: call with matches + warningCount
Formatter->>Handler: return compact markdown (single-line matches)
Handler->>Client: respond with { content: compact markdown, structuredContent: Structured }
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔎 Preview deployed: https://kody-pr-362.kentcdodds.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/worker/src/mcp/tools/search-format.ts`:
- Line 497: The current follow-up text incorrectly implies the `entity`
follow-up works for all hits; change the message string to clarify that "For
full detail on entity-backed hits, call `search` with `entity:
\"{id}:{type}\"`." and/or only append that follow-up when the result actually
has an entity ref. Locate the message construction in search-format.ts (the
string currently "'For full detail on one hit, call `search` with `entity:
\"{id}:{type}\"`.'") and update it to mention "entity-backed hits" or add a
guard that checks for an entity ref (avoid offering the follow-up for
`retriever_result` rows which lack an entity ref and are not supported by
parseEntityRef).
In `@packages/worker/src/mcp/tools/search.ts`:
- Around line 1768-1774: The compact markdown currently collapses multiple
warnings into a single message because conciseWarnings is built as a single
string when warnings.length > 0; update formatSearchMarkdown logic so
conciseWarnings reflects the actual warning count instead of always showing 1:
use warnings.length (or structuredContent.result.warnings.length) to create a
message like `${warnings.length} auxiliary search warning(s) available in
structuredContent.result.warnings.` and ensure the same fix is applied where
conciseWarnings is constructed again (the other occurrence referencing
warnings/structuredWarnings). Locate identifiers structuredWarnings,
conciseWarnings, formatSearchMarkdown and the use of
warnings.length/structuredContent.result.warnings and replace the single-entry
fallback with a count-aware message.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8d7e036c-aaa0-4c8f-8843-e4771148b6b1
📒 Files selected for processing (5)
docs/use/search.mdpackages/worker/src/mcp/tools/search-format.node.test.tspackages/worker/src/mcp/tools/search-format.tspackages/worker/src/mcp/tools/search-handler.node.test.tspackages/worker/src/mcp/tools/search.ts
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 16ad5b6. Configure here.
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>

Summary
search({ query })responses as a compact ranked list with type, title/name, one-line summary, and entity refs for entity-backed hits.search({ entity }), remove unused README enrichment for ranked query hits, and update search docs accordingly.Test plan
npx vitest run packages/worker/src/mcp/tools/search-format.node.test.ts packages/worker/src/mcp/tools/search-handler.node.test.ts packages/worker/src/mcp/tools/search.node.test.tsnpm run format:check -- packages/worker/src/mcp/tools/search-format.ts packages/worker/src/mcp/tools/search.ts packages/worker/src/mcp/tools/search-format.node.test.ts packages/worker/src/mcp/tools/search-handler.node.test.ts docs/use/search.mdnpm run typecheckgit diff --checkSummary by CodeRabbit
Improvements
Documentation
Tests