|
| 1 | +# <img src="https://echarts.apache.org/zh/images/favicon.png" height="24"/> MCP ECharts  [](https://github.com/hustcc/mcp-echarts/actions/workflows/build.yml) [](https://www.npmjs.com/package/mcp-echarts) [](https://smithery.ai/server/@hustcc/mcp-echarts) [](https://www.npmjs.com/package/mcp-echarts) [](https://archestra.ai/mcp-catalog/hustcc__mcp-echarts) |
| 2 | + |
| 3 | +Generate <img src="https://echarts.apache.org/zh/images/favicon.png" height="14"/> [Apache ECharts](https://echarts.apache.org/) with AI MCP dynamically for chart generation and data analysis. _Also you can use <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*ZFK8SrovcqgAAAAAAAAAAAAAemJ7AQ/original" height="14"/> [mcp-server-chart](https://github.com/antvis/mcp-server-chart) to generate chart, graph, map._ |
| 4 | + |
| 5 | +<a href="https://glama.ai/mcp/servers/@hustcc/mcp-echarts"> |
| 6 | + <img width="380" height="200" src="https://glama.ai/mcp/servers/@hustcc/mcp-echarts/badge" alt="ECharts MCP server" /> |
| 7 | +</a> |
| 8 | + |
| 9 | +<div align="center"> |
| 10 | + <img width="648" alt="mcp-echarts" src="https://mdn.alipayobjects.com/huamei_1gdzij/afts/img/A*s3w3SpMMPDQAAAAARzAAAAgAemB7AQ/original" /> |
| 11 | +</div> |
| 12 | + |
| 13 | +## ✨ Features |
| 14 | + |
| 15 | +- Fully support all features and syntax of `ECharts`, include data, style, theme and so on. |
| 16 | +- Support exporting to `png`, `svg`, and `option` formats, with validation for `ECharts` to facilitate the model's multi-round output of correct syntax and graphics. |
| 17 | +- MinIO Integration, store charts in `MinIO` object storage and return URLs instead of Base64 data for better performance and sharing capabilities. |
| 18 | +- Lightweight, we can install it easily with `zero dependence`. |
| 19 | +- Extremely `secure`, fully generated locally, without relying on any remote services. |
| 20 | + |
| 21 | + |
| 22 | +## 🤖 Usage |
| 23 | + |
| 24 | +### Desktop Applications (stdio transport) |
| 25 | + |
| 26 | +To use with `Desktop APP`, such as Claude, VSCode, Cline, Cherry Studio, and so on, add the MCP server config below. On Mac system: |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "mcpServers": { |
| 31 | + "mcp-echarts": { |
| 32 | + "command": "npx", |
| 33 | + "args": [ |
| 34 | + "-y", |
| 35 | + "mcp-echarts" |
| 36 | + ] |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +On Window system: |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "mcpServers": { |
| 47 | + "mcp-echarts": { |
| 48 | + "command": "cmd", |
| 49 | + "args": [ |
| 50 | + "/c", |
| 51 | + "npx", |
| 52 | + "-y", |
| 53 | + "mcp-echarts" |
| 54 | + ] |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +Also, you can use it on [modelscope](https://www.modelscope.cn/mcp/servers/hustcc/MCP-ECharts), [glama.ai](https://glama.ai/mcp/servers/@hustcc/mcp-echarts), [smithery.ai](https://smithery.ai/server/@hustcc/mcp-echarts) or others with HTTP, SSE Protocol. |
| 61 | + |
| 62 | + |
| 63 | +## 🚰 Run with SSE or Streamable transport |
| 64 | + |
| 65 | +Install the package globally. |
| 66 | + |
| 67 | +```bash |
| 68 | +npm install -g mcp-echarts |
| 69 | +``` |
| 70 | + |
| 71 | +Run the server with your preferred transport option: |
| 72 | + |
| 73 | +```bash |
| 74 | +# For SSE transport (default endpoint: /sse) |
| 75 | +mcp-echarts -t sse |
| 76 | + |
| 77 | +# For Streamable transport with custom endpoint |
| 78 | +mcp-echarts -t streamable |
| 79 | +``` |
| 80 | + |
| 81 | +Then you can access the server at: |
| 82 | +- SSE transport: `http://localhost:3033/sse` |
| 83 | +- Streamable transport: `http://localhost:3033/mcp` |
| 84 | + |
| 85 | + |
| 86 | +## 🎮 CLI Options |
| 87 | + |
| 88 | +You can also use the following CLI options when running the MCP server. Command options by run cli with `-h`. |
| 89 | + |
| 90 | +```plain |
| 91 | +MCP ECharts CLI |
| 92 | +
|
| 93 | +Options: |
| 94 | + --transport, -t Specify the transport protocol: "stdio", "sse", or "streamable" (default: "stdio") |
| 95 | + --port, -p Specify the port for SSE or streamable transport (default: 3033) |
| 96 | + --endpoint, -e Specify the endpoint for the transport: |
| 97 | + - For SSE: default is "/sse" |
| 98 | + - For streamable: default is "/mcp" |
| 99 | + --help, -h Show this help message |
| 100 | +``` |
| 101 | + |
| 102 | + |
| 103 | +## 🗂️ MinIO Configuration (Optional) |
| 104 | + |
| 105 | +For better performance and sharing capabilities, you can configure MinIO object storage to store chart images as URLs instead of Base64 data. |
| 106 | + |
| 107 | +> [!NOTE] |
| 108 | +> If MinIO is not configured or unavailable, the system automatically falls back to `Base64` data output, ensuring compatibility. |
| 109 | +
|
| 110 | +We can Integrate with `MinIO` object storage providers below. |
| 111 | + |
| 112 | + - [MinIO](https://min.io/): High-performance, S3-compatible object storage. Use [MinIO JavaScript Client](https://min.io/docs/minio/linux/developers/javascript/minio-javascript.html) for direct integration. |
| 113 | + - [Amazon S3](https://aws.amazon.com/s3/): Use [AWS SDK](https://aws.amazon.com/sdk-for-javascript/) with compatible API endpoint. |
| 114 | + - [Alibaba Cloud OSS](https://www.alibabacloud.com/product/object-storage-service): Use the [Alibaba Cloud SDK](https://www.alibabacloud.com/help/en/sdk) for OSS services. |
| 115 | + - [Google Cloud Storage](https://cloud.google.com/storage): Integrate using [Google Cloud SDK](https://cloud.google.com/sdk) or compatible API. |
| 116 | + - [Microsoft Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs): Use [Azure SDK](https://azure.microsoft.com/en-us/downloads/) for Blob storage access. |
| 117 | + - [Tencent Cloud COS](https://intl.cloud.tencent.com/product/cos): Use the [Tencent Cloud SDK](https://intl.cloud.tencent.com/document/product/436/6474) for COS integration. |
| 118 | + |
| 119 | +Also, we can setup MinIO locally for free. |
| 120 | + |
| 121 | +1. **Install and start MinIO locally:** |
| 122 | + |
| 123 | + ```bash |
| 124 | + # Download MinIO (macOS example) |
| 125 | + brew install minio/stable/minio |
| 126 | + |
| 127 | + # Start MinIO server |
| 128 | + minio server ~/minio-data --console-address :9001 |
| 129 | + ``` |
| 130 | + |
| 131 | +3. **Configure environment variables:** |
| 132 | + |
| 133 | + ```bash |
| 134 | + # Copy the example environment file |
| 135 | + cp .env.example .env |
| 136 | + |
| 137 | + # Edit .env with your MinIO settings |
| 138 | + MINIO_ENDPOINT=localhost |
| 139 | + MINIO_PORT=9000 |
| 140 | + MINIO_USE_SSL=false |
| 141 | + MINIO_ACCESS_KEY=minioadmin |
| 142 | + MINIO_SECRET_KEY=minioadmin |
| 143 | + MINIO_BUCKET_NAME=mcp-echarts |
| 144 | + ``` |
| 145 | + |
| 146 | + |
| 147 | +## 🔨 Development |
| 148 | + |
| 149 | +Install dependencies: |
| 150 | + |
| 151 | +```bash |
| 152 | +npm install |
| 153 | +``` |
| 154 | + |
| 155 | +Build the server: |
| 156 | + |
| 157 | +```bash |
| 158 | +npm run build |
| 159 | +``` |
| 160 | + |
| 161 | +Start the MCP server: |
| 162 | + |
| 163 | +```bash |
| 164 | +npm run start |
| 165 | +``` |
| 166 | + |
| 167 | + |
| 168 | +## 🧑🏻💻 Contributors |
| 169 | + |
| 170 | +- [lyw405](https://github.com/lyw405): Supports `15+` charting MCP tool. [#2](https://github.com/hustcc/mcp-echarts/issues/2) |
| 171 | +- [2niuhe](https://github.com/2niuhe): Support MCP with SSE and Streaming HTTP. [#17](https://github.com/hustcc/mcp-echarts/issues/17) |
| 172 | +- [susuperli](https://github.com/susuperli): Use `MinIO` to save the chart image base64 and return the url. [#10](https://github.com/hustcc/mcp-echarts/issues/10) |
| 173 | +- [BQXBQX](https://github.com/BQXBQX): Use `@napi-rs/canvas` instead node-canvas. [#3](https://github.com/hustcc/mcp-echarts/issues/3) |
| 174 | +- [Meet-student](https://github.com/Meet-student): Add `outputType` schema for all chart tools. [#24](https://github.com/hustcc/mcp-echarts/issues/24) |
| 175 | +- [hustcc](https://github.com/hustcc): Initial the repo. |
| 176 | + |
| 177 | + |
| 178 | +## 📄 License |
| 179 | + |
| 180 | +MIT@[hustcc](https://github.com/hustcc). |
0 commit comments