QuickChart MCP Server for Dynamic Chart Generation
Generate dynamic charts with the QuickChart MCP server using QuickChart.io for real-time, customizable chart rendering via Model Context Protocol.
npx -y @GongRzhe/Quickchart-MCP-ServerOverview
The QuickChart MCP Server is a small web service that exposes QuickChart.io chart rendering through the Model Context Protocol (MCP). It lets language models or other agents request on-demand chart images by sending structured chart configurations (Chart.js options) rather than handcrafting URLs or embedding plotting libraries. The server translates MCP tool calls into QuickChart API requests, returning image URLs or base64-encoded PNGs suitable for embedding in chat responses, notebooks, or dashboards.
This approach is useful when you want programmatic, real-time chart generation as part of an LLM-driven workflow: let the model decide chart types and configuration, then render high-quality charts without shipping a full charting stack to the runtime environment. The server is lightweight, configurable, and intended to be used as an MCP-compatible tool endpoint for model integrations.
Features
- Exposes QuickChart.io rendering as an MCP tool for model-driven workflows
- Accepts Chart.js configuration objects and renders PNG/SVG/other formats
- Returns shareable image URLs or base64 image data
- Configurable image size, background, and format parameters
- Optional caching, size limits, and simple access control via environment variables
- Small Node.js/Express implementation that is easy to deploy and extend
Installation / Configuration
Prerequisites:
- Node.js 16+ and npm
- Optional: QuickChart account or proxy URL (QuickChart.io supports public access, but you can self-host or use a private proxy)
Quick start (typical Node.js example):
# Clone the repository
# Install dependencies
# Create .env (see table below for variables)
# edit .env as needed
# Start the server
# or for development
Environment variables (example .env):
PORT=8080
QUICKCHART_BASE_URL=https://quickchart.io/chart
CACHE_TTL_SECONDS=60
MAX_CHART_PIXELS=2000000
ALLOW_BASE64=false
API_KEY= # optional if you use a private QuickChart instance
Common package.json scripts:
Environment variables reference:
| Name | Default | Purpose |
|---|---|---|
| PORT | 8080 | HTTP port to listen on |
| QUICKCHART_BASE_URL | https://quickchart.io/chart | QuickChart rendering endpoint |
| CACHE_TTL_SECONDS | 60 | Optional cache TTL for generated images |
| MAX_CHART_PIXELS | 2000000 | Safety limit on width*height |
| ALLOW_BASE64 | false | Whether to allow returning base64 image blobs |
| API_KEY | (empty) | Optional API key for private QuickChart instances |
Available Tools / Resources
The server exposes a Tool Manifest (MCP-compatible) and an invocation endpoint. Example endpoints:
- GET /mcp/tool-manifest — returns the MCP tool manifest describing input schema and usage
- POST /mcp/invoke — accepts a JSON payload describing the requested chart and returns a rendering result
Example tool manifest (simplified):
Invocation response example:
If ALLOW_BASE64 is enabled, the server can optionally return a base64-encoded PNG in the “b64” field for direct embedding.
Use Cases
Embedding charts in LLM-generated reports: A model can generate Chart.js configuration as part of its reasoning, call the MCP tool to render the chart, and insert a chart image into its reply.
- Example: Generate a bar chart comparing quarterly revenue and return a URL to embed in a Markdown report.
Dynamic dashboards for conversational agents: Agents can render updated visualizations on user requests (e.g., “Show the last 7 days of active users”) by producing the Chart.js config and calling the tool to get a fresh image.
Automated emails or reports: Scheduled jobs produce the required chart config and call the MCP server to create images for PDF or HTML reports.
Prototyping and rapid visualization in notebooks: Use the server to quickly render sample charts without installing Chart.js locally. Return base64 images for inline display.
Concrete example: POST payload to /mcp/invoke:
Expected minimal response:
Notes and Best Practices
- Validate Chart.js config on the client or server side to avoid malformed requests. The server enforces pixel limits and other safety checks to prevent abuse.
- Use caching for repeated identical charts to reduce rendering costs and latency.
- If you require stronger access control, put the MCP server behind an authenticated gateway or add token checks in the server code.
- Keep QuickChart usage within its terms of service. If you need high throughput or private rendering, consider hosting a QuickChart instance or proxy.
Links and Resources
- QuickChart: https://quickchart.io
- Model Context Protocol (MCP): follow your platform’s MCP spec for tool manifests and invocation formats
- Source code: https://github.com/GongRzhe/Quickchart-MCP-Server
This server is intended as a simple, extensible bridge between model-driven workflows and programmatic chart rendering. It provides a practical pattern for producing figures from model outputs with minimal client-side complexity.