Skip to main content
Glama

Graphistry MCP 集成

使用 Graphistry 和 MCP 对大型语言模型进行 GPU 加速图形可视化和分析。

概述

该项目将 Graphistry 强大的 GPU 加速图形可视化平台与模型控制协议 (MCP) 相集成,为 AI 助手和法学硕士 (LLM) 提供高级图形分析功能。它使法学硕士 (LLM) 能够通过标准化、LLM 友好的界面可视化和分析复杂的网络数据。

主要特点:

  • 通过 Graphistry 实现 GPU 加速的图形可视化

  • 高级模式发现和关系分析

  • 网络分析(社区检测、中心性、路径查找、异常检测)

  • 支持各种数据格式(Pandas、NetworkX、边列表)

  • LLM 友好 API:用于图形工具的单个graph_data字典

Related MCP server: Data Visualization MCP Server

🚨重要提示:Graphistry 需要注册

此 MCP 服务器需要一个免费的 Graphistry 帐户才能使用可视化功能。

  1. hub.graphistry.com注册免费账户

  2. 在启动服务器之前,将您的凭据设置为环境变量或.env文件:

    export GRAPHISTRY_USERNAME=your_username export GRAPHISTRY_PASSWORD=your_password # or create a .env file with: # GRAPHISTRY_USERNAME=your_username # GRAPHISTRY_PASSWORD=your_password

    请参阅.env.example了解模板。

MCP 配置 (.mcp.json)

要将此项目与 Cursor 或其他 MCP 兼容工具一起使用,您需要在项目根目录中创建一个.mcp.json文件。模板文件为.mcp.json.example

设置:

cp .mcp.json.example .mcp.json

编辑.mcp.json如下:

  • 为您的环境设置正确的路径(例如,项目根目录、Python 可执行文件、服务器脚本)

  • 设置您的 Graphistry 凭证(或使用环境变量/.env)

  • 在 HTTP 和 stdio 模式之间进行选择:

    • graphistry-http :通过 HTTP 连接(设置url以匹配服务器的端口)

    • graphistry :通过 stdio 连接(根据需要设置commandargsenv

笔记:

  • .mcp.json.example包含 HTTP 和 stdio 配置。您可以根据需要通过设置disabled字段来启用/禁用它们。

  • 请参阅.env.example了解环境变量设置。

安装

推荐安装(Python venv + pip)

# Clone the repository git clone https://github.com/graphistry/graphistry-mcp.git cd graphistry-mcp # Set up virtual environment and install dependencies python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]" # Set up your Graphistry credentials (see above)

或者使用安装脚本:

./setup-graphistry-mcp.sh

用法

启动服务器

# Activate your virtual environment if not already active source .venv/bin/activate # Start the server (stdio mode) python run_graphistry_mcp.py # Or use the start script for HTTP or stdio mode (recommended, sources .env securely) ./start-graphistry-mcp.sh --http 8080

安全和凭证处理

  • 服务器使用python-dotenv从环境变量或.env加载凭据,因此您可以安全地使用.env文件进行本地开发。

  • start-graphistry-mcp.sh脚本源.env并且是启动服务器最强大、最安全的方式。

添加到 Cursor(或其他 LLM 工具)

  • 将 MCP 服务器添加到您的.cursor/mcp.json或等效配置中:

    { "graphistry": { "command": "/path/to/your/.venv/bin/python", "args": ["/path/to/your/run_graphistry_mcp.py"], "env": { "GRAPHISTRY_USERNAME": "your_username", "GRAPHISTRY_PASSWORD": "your_password" }, "type": "stdio" } }
  • 确保使用虚拟环境(通过使用 venv 的 python 的完整路径,或在启动之前激活它)。

  • 如果您看到有关 API 版本或缺少凭据的错误,请仔细检查您的环境变量和注册。

示例:可视化图形(LLM 友好 API)

主工具visualize_graph现在接受单个graph_data字典。例如:

{ "graph_data": { "graph_type": "graph", "edges": [ {"source": "A", "target": "B"}, {"source": "A", "target": "C"}, {"source": "A", "target": "D"}, {"source": "A", "target": "E"}, {"source": "B", "target": "C"}, {"source": "B", "target": "D"}, {"source": "B", "target": "E"}, {"source": "C", "target": "D"}, {"source": "C", "target": "E"}, {"source": "D", "target": "E"} ], "nodes": [ {"id": "A"}, {"id": "B"}, {"id": "C"}, {"id": "D"}, {"id": "E"} ], "title": "5-node, 10-edge Complete Graph", "description": "A complete graph of 5 nodes (K5) where every node is connected to every other node." } }

示例(超图):

{ "graph_data": { "graph_type": "hypergraph", "edges": [ {"source": "A", "target": "B", "group": "G1", "weight": 0.7}, {"source": "A", "target": "C", "group": "G1", "weight": 0.6}, {"source": "B", "target": "C", "group": "G2", "weight": 0.8}, {"source": "A", "target": "D", "group": "G2", "weight": 0.5} ], "columns": ["source", "target", "group"], "title": "Test Hypergraph", "description": "A simple test hypergraph." } }

可用的 MCP 工具

以下 MCP 工具可用于图形可视化、分析和操作:

  • visualize_graph :使用 Graphistry 的 GPU 加速渲染器可视化图形或超图。

  • get_graph_ids :列出当前会话中所有存储的图形 ID。

  • get_graph_info :获取存储图的元数据(节点/边数、标题、描述)。

  • apply_layout :将标准布局(force_directed、radial、circle、grid)应用于图形。

  • detect_patterns :运行网络分析(中心性、社区检测、路径查找、异常检测)。

  • encode_point_color :按列设置节点颜色编码(分类或连续)。

  • encode_point_size :按列设置节点大小编码(分类或连续)。

  • encode_point_icon :按列设置节点图标编码(分类,带有图标映射或分箱)。

  • encode_point_badge :按列设置节点徽章编码(分类,带有图标映射或分箱)。

  • apply_ring_categorical_layout :按分类列(例如,组/类型)排列环中的节点。

  • apply_group_in_a_box_layout :以组内框布局排列节点(需要 igraph)。

  • apply_modularity_weighted_layout :按模块化加权布局排列节点(需要 igraph)。

  • apply_ring_continuous_layout :按连续列(例如分数)排列环中的节点。

  • apply_time_ring_layout :按日期时间列(例如,created_at)排列环中的节点。

  • apply_tree_layout :以树状(分层层次)布局排列节点。

  • set_graph_settings :设置高级可视化设置(点大小、边缘影响等)。

贡献

欢迎提交 PR 和问题!随着我们对 LLM 驱动的图形分析和工具集成的了解越来越多,这个项目正在快速发展。

执照

麻省理工学院

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/graphistry/graphistry-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server