图表生成工具

MCP ECharts是一个基于Apache ECharts的动态图表生成和数据分析工具,支持多种导出格式和MinIO集成。

作者 By hustcc
本地部署 图表生成 数据分析
GitHub

MCP心电图

生成 阿帕奇ECharts 使用AI MCP动态生成图表和数据分析。 你也可以使用 mcp服务器图表 生成图表、图形、地图。

mcp-echarts

award

✨ 特性

  • 完全支持的所有功能和语法 ECharts,包括数据、风格、主题等。
  • 支持导出到 png, svg,以及 option 格式,带有验证 ECharts 以促进模型多轮输出正确的语法和图形。
  • MinIO集成,将图表存储在 MinIO 对象存储和返回URL,而不是Base64数据,以获得更好的性能和共享功能。
  • 重量轻,我们可以很容易地安装它 zero dependence.
  • 极其 secure,完全在本地生成,不依赖任何远程服务。

🤖 用法

先决条件

  • 需要Node.js 18或更高版本。

桌面应用程序(stdio传输)

与一起使用 Desktop APP,如Claude、VSCode、Cline、Cherry Studio等,在下面添加MCP服务器配置。在Mac系统上:

JSON``` 1 2 3 4 5 6 7 8 9 10 11{ “mcpServers”: { “mcp-echarts”: { “command”: “npx”, “args”: [ “-y”, “mcp-echarts” ] } } }


On Window系统:


JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13{
  "mcpServers": {
    "mcp-echarts": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "mcp-echarts"
      ]
    }
  }
}

此外,您还可以在 魔搭, glama.ai, 史密斯艾 或使用HTTP、SSE协议的其他协议。

🚰 使用SSE或流媒体传输运行

全局安装该软件包。

BASH``` 1npm install -g mcp-echarts


使用首选传输选项运行服务器:


BASH```
1
2
3
4# For SSE transport (default endpoint: /sse)
mcp-echarts -t sse
# For Streamable transport with custom endpoint
mcp-echarts -t streamable

然后,您可以访问服务器:

  • SSE运输: http://localhost:3033/sse
  • 可流动运输: http://localhost:3033/mcp

🎮 CLI选项

运行MCP服务器时,您还可以使用以下CLI选项。使用run-cli命令选项 -h.

PLAIN``` 1 2 3 4 5 6 7 8MCP ECharts CLI Options: —transport, -t Specify the transport protocol: “stdio”, “sse”, or “streamable” (default: “stdio”) —port, -p Specify the port for SSE or streamable transport (default: 3033) —endpoint, -e Specify the endpoint for the transport: - For SSE: default is “/sse” - For streamable: default is “/mcp” —help, -h Show this help message


## 🗂️ MinIO配置(可选)


为了获得更好的性能和共享功能,您可以将MinIO对象存储配置为将图表图像存储为URL,而不是Base64数据。


> [!注意]
> 如果MinIO未配置或不可用,系统会自动回退到 `Base64` 数据输出,确保兼容性。


我们可以与 `MinIO` 下面是对象存储提供程序。


- [MinIO](https://min.io/):高性能、兼容S3的对象存储。使用 [MinIO JavaScript客户端](https://docs.min.io/enterprise/aistor-object-store/developers/sdk/javascript/) 直接整合。
- [亚马逊S3](https://aws.amazon.com/s3/):使用 [AWS SDK](https://aws.amazon.com/sdk-for-javascript/) 具有兼容的API端点。
- [阿里云OSS](https://www.alibabacloud.com/product/object-storage-service):使用 [阿里云SDK](https://www.alibabacloud.com/help/en/sdk) OSS服务。
- [谷歌云存储](https://cloud.google.com/storage):集成使用 [谷歌云SDK](https://cloud.google.com/sdk) 或兼容的API。
- [Microsoft Azure Blob存储](https://azure.microsoft.com/en-us/products/storage/blobs):使用 [Azure SDK](https://azure.microsoft.com/en-us/downloads/) 用于Blob存储访问。
- [腾讯云COS](https://intl.cloud.tencent.com/product/cos):使用 [腾讯云SDK](https://intl.cloud.tencent.com/document/product/436/6474) COS集成。


此外,我们可以在本地免费设置MinIO。


1. **在本地安装并启动MinIO:**


BASH```
1
2
3
4# Download MinIO (macOS example)
brew install minio/stable/minio
# Start MinIO server
minio server ~/minio-data --console-address :9001
  1. 配置环境变量:

BASH``` 1 2 3 4 5 6 7 8 9# Copy the example environment file cp .env.example .env

Edit .env with your MinIO settings

MINIO_ENDPOINT=localhost MINIO_PORT=9000 MINIO_USE_SSL=false MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_BUCKET_NAME=mcp-echarts



## 🔨 发展


安装依赖项:


BASH```
1npm install

构建服务器:

BASH``` 1npm run build


启动MCP服务器:


BASH```
1npm run start

🧑🏻‍💻 贡献者

  • 谎言405:支持 15+ 图表MCP工具。 #2
  • 2个:支持带SSE和流式HTTP的MCP。 #17
  • 苏苏佩里:使用 MinIO 保存图表图像base64并返回url。 #10
  • BQXBQX:使用 @napi-rs/canvas 而是节点画布。 #3
  • 认识学生:添加 outputType 所有图表工具的模式。 #24
  • hustcc:初始化回购。

📄 许可证

麻省理工学院@hustcc.