Skip to content

improvement(search): run Search MCP calls whose arguments have one reading, and log rejected ones - #9814

Merged
waleedlatif1 merged 3 commits into
stagingfrom
improvement/search-mcp-rvt-gaps
Nov 9, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
improvement/search-mcp-rvt-gaps

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • The MCP SDK rejects a tool call whose arguments fail the input schema before the tool runs: the client gets MCP error -32602, spends another round, and nothing is logged on our side. The Search MCP route now rewrites search arguments that fail the schema but have exactly one reading, before the SDK validates them:
    • nativeQueries: [] → omitted
    • a null optional native query field (e.g. kind: null) → omitted
    • a top-level provider that names a provider → the source filter (when source is absent or the same); any other value is still rejected
    • a search filter (startDate, endDate, modifiedAfter, modifiedBefore, sortBy, topK) that every native query carries with the same value → the search's own filter
  • Native queries that disagree on a filter (or where only some carry it) are still rejected, rather than guessing
  • Arguments the schema already accepts reach the SDK unchanged, and tools/list is untouched (no schema or description change, so clients are not asked to re-approve the tools)
  • Logs Knowledge MCP tool input repaired (which repairs) and Knowledge MCP tool input rejected (field paths and issue codes, no values), so rejected calls become visible

Type of Change

  • Improvement

Testing

  • MCP client bench (Sonnet 5.5, 83 cases): 1.5% of attempts (30 of 1,992) hit a schema rejection on the current code; 13 of the 30 have one reading and are repaired by this change. Paired run against staging: results to follow in a comment
  • New lib/knowledge/mcp/route-handler.protocol.test.ts sends JSON-RPC through the real route, SDK transport and Search MCP server: each repair fails on the base and passes here (each guard reverted and watched go red), both ambiguous-filter cases and a provider value that names no provider stay rejected, and calls to inherited-name tools (constructor, toString, __proto__) get an MCP error, not a 500
  • bunx vitest run lib/knowledge/mcp (60 passed), biome on changed files; type-check and audits in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 9, 2026 6:09pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new blocking issue remains.

Summary

The PR repairs clearly intended Search MCP arguments before SDK checks and logs repairs and rejected inputs without argument values.

  • Search runs when common argument forms have one clear meaning.
  • Rejected MCP tool inputs now show which fields failed.

Reviews (2) · Last reviewed commit: "fix(search): look up tool schemas by own..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit eae86a6 into staging Nov 9, 2026
99 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/search-mcp-rvt-gaps branch November 9, 2026 20:34

This branch was previously deployed

1 inactive deployment
Preview — 50ae0203 Deployed Nov 9, 2026 by vercel[bot]
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