feat(api/mcp): add heatmap tile schema for hyperdx_save_dashboard#2199
feat(api/mcp): add heatmap tile schema for hyperdx_save_dashboard#2199alex-fedotyev wants to merge 3 commits intomainfrom
Conversation
Adds a heatmap display type to the MCP mcpTilesParam schema so AI agents can author heatmap tiles via hyperdx_save_dashboard. New mcpHeatmapSelectItemSchema carries valueExpression, countExpression, alias, and heatmapScaleType, mirroring the heatmap fields persisted in DerivedColumnSchema. Adds a unit test file covering accept/reject cases for the heatmap schema and a few-shot example in the tiles description block. Drive-by cleanup: replaced en-dashes used as em-dashes in pre-existing describe() strings with regular punctuation to match the team's writing style. Follow-up to #2107 (heatmap chart type wired into editor and renderer). This PR adds the MCP-side schema only. End-to-end save/get of heatmap tiles also requires the external API conversion layer to land in a sister PR before AI agents can persist heatmap tiles via hyperdx_save_dashboard. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e583fc6 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 |
🔵 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
|
PR Review
✅ No critical bugs or security issues. Schema fields ( |
E2E Test Results✅ All tests passed • 163 passed • 3 skipped • 1218s
Tests ran across 4 shards in parallel. |
The external API surface in PR #2200 exposes where/whereLanguage at the chart-config level for heatmaps (UI HeatmapSeriesEditor doesn't render per-series filters; the persisted shape stores them once via SelectSQLStatementSchema). The MCP heatmap schema was dropping them, so once #2200 lands a save through hyperdx_save_dashboard would silently discard the filter on read-back. Add `where` and `whereLanguage` to mcpHeatmapTileSchema.config with the same defaults the search tile uses (where: '', whereLanguage: 'lucene'). Extend the round-trip test with a Lucene filter, add an explicit whereLanguage="sql" round-trip, and a negative test for an invalid whereLanguage. Update the example string and changeset to document the new fields.
Deep-review on #2200 flagged that buildCreateDashboardPrompt and buildQueryGuidePrompt enumerate every supported displayType but omit heatmap, hiding the new capability from agents reading the prompt. Adds heatmap to: - TILE TYPE GUIDE (buildCreateDashboardPrompt): one-line description plus the Trace-source-only and aggFn:"heatmap" + valueExpression requirements. - COMMON MISTAKES TO AVOID: a single bullet covering the source-kind and select-item rules. - PER-TILE TYPE CONSTRAINTS (buildQueryGuidePrompt): 1 select item, no groupBy, Trace sources only. Not in this commit: the MCP source-kind runtime gate (getHeatmapTilesWithIncompatibleSources) flagged as P0/P1 #2 in the same deep-review. The helper is added in #2200 and is not yet importable from this branch; the gate will land in the rebase commit after #2200 merges.
Summary
Adds a
heatmapdisplay type to the MCPmcpTilesParamschema so AI agentscan author heatmap tiles via
hyperdx_save_dashboard.The new
mcpHeatmapSelectItemSchemamirrors the heatmap fields persisted inDerivedColumnSchema(common-utils):aggFn: literal"heatmap"(not part ofAggregateFunctionSchema)valueExpression: required column to bucket on the Y axiscountExpression: optional normalization expressionalias: optional display labelheatmapScaleType: optional"log" | "linear"The new
mcpHeatmapTileSchemaaddsnumberFormatso AI agents can formatdurations/bytes on the value axis.
groupByis intentionally omitted becauseheatmap tiles don't group, and per-select
where/whereLanguageis omittedbecause heatmap doesn't filter per-item (filtering happens at the chart level).
Stacked on #2200
This PR is stacked on #2200 ([HDX-4120] external dashboards API heatmap support).
Without #2200, calls to
hyperdx_save_dashboardwith a heatmap tile wouldreturn a cryptic Zod validation error from the external-API discriminated
union. #2200 should merge first, then this PR rebases on main and an
integration round-trip test can be added in
dashboards.test.ts(extendingthe existing "create a dashboard with multiple tile types" pattern).
Marking this PR draft until #2200 lands.
What's in this PR
mcpHeatmapSelectItemSchemaandmcpHeatmapTileSchemainmcp/tools/dashboards/schemas.tsmcpTileSchemaz.union(...)mcpTilesParam.describe(...)blockmcp/tools/dashboards/__tests__/schemas.test.tscovering accept and reject casesWhat's NOT in this PR
mcpSqlTileSchema.config.displayTypeenum is intentionally untouched.dashboards.test.ts. Will be added once[HDX-4120] feat(api): support heatmap tiles in external dashboards API #2200 merges and this branch rebases on main.
Drive-by
The pre-existing en-dashes (used as em-dashes) in seven
describe()stringson this file were replaced with regular punctuation to match the team's
writing style. No semantic change.
Deep-review carryover from #2200 (2026-05-07)
The deep-review that fired on #2200 also flagged two MCP-side items that belong here:
buildCreateDashboardPromptandbuildQueryGuidePromptnow enumerate heatmap in the TILE TYPE GUIDE, COMMON MISTAKES, and PER-TILE TYPE CONSTRAINTS sections (commit e583fc6).createDashboard/updateDashboarddoes not yet callgetHeatmapTilesWithIncompatibleSources, so an MCP-saved heatmap can persist against a non-Trace source while the REST routes reject it with HTTP 400. The helper is added in [HDX-4120] feat(api): support heatmap tiles in external dashboards API #2200 and is not importable from this branch yet. Will land in the post-[HDX-4120] feat(api): support heatmap tiles in external dashboards API #2200 rebase commit alongside the round-trip integration test.Test plan
yarn lintcleanyarn tsc --noEmitcleanjest src/mcp/tools/dashboards/__tests__/schemas.test.ts(5/5 passing)prose-lint --stagedclean