Skip to main content

Grasshopper MCP Bridge

Grasshopper MCP Bridge 是一個連接 Grasshopper 和 Claude Desktop 的橋接服務器,使用 Model Context Protocol (MCP) 標準協議。

功能特點

  • 通過 MCP 協議連接 Grasshopper 和 Claude Desktop
  • 提供直觀的工具函數,用於創建和連接 Grasshopper 組件
  • 支持高層次意圖識別,可以從簡單描述自動創建複雜的組件模式
  • 包含組件知識庫,了解常用組件的參數和連接規則
  • 提供組件指南資源,幫助 Claude Desktop 正確連接組件

系統架構

該系統由以下部分組成:

  1. Grasshopper MCP 組件 (GH_MCP.gha):安裝在 Grasshopper 中的插件,提供 TCP 服務器接收命令
  2. Python MCP 橋接服務器:連接 Claude Desktop 和 Grasshopper MCP 組件的橋接服務器
  3. 組件知識庫:包含組件信息、模式和意圖的 JSON 文件

安裝說明

前提條件

  • Rhino 7 或更高版本
  • Grasshopper
  • Python 3.8 或更高版本
  • Claude Desktop

安裝步驟

  1. 安裝 Grasshopper MCP 組件

    將 GH_MCP.gha 文件複製到 Grasshopper 組件文件夾:

    %APPDATA%\Grasshopper\Libraries\
    
  2. 安裝 Python MCP 橋接服務器

    使用 pip 安裝:

    pip install grasshopper-mcp
    

    或從源代碼安裝:

    git clone https://github.com/alfredatnycu/grasshopper-mcp.git
    cd grasshopper-mcp
    pip install -e .
    

使用方法

  1. 啟動 Rhino 和 Grasshopper

  2. 啟動 MCP 橋接服務器

    在命令行中運行:

    grasshopper-mcp
    
  3. 在 Claude Desktop 中添加 MCP 服務器

    在 Claude Desktop 的設置中添加以下 MCP 服務器配置:

    {
      "mcpServers": {
        "grasshopper": {
          "command": "grasshopper-mcp",
          "args": []
        }
      }
    }
    
  4. 使用 Claude Desktop 與 Grasshopper 交互

    現在您可以使用 Claude Desktop 向 Grasshopper 發送命令,例如:

    • "在 Grasshopper 中創建一個 3D Voronoi"
    • "添加一個圓形組件"
    • "連接點和圓形組件"

可用工具

  • add_component:添加組件到 Grasshopper 畫布
  • connect_components:連接兩個組件
  • create_pattern:根據高層次描述創建組件模式
  • get_available_patterns:獲取可用的模式列表
  • clear_document:清空 Grasshopper 文檔
  • save_document:保存 Grasshopper 文檔
  • load_document:加載 Grasshopper 文檔
  • get_document_info:獲取文檔信息

開發者指南

項目結構

grasshopper-mcp/
├── grasshopper_mcp/          # Python 包
│   ├── __init__.py
│   └── bridge.py             # MCP 橋接服務器
├── GH_MCP/                   # Grasshopper 組件源代碼
│   ├── GH_MCP/
│   │   ├── Commands/         # 命令處理器
│   │   ├── Models/           # 數據模型
│   │   ├── Resources/        # 資源文件
│   │   └── Utils/            # 工具類
│   └── GH_MCP.sln            # Visual Studio 解決方案
├── setup.py                  # Python 包配置
└── README.md                 # 說明文檔

添加新功能

  1. 添加新的 Grasshopper 命令

    在 GH_MCP/Commands/ 目錄中創建新的命令處理器,並在 GrasshopperCommandRegistry.cs 中註冊。

  2. 添加新的 MCP 工具

    在 grasshopper_mcp/bridge.py 中使用 @server.tool 裝飾器添加新的工具函數。

  3. 擴展組件知識庫

    在 ComponentKnowledgeBase.json 中添加新的組件、模式或意圖。

貢獻指南

歡迎提交 Pull Request 或 Issue 來改進這個項目。在提交代碼前,請確保:

  1. 代碼符合項目的編碼風格
  2. 添加了適當的測試
  3. 更新了文檔

許可證

MIT 許可證

Metadata

Release files for grasshopper-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grasshopper-mcp 0.1.0
File Size Uploaded Provenance
grasshopper_mcp-0.1.0.tar.gz 6.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for grasshopper-mcp 0.1.0
File Interpreter ABI Platform
grasshopper_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / grasshopper_mcp-0.1.0.tar.gz

Download URL grasshopper_mcp-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
db63435f443408073d9226301ec38b3bc3ce60dbf8817bb670d8ff3cc937827d
BLAKE2b-256 checksum
How to use checksums
415561f5782aac802821a99aa42fac73c09451d90e6d538c8d46e0d84b6c854e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / grasshopper_mcp-0.1.0-py3-none-any.whl

Download URL grasshopper_mcp-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e81166d45bf2122d6c69d87952f617c48df7a6fc6d6ad80ead3751dcd4f9bc8d
BLAKE2b-256 checksum
How to use checksums
8e27cbed5f1824207ba9dc88e04a58a34f7a173abad9398857842535c7bdfdb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for grasshopper-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page