Repository navigation
feat(mcp): Render Sentry time series charts inline in MCP Apps hosts - #2413
Conversation
Tools can now declare MCP `_meta`, which the server sends in tools/list. A tool that points `_meta.ui.resourceUri` at a view in the new UI resource registry gets that `ui://` resource listed and readable, with the MCP Apps mime type. The registry is empty until the chart view lands. Refs #741 Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
render_sentry_chart fetches an events time series for a query and returns every bucket of each series, so values never round-trip through the model and the chart is not capped at 48 buckets like search results are. With groupBy it asks events-timeseries for the top 5 values of one attribute (topEvents, without the Other series) and returns one series per value. Time series results from the dataset search tools now suggest the same chart as a callable render_sentry_chart action. Refs #741 Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Add the chart view as the ui://sentry/chart/v1.html resource and link the tool to it with _meta.ui.resourceUri (plus openai/outputTemplate for ChatGPT). The view is vanilla TypeScript with hand-drawn SVG, uses the ext-apps App class, follows the host theme, and calls the tool again through the host for its 1h/24h/7d/14d range picker. esbuild bundles chart-app/ into src/ui/chart-app.generated.ts so stdio and the Worker serve it with no file system. ci:policy fails when the generated file is stale. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Add scripts/mcp-apps-host.mjs and the mcp-apps verify-toolkit map. The script starts the mock stdio server, reads render_sentry_chart's ui:// view, mounts it through the ext-apps AppBridge in headless Chromium under the spec's default CSP, and screenshots light, dark, the range picker round trip, and a grouped chart. Document MCP Apps views in the tool and response design docs and contributor guides. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
The inlined render_sentry_chart view adds 418 KB to dist/sentry-mcp.cjs, which now measures 4.10 MiB. Raise the budget to 4.4 MiB so it keeps about 300 KB of headroom, as before. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8b60aaa. Configure here.
…n the chart view Keep the rendered chart and clear the pending range when the host cancels a tool call, enable Open in Sentry for http URLs from self-hosted installs, and draw a point for a series with a single bucket.
MathurAditya724
left a comment
There was a problem hiding this comment.
I reproduced two correctness gaps with independent tests in addition to the seven passing tool tests. Please address the inline findings and add regressions for omitted project scope and negative/mixed-sign metric buckets. The dependency security finding also still needs a resolution before this can merge.
Without a project parameter, Sentry only covers projects whose teams the user belongs to, so an org admin outside those teams got an empty chart. Send project=-1 like the UI's All Projects, as #2415 does for search_events.
The y domain assumed a zero minimum, so negative buckets were drawn below the viewBox. Span the actual minimum and maximum, always including 0, and draw gridlines across that range.
Discover reads group-by columns from field, so Open in Sentry for a grouped errors chart showed an ungrouped query. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Below the 280-unit minimum viewBox width, viewBox units and CSS pixels differ, so the tooltip drifted from the crosshair. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
…hart view The ext-apps App class pulled zod and the MCP client SDK into the view, which made it 414 KB of script for 11 KB of chart code. bridge.ts speaks the stable MCP Apps protocol over postMessage directly (ui/initialize, initialized, tool-input, tool-result, tool-cancelled, host-context-changed, resource-teardown, size-changed, tools/call, ui/open-link), and parse.ts replaces zod at the structuredContent boundary. The view drops from 408 KiB to 16 KiB of HTML.
The server needs one MIME type string and two _meta shapes from the MCP Apps spec, so declare them in ui-resources.ts. ext-apps stays a dev dependency for the verify-toolkit host's AppBridge.
The chart view now adds 17 KB, not 418 KB, so the bundle is back to 3,901,981 bytes (3.72 MiB).
Sessions that never render a view, such as every text-only client, no longer evaluate the inlined HTML module. Bundlers keep it in the same file but defer its initialization.
generate-chart-app (and ci:policy) fails when a view is over its 24 KiB budget or loads anything from the network. A vitest check fails when a tool names an unknown view, a view has no tool, a ui:// URI has no version, a csp allows an origin, or the HTML changes without a new htmlSha256 next to its URI, which is the prompt to bump the version.
mcp-core and its views implement MCP Apps directly, so the server bundle and views stay small. The rule leaves ext-apps to the verify-toolkit host, and a fixture test runs Oxlint to prove it fires.
The reference AppBridge now also sends a theme change, a cancelled call, and ui/resource-teardown, so the host run checks every message the hand-written bridge handles. Evidence regenerated: 9 of 9 checks pass, and the screenshots are byte-identical to the ext-apps App build.
design/mcp-apps.md owns the view rules: optional, query-driven, offline, budgeted, versioned by URI, untrusted at the boundary, listed only with a tool, and not gated on the client capability, with the reasons and the gaps. mcp-tools, mcp-tool-responses, and the contributing guide point at it instead of repeating the rules.
3,902,133 bytes after the view's HTML moved behind a lazy import.
|
Answering both comments. The view is tight now, and the principles and checks are in, as of 42df212. Size. The view is 16.9 KB of HTML, down from ~408 KiB. The esbuild metafile showed where the old bytes went: zod (193 KB) plus the MCP client and core packages that ext-apps' Loading. The HTML is behind a dynamic import and loads only on the first Principles:
Checks. Each one has a test that fails on a bad input.
Verification. The headless host script now passes 9 of 9 checks against the reference AppBridge, including a new lifecycle check for theme change, cancel and teardown, and the screenshots match the old build byte for byte. The mcp-core suite (2509 tests) and |
UiResource.budgetBytes holds the budget that generate-chart-app enforces, so the generator, the policy test, and a size report read one value instead of copying 24 KiB. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
measure-ui builds the server with every skill, reads each listed ui:// resource through resources/read, and reports raw, gzip, and brotli bytes against the view's budget, as a table, JSON, or a markdown section. A new view shows up without a script change. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
The Token Cost workflow now runs measure-ui, adds an MCP Apps views section to the PR comment and job summary, and uploads ui-stats.json with token-stats.json. It also runs when a view's sources change. The PR comment now posts on every same-repo PR run instead of only when the tool token count moved, since a view can grow while the token count stays the same. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
📊 MCP Server Token Cost ReportSummary
Per-Tool Breakdown
Note: This measures the static overhead of tool definitions sent to LLM clients with every request. Lower is better. MCP Apps viewsEach
The budget applies to raw bytes, and the view's generator fails over it. |
Mark render_sentry_chart experimental and keep it out of generated skill prompts. Stable sessions list neither the tool nor its ui:// view, and declare no resources capability, since resources follow the registered tools. The search_events chart suggestion already routes only to available tools. Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>

Why
MCP Apps hosts (Claude, VS Code, ChatGPT/Codex) can render interactive charts inline, the way Datadog's MCP "Get Widget" does. Sentry MCP returns only text and JSON. This is v1 of #741, focused on charts.
What changed
defineToolpasses_metathrough to tools/list. A smallui-resourcesregistry lists eachui://view that a registered tool references, with mimeTypetext/html;profile=mcp-app(MCP Apps spec 2026-01-26).render_sentry_charttool. It takes a query (dataset, query, yAxis, optional groupBy for the top 5 values, period or start/end) and fetches the series on the server. Values never pass through the model, and the full series is returned, not the 48 bucketssearch_eventskeeps._meta.ui.resourceUriandopenai/outputTemplate, bothui://sentry/chart/v1.html. It does not use ext-appsregisterAppTool, which adds the deprecated flatui/resourceUrikey.search_eventstime series results suggestrender_sentry_chartwith the same arguments.packages/mcp-core/chart-app/) is vanilla TS and SVG on the ext-appsAppclass. It has hover tooltips, hatched incomplete buckets, light/dark from the host, a 1h/24h/7d/14d picker that re-calls the tool through the host, and "Open in Sentry" viaui/open-link. It is self-contained, so the CSP declares no domains.generate-chart-appbundles the view into a generated TS string, so stdio and the Worker need no file system.ci:policyfails on drift.map/mcp-apps.md,scripts/mcp-apps-host.mjs) mounts the view through ext-appsAppBridgein headless Chromium. Screenshots are indocs/evidence/mcp-apps-chart/.Tradeoffs
zodEnglishLocalesPlugin(down from 567 KiB).@sentry/mcp-serverbundle budget rises from 3.75 to 4.4 MiB. The bundle is 4.10 MiB, about 3.70 MiB without the view.Blast Radius
Additive. Existing tools change only by the new suggested action on
search_eventstime series results. The server now advertises theresourcescapability.Open questions
Appclass for a hand-rolled bridge to cut size?via @dcramer.
--
View Session [Sentry]