数据可视化MCP服务器
概述
一个Model Context Protocol(MCP)服务器实现,为LLM提供使用Vega-Lite语法可视化数据的接口。
组件
工具
服务器提供两个核心工具:
save_data- 将数据聚合表保存到服务器以供后续可视化
- 输入:
name(字符串): 要保存的数据表名称data(数组): 表示数据表的对象数组
- 返回:成功消息
visualize_data- 使用Vega-Lite语法可视化数据表
- 输入:
data_name(字符串): 要可视化的数据表名称vegalite_specification(字符串): 表示Vega-Lite规范的JSON字符串
- 返回:如果
--output_type设置为text,则返回包含完整Vega-Lite规范(含数据)的成功消息,并附加artifact键。如果--output_type设置为png,则返回使用MPCImageContent容器的可视化PNG图像的base64编码。
与Claude Desktop的配合使用
# 将服务器添加到您的claude_desktop_config.json
{
"mcpServers": {
"datavis": {
"command": "uv",
"args": [
"--directory",
"/绝对路径/to/mcp-datavis-server",
"run",
"mcp_server_datavis",
"--output_type",
"png" # 或 "text"
]
}
}
}
