feat: Support dashboard variables in MCP server - #2951
Conversation
🦋 Changeset detectedLatest commit: 5b32a11 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Greptile SummaryThis PR adds dashboard-variable support to MCP dashboard persistence, validation, and tile-query tools.
Confidence Score: 3/5The PR is not yet safe to merge because the outstanding aggregate-condition language mismatch can generate malformed or incorrectly filtered ClickHouse queries. Variable-bearing aggregate conditions still default to Lucene during substitution while the aggregate WHERE-pushdown path defaults the same field to SQL, leaving both previously reported query failures unresolved. Files Needing Attention: packages/common-utils/src/variables.ts, packages/common-utils/src/core/renderChartConfig.ts
|
| Filename | Overview |
|---|---|
| packages/common-utils/src/variables.ts | Extends language-aware variable expansion, but the previously reported aggregate-condition default mismatch remains in the current query path. |
| packages/api/src/mcp/tools/dashboards/variables.ts | Resolves declared dashboard variables, defaults selections to empty, and rejects unknown supplied names. |
| packages/api/src/mcp/tools/dashboards/queryTile.ts | Adds variable selections and variable diagnostics to single-tile execution. |
| packages/api/src/mcp/tools/dashboards/queryTiles.ts | Threads resolved variables through bounded concurrent tile execution. |
| packages/api/src/mcp/tools/query/helpers.ts | Passes variables into builder, raw-SQL, and event-pattern query paths and improves unknown-variable diagnostics. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[MCP dashboard tool] --> B[Load team-scoped dashboard]
B --> C[Read variable-enabled filters]
C --> D[Resolve supplied variable values]
D --> E[Expand tile expressions and macros]
E --> F[Render ClickHouse query]
F --> G[Return result and warnings]
Reviews (5): Last reviewed commit: "fix: Fix tests after merge" | Re-trigger Greptile
E2E Test Results✅ All tests passed • 320 passed • 1 skipped • 1356s
Tests ran across 4 shards in parallel. |
Deep Review✅ No P0/P1 issues found. The change is well-tested (large additions across 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Reviewers (10): correctness, testing, maintainability, project-standards, api-contract, security, adversarial, kieran-typescript, agent-native, learnings-researcher. Coverage note: The dispatched persona-reviewer sub-agents had not returned their findings at synthesis time, so the findings above come from direct analysis of the diff and the surrounding schema/expansion code; they were verified against the code paths cited. The new behavior is otherwise accompanied by substantial test coverage, and the CSV-format non-escaping in Testing gaps: No test asserts the documented "Rejected when isVariableEnabled is not true" / "rejected when isBroadcastEnabled is false" filter constraints — consistent with those constraints not being enforced. |
70b5f03 to
e283e7d
Compare
e283e7d to
7a41daf
Compare
|
Are we planning to merge this only after we remove the feature flags? I am concerned agents might start using this feature before its allowed. |
Correct, we will merge after enabling the feature. Sorry, should have written that in the description. I'll put this in draft mode but would appreciate your review still, so I can get started on addressing any feedback you may have. I expect we can remove the toggle early next week. |
|
PR LGTM otherwise! Thanks for clarifying |
5b32a11 to
b3b78ae
Compare
Summary
This PR updates the MCP tools and prompts to include support for the new dashboard variables feature.
This is to be merged only after removing the toggles guarding the dashboard variables feature.
Screenshots or video
How to test locally
Fire up your agent and ask it to build a dashboard that makes use of dashboard variables.
References