feat(api): support number-tile backgroundChart in the MCP dashboard tools#2584
feat(api): support number-tile backgroundChart in the MCP dashboard tools#2584alex-fedotyev wants to merge 1 commit into
Conversation
…ools
Add backgroundChart ({ type: line | area, color? }) to the builder
number-tile config in clickstack_save_dashboard and
clickstack_patch_dashboard, reusing BackgroundChartSchema from
common-utils. The MCP tools already share the external-api conversion,
so this is schema + prompt + tests only, no conversion edits.
Builder number tiles only: raw SQL number tiles return a single value
with no time dimension to bucket, so backgroundChart is not on their
schema (a sent value is stripped on save). Mirrors number-tile color in
the MCP tools (#2480).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: bc17781 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 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
|
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge; changes are additive and confined to MCP schema, prompt text, and integration tests. The diff is a clean, self-contained addition of an optional field. BackgroundChartSchema is imported from common-utils (shared with the REST API), so the type definition cannot drift. The external-API conversion layer already passes backgroundChart through, meaning no new conversion logic was needed. Raw SQL tiles correctly drop the field via Zod's default strip behavior, confirmed by a dedicated integration test. Four integration tests cover the key scenarios—round-trip save, round-trip patch, invalid-type rejection, and raw-SQL stripping—providing good confidence that the path is correct end-to-end. No files require special attention. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Agent as MCP Agent
participant Tool as MCP Tool (save/patch)
participant Schema as mcpNumberTileSchema
participant Conversion as externalAPI conversion
participant DB as Dashboard Store
Agent->>Tool: clickstack_save_dashboard / clickstack_patch_dashboard
Tool->>Schema: Zod parse (mcpTileSchema union)
Note over Schema: Builder number tile → mcpNumberTileSchema<br/>backgroundChart accepted (BackgroundChartSchema)<br/>Raw SQL tile → mcpSqlTileSchema<br/>backgroundChart stripped (not in schema)
Schema-->>Tool: Validated tile config
Tool->>Conversion: toInternalConfig / toExternalConfig
Note over Conversion: backgroundChart passed through as-is
Conversion->>DB: Persist BuilderSavedChartConfig with backgroundChart
DB-->>Agent: Saved dashboard with backgroundChart in response
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Agent as MCP Agent
participant Tool as MCP Tool (save/patch)
participant Schema as mcpNumberTileSchema
participant Conversion as externalAPI conversion
participant DB as Dashboard Store
Agent->>Tool: clickstack_save_dashboard / clickstack_patch_dashboard
Tool->>Schema: Zod parse (mcpTileSchema union)
Note over Schema: Builder number tile → mcpNumberTileSchema<br/>backgroundChart accepted (BackgroundChartSchema)<br/>Raw SQL tile → mcpSqlTileSchema<br/>backgroundChart stripped (not in schema)
Schema-->>Tool: Validated tile config
Tool->>Conversion: toInternalConfig / toExternalConfig
Note over Conversion: backgroundChart passed through as-is
Conversion->>DB: Persist BuilderSavedChartConfig with backgroundChart
DB-->>Agent: Saved dashboard with backgroundChart in response
Reviews (1): Last reviewed commit: "feat(api): support number-tile backgroun..." | Re-trigger Greptile |
Deep Review✅ No critical issues found. This is a tightly-scoped, additive change: it adds 🔵 P3 nitpicks (1)
Reviewers (6): correctness, testing, maintainability, kieran-typescript, api-contract, project-standards. Testing gaps: |
E2E Test Results✅ All tests passed • 224 passed • 3 skipped • 1519s
Tests ran across 4 shards in parallel. |
Add
backgroundChartto number tiles in the MCP dashboard tools, so an agent can author the background trend sparkline throughclickstack_save_dashboardandclickstack_patch_dashboard. Mirrors the number-tile color MCP work in #2480 and the v2 REST parity in #2509.Part of #1360. Replaces #2510 (closed; that branch began as a stacked PR and the commit history got noisy once the base merged). Same code, single clean commit against
main.Summary
Add
backgroundChart(a requiredtypeoflineorarea, plus an optional palette-tokencolor) to the builder number-tile config in the MCP save and patch tools, reusingBackgroundChartSchemafromcommon-utils. The MCP tools already share the external-api conversion, so this is schema, prompt, and tests only, no conversion edits. Raw SQL number tiles do not expose it (no time dimension to bucket), matching the editor and the REST API.What
backgroundCharttomcpNumberTileSchema.configwith a tool description; the patch tool inherits it viamcpPatchTileSchema.typeoutsideline/area; drop the field on a raw SQL number tile.Test plan
yarn workspace @hyperdx/api lintyarn workspace @hyperdx/api tsc --noEmitmcp/__tests__/dashboards/{saveDashboard,patchDashboard}.test.ts(75 passed)CI re-runs lint, typecheck, and the test suite against the current
mainon this branch.What's NOT in this PR (follow-up)