Skip to main content

Grasshopper MCP Bridge Server

Project description

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 許可證

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grasshopper_mcp-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grasshopper_mcp-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file grasshopper_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: grasshopper_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for grasshopper_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 db63435f443408073d9226301ec38b3bc3ce60dbf8817bb670d8ff3cc937827d
MD5 225ac9636df023969831985a82c4c0df
BLAKE2b-256 415561f5782aac802821a99aa42fac73c09451d90e6d538c8d46e0d84b6c854e

See more details on using hashes here.

File details

Details for the file grasshopper_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for grasshopper_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e81166d45bf2122d6c69d87952f617c48df7a6fc6d6ad80ead3751dcd4f9bc8d
MD5 435c87c2704a2695ed96d3c8bcd5e2ac
BLAKE2b-256 8e27cbed5f1824207ba9dc88e04a58a34f7a173abad9398857842535c7bdfdb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page