Skip to content

MCP Apps: interactive Vega-Lite charts#132

Closed
nicosuave wants to merge 1 commit intomainfrom
mcp-apps-vega
Closed

MCP Apps: interactive Vega-Lite charts#132
nicosuave wants to merge 1 commit intomainfrom
mcp-apps-vega

Conversation

@nicosuave
Copy link
Copy Markdown
Member

Summary

  • Vite-built chart widget with bundled ext-apps SDK + Vega-Lite + vega-interpreter (CSP-safe, no eval, no CDN)
  • Widget receives data via MCP Apps protocol, renders interactive Vega-Lite charts in Claude Desktop and other MCP Apps hosts
  • create_chart returns Vega spec only (no 374KB PNG bloat)
  • structured_output=False on all tools + falsy defaults to fix Claude Desktop tool visibility
  • Fullscreen toggle support (activates when host advertises it)
  • Removed vendored mcp-ui-server, _apps_enabled flag, and CDN dependencies

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac97484b58

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};

app.ontoolinput = () => {
container.innerHTML = '<div class="loading">Running query...</div>';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep fullscreen button when showing loading state

Replacing #chart with innerHTML in ontoolinput removes the existing #fullscreen-btn node, but later rendering only removes non-button children and never recreates that button. In hosts that emit ontoolinput before each result (the normal flow), fullscreen support disappears after the first query, so users can no longer toggle display mode even when the host advertises it.

Useful? React with 👍 / 👎.

@nicosuave nicosuave force-pushed the mcp-apps-vega branch 2 times, most recently from e008848 to 4ad2da7 Compare March 31, 2026 01:43
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ad2da725b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +24 to +25
const ro = new ResizeObserver(() => result.view.resize().run());
ro.observe(container);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Dispose previous chart observers before rerendering

Each tool result creates a new ResizeObserver bound to a new Vega view, but neither the observer nor the prior view is ever cleaned up when a subsequent query rerenders the chart. In sessions where users run multiple queries, observers accumulate and continue firing on every resize, causing redundant view.resize().run() calls and growing memory/CPU usage over time.

Useful? React with 👍 / 👎.

Comment on lines +15 to +19
const prefersDark = window.matchMedia?.("(prefers-color-scheme: dark)").matches;

embed(container, spec as any, {
actions: false,
theme: prefersDark ? "dark" : undefined,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use host-provided theme when selecting Vega theme

The chart theme is chosen from window.matchMedia('(prefers-color-scheme: dark)') instead of MCP host context, so embedded charts can render with the wrong Vega theme whenever host theme and OS theme differ (or when the host theme changes at runtime). This leads to inconsistent colors/contrast in clients like Claude Desktop that provide their own theme via host context.

Useful? React with 👍 / 👎.

- Vite-built widget bundles ext-apps SDK + Vega-Lite + vega-interpreter
  into a single HTML file (no CDN deps, no eval, CSP-safe)
- Widget receives tool result via MCP Apps protocol (ontoolresult)
- Supports fullscreen toggle when host advertises it
- create_chart returns vega_spec only (no PNG, widget renders interactively)
- Register ui://sidemantic/chart resource with proper MCP Apps metadata
- Remove _apps_enabled flag (MCP Apps works via protocol, not a runtime flag)
- Remove vendored mcp-ui-server (widget is self-contained)
- Remove --apps CLI flag dependency on mcp-ui-server import
- structured_output=False on all tools (fixes Claude Desktop tool visibility)
- Replace | None params with falsy defaults (removes anyOf from schemas)
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc3ba0ec61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +14 to +15
spec.width = "container";
spec.height = 500;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect chart size from tool result when rendering

renderChart always forces spec.width = "container" and spec.height = 500, so the widget ignores the width/height requested via create_chart and remains 500px tall even in fullscreen mode. In practice this can clip dense charts (many categories/labels) and makes fullscreen mostly unused vertical space; the renderer should preserve the incoming size or compute height from the current container/display mode instead of hard-coding 500.

Useful? React with 👍 / 👎.

@nicosuave nicosuave closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant