Repository navigation
chore(api): steer MCP agents to builder tools over raw SQL - #3853
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
2 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 1 P3 None could be anchored to changed lines; they are listed below. 1 P3 folded at the bottom. Findings outside the changed lines
🔵 1 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This is a prose-only change to MCP tool descriptions and server instructions (plus tests); all factual capability claims in the new steering text were verified accurate against the live schemas ( 🟡 P2 — recommended
🔵 P3 nitpicks (6)
Reviewers (4): correctness, testing, maintainability, project-standards. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 477 passed • 1 skipped • 1147s
Tests ran across 4 shards in parallel. |
Summary
Agents were reaching for
clickstack_sqlfor work the builder tools already handle. The SQL fallback list named CTEs and subqueries broadly, so an agent could write a CTE for an aggregation and then cite that list as the reason for SQL. In a 14-day aggregate review of request intent across 212 teams, about 18% cited HAVING and about 37% said the builders could not extract JSON or regex.The server instructions,
clickstack_sql, and the shared builder-tool nudge now draw a sharper line. SQL is reserved for joins across sources or tables, window functions or per-row ordering, aggregation over an already-aggregated result, unregistered tables, and summary metrics. A shared "not reasons" list maps the common needs to the tool that covers them: HAVING, JSON/regex and derived fields, conditional counts and two-window comparisons, one trace with logs, and child-span time breakdowns.clickstack_tableandclickstack_timeseriesstate theirhaving, expression-valuedgroupBy/valueExpression, and per-itemwheresupport up front. Descriptions stay under the 2048-byte client limit.No tool parameters or query behavior changed.
How to reproduce
Starting point: an MCP client connected to a ClickStack instance.
On
main:On this branch:
How to test on Vercel preview
N/A — non-UI change.
References
Note
Low Risk
Metadata and test-only changes; no tool parameters or query execution paths are modified.
Overview
Updates MCP copy only so agents default to builder query tools instead of
clickstack_sql. SharedSQL_FALLBACK_CRITERIAinbuilderCatalogis narrowed (drops broad CTE/subquery wording; names joins, window/per-row ordering, already-aggregated results, unregistered tables, and summary metrics). A newNOT_REASONS_TO_USE_SQLlist maps common needs (HAVING, JSON/regex via expressions, per-itemwhere, trace waterfall/logs, child-span breakdown) to the right builder tools.That guidance is wired into server instructions, the
clickstack_sqldescription, and the shared PREFER builder nudge.clickstack_tableandclickstack_timeseriesnow call outhaving, expressiongroupBy/valueExpression, and per-selectwherebefore the SQL nudge.Tests in
toolDescriptions.test.tsassert the 2048-byte Claude limit, that instructions/SQL omit “CTEs” but include both policy strings, and that builder capability phrases precede the SQL nudge.Reviewed by Cursor Bugbot for commit db0af2e. Bugbot is set up for automated code reviews on this repo. Configure here.