flint-chart-mcp

v1.1.1
flint-chart-mcp Checked 20 hours ago Published 14 days ago

Model Context Protocol server for Flint — compile, validate, and render semantic chart specs across supported backends.

Flint's bundled chart-author and theme-author skills teach an agent how to author a ChartAssemblyInput or a reusable ThemeSpec. This MCP server exposes those skills and acts as the execution counterpart for charts: it compiles, validates, and renders one semantic spec. Most chart MCP servers expose one tool per chart type (26+ tools) because every chart has a different schema, and they upload your config to a remote render service. Flint has one schema (ChartAssemblyInput) spanning ~40 chart types × multiple backends, so this server exposes six focused tools and renders locally.

Summary extracted from the README.

flint-chart-mcp

Model Context Protocol (MCP) server for Flint. Give it data + one semantic chart spec; get back a rendered chart — PNG or SVG — across Vega-Lite, ECharts, and Chart.js. Rendering is local and in-process: your data never leaves the host.

Flint's bundled chart-author and theme-author skills teach an agent how to author a ChartAssemblyInput or a reusable ThemeSpec. This MCP server exposes those skills and acts as the execution counterpart for charts: it compiles, validates, and renders one semantic spec.

Why a small tool surface

Most chart MCP servers expose one tool per chart type (26+ tools) because every chart has a different schema, and they upload your config to a remote render service. Flint has one schema (ChartAssemblyInput) spanning ~40 chart types × multiple backends, so this server exposes six focused tools and renders locally.

Tools

Tool Input Output
render_chart spec + backend + format (png/svg) + scale? inline PNG image or SVG text
compile_chart spec + backend backend-native spec JSON + warnings
validate_chart spec + backend + optional updates validity, warnings/errors, computed size as JSON (also in structuredContent); on Vega-Lite, a report of what to fix follows; a malformed update layer is an error
list_chart_types backend? chart types, encoding channels, and supported interaction presets per backend
list_interaction_presets chartType?, type? interaction presets: what each does, what it needs from the chart, reset gestures, and every option it accepts
list_themes optional preset id shipped visual themes, plus guidance for a selected theme
get_flint_skill skill (chart/theme/interaction/board) + section? a bundled skill as markdown, or one ## section of it
validate_board headline, deck, source, charts, optional link_spec, grid a board of several charts checked without drawing: its report, layout, links and review
show chart (spec + optional updates, view) or board (as validate_board) a live UI card (MCP App) with the chart or board: SVG preview + editing panel, with its ChartUpdate layers applied, and the same report

Visual themes

For Vega-Lite charts, agents should use a preset id from list_themes:

{ "theme_spec": "economist" }

When the user requests a brand adjustment, extend a preset and keep the override small:

{
  "theme_spec": {
    "extends": "economist",
    "id": "our-brand",
    "ink": { "series": { "single": "#6b3fa0" } }
  }
}

See the full ThemeSpec guide for supported fields and merge behavior.

MCP App: live chart view

In hosts that support MCP App UIs (e.g. Claude Desktop), show opens a card with the chart or board spec it is given. The agent checks the spec with validate_chart or validate_board and fixes what the report asks before it calls show, so each turn shows one card; later changes open a new card and earlier cards keep what they showed. The card renders the spec live (Vega-Lite → SVG) and shows a customization panel built from Flint's own option model — chart type, channel bindings, chart properties (corner radius, stack mode, donut hole, …), and encoding actions (sort), plus Flint's visual theme presets. Rendering and edits run entirely in the host UI; no data leaves the host. The UI is a single self-contained HTML bundle served as the ui://flint-chart/view.html resource and built with npm run build:ui.

The server keeps nothing between calls: every tool builds the chart or board again from the spec it is given, so it runs stateless behind any number of instances. The reader's changes on a card (a theme, an arrangement, panel edits) stay on that card and reach the agent in the card's context, as the fields to pass to the next show.

Resources and prompts

Name Kind Purpose
flint://agent-skill resource Bundled Flint authoring instructions for generating valid ChartAssemblyInput specs.
flint://theme-skill resource Bundled instructions for translating a visual identity into a valid reusable ThemeSpec.
flint://interaction-skill resource Bundled instructions for adding behaviour to a chart: a gesture or an intent mapped to presets, as one valid interaction_spec.
flint://chart-types resource Browsable chart-type catalog and encoding channels across backends.
flint://board-skill resource Bundled instructions for a board of several charts: headline, chart choice, layout, links.
ui://flint-chart/view.html resource Bundled UI for the show MCP App card (live chart or board + customization panel).
author_flint_chart prompt Embeds the bundled skill so prompt-aware clients can load the chart-spec rules before tool calls.
author_flint_theme prompt Embeds the theme-author skill for creating, translating, refining, or reviewing a ThemeSpec.
author_flint_interaction prompt Embeds the interaction-author skill: presets as an interaction_spec, the ChartUpdate for a mounted chart, reading the chart state, linking charts, and bespoke interactions.

The server instructions tell the agent to call get_flint_skill before it writes a spec, so the skills reach the agent in hosts that do not surface MCP resources or prompts to the model. You can also include flint://agent-skill or run the author_flint_chart prompt before asking the agent to call validate_chart, show, render_chart, or compile_chart.

When creating or substantially customizing a visual theme, load flint://theme-skill or run author_flint_theme. Use list_themes separately to discover built-in presets and retrieve preset-specific guidance.

When the user asks for behaviour on a chart, names an intent such as explore or compare, or adds behaviour to a chart that already exists, load flint://interaction-skill or run author_flint_interaction. Use list_chart_types to confirm the presets a chart type supports.

Data can be provided in two ways:

  • Embedded rows: pass data: { values: [...] } directly in the MCP tool call.
  • Local file references: pass data: { url: "..." } for a .json, .csv, or .tsv file. Remote URLs are never fetched.

By default the server trusts the agent's host for file access: any local file the agent references can be read (the host already governs what the agent may touch, and the agent can already inline the same rows via data.values). Relative data.url paths resolve against the server's working directory; absolute paths and file:// URLs are read as given. For data it downloads or generates, the agent can simply create a folder in the project (e.g. ./flint-data) and reference files from it — the server doesn't create or require any special directory.

For untrusted/server deployments, pass --disable-file-reference to reject local data.url file references entirely, accepting only inline data.values. Reads stay read-only either way — the server never writes your data.

backend is one of vegalite, echarts, chartjs. The chartjs backend renders PNG only (its engine has no SVG output).

Install / run

Zero-install via npx:

npx -y flint-chart-mcp

MCP client config

{
  "mcpServers": {
    "flint": {
      "command": "npx",
      "args": ["-y", "flint-chart-mcp"]
    }
  }
}

To disable local file references (accept only inline data.values — useful for untrusted/server deployments), pass --disable-file-reference:

{
  "mcpServers": {
    "flint": {
      "command": "npx",
      "args": ["-y", "flint-chart-mcp", "--disable-file-reference"]
    }
  }
}

Works with Claude Desktop, Cursor, VS Code, and any MCP client that speaks stdio.

CLI options

--transport <stdio>   Transport (only "stdio" is supported). Default: stdio.
--backends <list>     Comma-separated subset of vegalite,echarts,chartjs.
                      Overridden by FLINT_MCP_BACKENDS if set.
--disable-file-reference
                      Reject local data.url file references; accept only inline
                      data.values. When unset, any local file the agent
                      references is readable (relative paths resolve against the
                      working directory). Also enabled by
                      FLINT_MCP_DISABLE_FILE_REFERENCE.
--data-roots <list>   Deprecated and ignored. Local files are readable by default.
--data-root <dir>     Deprecated and ignored. Local files are readable by default.
-v, --version         Print version.
-h, --help            Print help.

Gate the exposed backends at deploy time:

FLINT_MCP_BACKENDS=vegalite,echarts npx -y flint-chart-mcp

Local data.url files are readable by default. To harden an untrusted deployment, reject local file references and accept only inline rows:

npx -y flint-chart-mcp --disable-file-reference

Local file compile (flint-chart)

Compile a saved ChartAssemblyInput JSON to SVG or PNG without an agent:

flint-chart compile chart.json --format svg
flint-chart compile chart.json --backend echarts --format png --output chart.png
cat chart.json | flint-chart compile - --format svg > chart.svg
flint-chart chart.json --format svg --output chart.svg   # shorthand, compile is optional

Options: --backend <vegalite|echarts|chartjs> (default vegalite), --format <png|svg> (default svg except chartjs → png), --output <path> / -o <path> (- for stdout; default <input>.<format> next to input, stdout when input is -), --scale <0.5–4>, --background <color>, -h/--help, -v/--version.

Relative data.url paths in the input resolve against the input file's directory, or the current working directory when reading from stdin (-).

Example render_chart call

{
  "name": "render_chart",
  "arguments": {
    "data": {
      "values": [
        { "region": "North", "revenue": 120 },
        { "region": "South", "revenue": 90 },
        { "region": "East",  "revenue": 150 }
      ]
    },
    "semantic_types": { "region": "Category", "revenue": "Quantity" },
    "chart_spec": {
      "chartType": "Bar Chart",
      "encodings": { "x": { "field": "region" }, "y": { "field": "revenue" } },
      "baseSize": { "width": 360, "height": 240 }
    },
    "backend": "vegalite",
    "format": "png"
  }
}

The response contains the PNG inline (MCP ImageContent, base64) plus a short note with the artifact size and any assembly warnings.

Programmatic rendering

The in-process render core is also importable, so build scripts and tools can reuse one shared SSR recipe:

import { renderChart } from 'flint-chart-mcp/render';

const { buffer, warnings } = await renderChart(input, 'echarts', { format: 'png', scale: 2 });

How it renders (in-process, no browser)

  • Vega-Lite → compile to Vega → headless vega.View → SVG → (PNG via @resvg/resvg-js).
  • ECharts → server-side SVG rendering → (PNG via resvg).
  • Chart.js → @napi-rs/canvas → PNG (no SVG engine).

Bundled Liberation Sans faces are registered for server-side text measurement and rasterization, with DejaVu Sans available as a broad Unicode fallback. Flint's computed width/height (its stretch-layout result) is applied so the semantic layout shows up in the artifact.

Security & limits

  • No remote upload. All rendering is in-process; data stays on the host.
  • Read-only file access. data.url reads local .json, .csv, or .tsv files only — the server never writes your data. By default it trusts the agent's host for which files are readable (the agent could already inline the same rows); use --disable-file-reference to reject local file references in untrusted deployments. Remote URLs are disabled to avoid SSRF.
  • DoS guards. Row count, file size, and canvas dimensions are capped for hostile specs.

Development

npm install            # from the repo root (workspaces)
npm run build:mcp      # build this package (requires flint-js built first)
npm run test:mcp       # run the test suite

License

MIT © Microsoft Corporation