Repository navigation
chore(api): steer MCP agents to builder tools over raw SQL - #3853
brandon-pereira wants to merge 1 commit into
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 • 480 passed • 1 skipped • 1069s
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
Documentation and test-only changes to MCP tool descriptions and server instructions; no query execution or API parameter behavior changes.
Overview
Sharpens MCP copy only so agents default to builder query tools instead of
clickstack_sql. SharedbuilderCatalogtext now narrows when SQL is allowed (e.g. joins, window/per-row ordering, re-aggregation, unregistered tables, summary metrics) and drops vague CTE/subquery wording that justified SQL for simple aggregations.Adds
NOT_REASONS_TO_USE_SQL, surfaced in server instructions and the SQL tool description, mapping common needs (HAVING, JSON/expressions, per-itemwhere, trace tools) to the right builder.clickstack_tableandclickstack_timeseriesdescriptions now lead with having, expressiongroupBy/valueExpression, and per-selectwherebefore the “prefer builder over SQL” nudge.Tests in
toolDescriptions.test.tslock metadata under the 2048-byte limit, assert the new SQL guidance (no “CTEs”), and check capability text ordering.Reviewed by Cursor Bugbot for commit 4a3c76d. Bugbot is set up for automated code reviews on this repo. Configure here.