EChart Server
A Go service that dynamically generates ECharts chart pages from JSON configurations.
mcp-server-echart
一个基于 mcp-go 框架构建的 Go 服务,它提供了一个能动态生成 ECharts 图表页面的工具。
✨ 功能特性
- 动态图表生成:通过调用工具,传入 ECharts 的 JSON 配置,即可生成一个独立的 HTML 图表页面。
- 高度可配置:支持自定义图表的标题、宽度和高度。
- 现代化页面:生成的图表页面拥有一个干净、现代化的外观。
- Docker 支持:提供
Dockerfile,可以轻松构建轻量、可移植的 Docker 镜像。 - 配置灵活:通过环境变量或
.env文件进行配置,轻松适配不同环境。
🚀 快速开始
1. 准备工作
2. 克隆与配置
克隆本仓库到您的本地:
git clone https://github.com/cnkanwei/mcp-server-echart.git
cd mcp-server-echart
复制配置文件模板,并根据需要进行修改:
cp .env.example .env
.env 文件包含以下配置项:
PORT: 服务监听的端口 (默认:8989)PUBLIC_URL: 对外暴露的 URL 根路径 (例如http://localhost:8989或https://your.domain.com)LOG_LEVEL: 日志级别 (例如info,debug)STATIC_DIR: 生成的静态 HTML 文件存放的目录 (默认:static)
3. 安装依赖
go mod tidy
📦 如何运行
在本地运行
go run main.go
服务启动后,会监听在 .env 文件中配置的 PORT 端口(默认为 8989)。
使用 Docker 运行
-
构建 Docker 镜像:
docker build -t mcp-server-echart . -
运行 Docker 容器:
# 基础运行 docker run -p 8989:8989 -d --name my-echart-server mcp-server-echart # 自定义端口和对外 URL docker run -p 9090:9090 \ -e PORT=9090 \ -e PUBLIC_URL="https://my.domain.com" \ -d --name my-echart-server mcp-server-echart
🛠️ 工具 (Tool) API
本服务提供了一个名为 generate_echarts_page 的工具。
参数
title(string, 必需): 图表页面的标题。inputSchema(object, 必需): ECharts 的 JSON 配置对象。width(number, 可选): 图表的宽度(像素),默认 800。height(number, 可选): 图表的高度(像素),默认 600。
返回值
成功调用后,工具会返回一个 URL,指向新生成的图表页面。
💻 如何使用
本服务可以通过任何支持 Server-Sent Events (SSE) 的 MCP 客户端进行调用。
客户端配置
如果您使用的 MCP 客户端支持通过配置文件连接到服务器,您可以添加如下配置来连接到本服务。
请将 mcp-server-echart 添加到您的客户端配置中,并将 URL 指向本服务的监听地址(默认为 http://localhost:8989/sse)。
示例配置 (client-config.json):
{
"mcpServers": {
"mcp-server-echart": {
"url": "http://localhost:8989/sse"
}
}
}
另一个示例 (例如,用于浏览器环境):
{
"mcpServers": {
"browser-use-mcp-server": {
"url": "http://localhost:8000/sse"
}
}
}
注意:
- URL 应与您在
.env文件中配置的PORT和PUBLIC_URL保持一致。mcp-go工具调用的默认端点是/sse,而不是/。
客户端配置 (通过 Docker 命令)
如果您的 MCP 客户端支持通过命令启动服务,您也可以配置它来直接运行 Docker Hub 上的镜像。这会将服务作为一个子进程来管理,客户端通过标准输入/输出 (stdin/stdout) 与其通信。
这对于本地开发或将服务分发给他人使用非常方便。
示例配置 (client-config.json):
{
"mcpServers": {
"mcp-server-echart-docker": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-p",
"8989:8989",
"-e",
"PORT=8989",
"-e",
"PUBLIC_URL=http://localhost:8989",
"cnkanwei/mcp-server-echart:latest"
]
}
}
}
注意:
-p 8989:8989将容器的 8989 端口映射到主机的 8989 端口,以便您可以从浏览器访问生成的图表。cnkanwei/mcp-server-echart:latest是发布在 Docker Hub 上的公共镜像。
📜 许可证
本项目基于 MIT License 开源。
Server Terkait
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
shadcn/ui MCP
Provides context about shadcn/ui components, including structure, usage, and installation for React, Svelte, and Vue.
MCP Sandbox
Execute Python code and install packages safely within isolated Docker containers.
FLUX Image Generator
Generate images using Black Forest Lab's FLUX model.
Azure MCP Server
All Azure MCP tools in a single server. The Azure MCP Server implements the MCP specification to create a seamless connection between AI agents and Azure services. Azure MCP Server can be used alone or with the GitHub Copilot for Azure extension in VS Code.
Page Design Guide MCP Server
MCP server providing modern web design guidance, color psychology, typography, layout patterns, and UI best practices for AI assistants
TestDino MCP
A Model Context Protocol (MCP) server that connects TestDino to AI agents. This server enables you to interact with your TestDino test data directly through natural language commands.
ArchiveNet
A context insertion and search server for Claude Desktop and Cursor IDE, using configurable API endpoints.
Metasploit MCP Server
An MCP server for integrating with the Metasploit Framework, enabling payload generation and management.
MCP Docs Server
Provides direct access to local documentation files through a context.md file in the project root.
Symphony of One
An MCP server for orchestrating multiple Claude instances to collaborate in a shared workspace with real-time communication.