ECharts ChartPage MCP Server
Generates complete single-file HTML chart pages powered by Apache ECharts, converting structured JSON data, visualization goals, and field mappings into safe, runnable visualizations with controlled option generation and strong validation.
Provides programmatic access to chart generation capabilities through an npm package, enabling developers to integrate chart generation into their TypeScript/JavaScript applications with a structured API for generating, recommending, validating, and patching chart pages.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ECharts ChartPage MCP Servergenerate a bar chart showing monthly sales for 2024"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ECharts ChartPage
echarts-chartpage is a TypeScript toolkit that turns structured JSON data, visualization goals, and field mappings into safe, runnable HTML chart pages powered by Apache ECharts.
It ships as:
an npm package for programmatic use
a CLI for local automation
an MCP server for agent workflows
The project is designed for deterministic output, controlled option generation, strong validation, and public open-source maintainability.
Features
Generate complete single-file HTML chart pages with Apache ECharts CDN included
Depend on the official
echartsnpm package in source code for types and integration correctnessAccept structured data plus
goal,theme, and field mapping inputRecommend safe chart types from a controlled whitelist
Build controlled ECharts options without arbitrary JS formatter injection
Validate schema, field mappings, chart compatibility, and generated HTML basics
Patch existing chart specs and regenerate output
Reuse one shared core across npm API, CLI, and MCP server
Ship with tests, CI, examples, contribution docs, and release-ready packaging
Supported Goals
trendcomparecompositiondistributionrankingcorrelation
Supported Chart Types
linebarstacked_barpiedonutscatterareatable
Installation
npm install echarts-chartpageFor local development:
npm installQuick Start
CLI
npx echarts-chartpage generate \
--input examples/inputs/line-chart.json \
--output revenue-trend.htmlnpm API
import { generateChartPage } from "echarts-chartpage";
const result = generateChartPage({
title: "Monthly Revenue Trend",
goal: "trend",
theme: "light",
outputMode: "single_html",
data: [
{ month: "2025-01", revenue: 120 },
{ month: "2025-02", revenue: 132 },
{ month: "2025-03", revenue: 148 }
],
fields: {
x: "month",
y: "revenue"
}
});
console.log(result.chartType);
console.log(result.html);MCP Server
Build first, then start the stdio server:
npm run build
npm run mcp:startInput Model
type GenerateChartPageInput = {
title: string;
description?: string;
goal: "trend" | "compare" | "composition" | "distribution" | "ranking" | "correlation";
data: Array<Record<string, string | number | boolean | null>>;
fields: {
x: string;
y: string | string[];
series?: string;
category?: string;
};
theme?: "light" | "dark";
outputMode?: "single_html";
chartType?: "line" | "bar" | "stacked_bar" | "pie" | "donut" | "scatter" | "area" | "table";
};Output
generateChartPage() returns:
normalized spec
resolved chart type
warnings
controlled ECharts option or
nullfor table fallbackcomplete runnable HTML
CLI Usage
The CLI binary name is echarts-chartpage.
generate
Generate a single HTML page from JSON input:
echarts-chartpage generate \
--input examples/inputs/line-chart.json \
--output examples/generated/line-chart.htmlrecommend
Recommend a chart type:
echarts-chartpage recommend \
--input examples/inputs/bar-chart.jsonvalidate
Validate input and optionally validate generated HTML:
echarts-chartpage validate \
--input examples/inputs/pie-chart.json \
--html examples/generated/pie-chart.htmlpatch
Patch a base chart spec and regenerate HTML:
echarts-chartpage patch \
--base examples/inputs/patch-base.json \
--patch examples/inputs/patch-update.json \
--output examples/generated/patch-example.htmlMCP Usage
The server exposes these tools:
recommend_chart_typegenerate_chart_pagevalidate_chart_pagepatch_chart_page
All tool inputs and outputs are structured JSON. A typical MCP client configuration points to the built stdio server:
{
"mcpServers": {
"echarts-chartpage": {
"command": "node",
"args": ["dist/mcp/server.js"]
}
}
}See examples/mcp-usage.md for request payload samples.
Programming API
Public API surface:
generateChartPagerecommendChartTypevalidateChartInputvalidateChartPageRequestvalidateGeneratedHtmlpatchChartPagebuildChartOptionbuildChartHtml
Runtime schemas are exported as well:
generateChartPageInputSchemapatchChartPageChangesSchemapatchChartPageInputSchemavalidateChartPageInputSchema
Input / Output Example
Input:
{
"title": "Traffic Source Mix",
"goal": "composition",
"theme": "light",
"outputMode": "single_html",
"data": [
{ "source": "Organic", "sessions": 4200 },
{ "source": "Paid", "sessions": 2100 },
{ "source": "Referral", "sessions": 1100 }
],
"fields": {
"x": "source",
"y": "sessions",
"category": "source"
}
}Output summary:
{
"chartType": "donut",
"warnings": [],
"html": "<!doctype html>..."
}Examples
The repository includes:
Generate all example HTML files with:
npm run examples:generateGenerated HTML files are written to examples/generated/.
Agent Skill
This repository also includes a reusable Codex-style skill for agents that need to call the MCP server consistently:
It documents:
when to trigger this MCP
how to choose among recommend / validate / generate / patch
structured calling rules
few-shot examples for model prompting
Install the bundled skill into the local Codex skill directory with:
npm run build
npm run skill:installArchitecture
Project layout:
src/
core/
chart-recommender.ts
option-builder.ts
html-builder.ts
validator.ts
patcher.ts
generator.ts
cli/
index.ts
commands/
mcp/
server.ts
schemas/
types/
utils/Design rules:
core logic is shared across all interfaces
output is controlled and deterministic
no arbitrary formatter functions are accepted
only whitelisted chart types are emitted
dataset + encode is preferred where practical
See also:
Development Commands
npm install
npm run lint
npm run typecheck
npm run test
npm run build
npm run examples:generateBuild Command
npm run buildOutputs are emitted to dist/.
Test Command
npm run testPublish Notes
Before publishing:
Update repository URLs in
package.json.Ensure the npm account
daqiang901003is authenticated on the publishing machine.Review the
CHANGELOG.md.Run
npm run verify.Publish with
npm publish.
The package is configured with:
exportsgenerated
.d.tsbinfilesESM-first output with CommonJS compatibility
Roadmap
richer ranking-specific sorting controls
dashboard-oriented multi-panel HTML templates
more chart recommendation heuristics
configurable design presets
richer MCP metadata and traces
FAQ
Does this execute arbitrary user JavaScript?
No. The generator does not accept arbitrary formatter functions, script fragments, or custom JS injection.
Why does some input fall back to table?
The builder uses a conservative whitelist. If mappings or data types are incompatible with a controlled chart output, it falls back to a stable table rendering.
Does the generated HTML need a build step?
No. It is a single HTML file intended to open directly in the browser.
Can I force a chart type?
Yes. Set chartType in the input. If the requested chart is incompatible with the data mapping, validation warnings are returned and generation can fall back to table.
Security
no arbitrary script injection
no arbitrary external JS injection beyond the fixed ECharts CDN
no formatter function injection
controlled HTML template shape
schema validation before generation
This project is intended for trusted structured data pipelines. If you accept untrusted input from external users, validate and sanitize it at your own boundary as well.
For the full repository policy, see SECURITY.md.
ECharts Integration Note
This project uses ECharts in two places:
source code depends on the official
echartsnpm package for typed option generationgenerated HTML uses the fixed Apache ECharts CDN runtime so the output file can open directly in a browser without a bundler
Contributing
See CONTRIBUTING.md.
License
MIT. See LICENSE.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/RiverThrimp/echarts-chartpage'
If you have feedback or need assistance with the MCP directory API, please join our Discord server