Grasshopper MCP

Grasshopper MCP

Enables AI-powered computational design in Rhino/Grasshopper with ML-based automatic layout optimization, component clustering, performance prediction, and real-time code execution in running Rhino instances.

Category
访问服务器

README

🚀 Grasshopper MCP - AI-Powered Computational Design Assistant

An MCP (Model Context Protocol) server that brings AI capabilities directly into Rhino/Grasshopper workflows, featuring ML-based automatic layout optimization - a capability not found in any other publicly available tool.

Version Status License: MIT Python 3.10+

🎯 What Makes This Different?

Unlike basic Grasshopper-to-LLM connectors that only generate code, this tool includes:

🧠 ML-Based Auto Layout (Industry First)

  • DBSCAN clustering for automatic component grouping
  • K-means clustering for fixed group counts
  • User pattern learning with persistent preferences
  • K-NN position prediction for optimal new component placement
  • Wire crossing minimization algorithm

🎓 AI Mentoring System

  • Performance prediction: Estimates optimization impact (e.g., "15-30% improvement expected")
  • Pattern detection: Identifies inefficient patterns and suggests better alternatives
  • Auto-grouping: Analyzes wire connectivity to suggest logical component groups
  • Layout anomaly detection: Finds isolated, overlapping, or misaligned components

🔌 Live Rhino Integration

  • Real-time connection to running Rhino/Grasshopper instances
  • Execute Python code remotely in Rhino
  • Get canvas state and trigger solves
  • No file-based workflow required

📋 Features Overview

Category Features
Rhino Bridge Live connection, remote Python execution, canvas state
GH File Ops Parse .gh/.ghx files, analyze structure, extract components
Component Library Searchable database of 500+ GH components
Code Generation GHPython and C# script templates
AI Mentoring Performance prediction, alternatives, auto-grouping
ML Layout Clustering, position prediction, crossing minimization

🛠️ Installation

git clone https://github.com/dongwoosuk/grasshopper-mcp.git
cd grasshopper-mcp
python -m venv .venv
.venv\Scripts\activate  # Windows
pip install -e .

⚙️ Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "grasshopper": {
      "command": "path/to/grasshopper_mcp/.venv/Scripts/python.exe",
      "args": ["-m", "grasshopper_mcp"],
      "cwd": "path/to/grasshopper_mcp"
    }
  }
}

🔌 Live Rhino Connection (Optional)

To enable real-time Rhino/Grasshopper control:

  1. Open Rhino 7 or 8
  2. Run EditPythonScript command
  3. Open and run rhino_listener/rhino_bridge_listener.py
  4. You'll see: Rhino Bridge Listener started on localhost:8080

📚 Available Tools

Rhino Bridge (requires listener)

Tool Description
rhino_status Check connection status
rhino_execute_python Execute Python in Rhino
gh_canvas_state Get current canvas state
gh_load_definition Load a .gh file
gh_solve Trigger recompute

AI Mentoring Tools

Tool Description
predict_performance Predict optimization impact
suggest_alternatives Detect patterns, suggest better approaches
auto_group Analyze connectivity, suggest groupings
ml_layout_analysis ML clustering analysis
predict_component_position K-NN based position prediction

Pattern Detection Examples

The suggest_alternatives tool detects these inefficient patterns:

Pattern Better Alternative
Multiple Move components Single Transform Matrix
Flatten + Graft sequence Path Mapper
Python loops for geometry Native GH components
Serial Boolean operations Batch Boolean
Expression for simple math Native Math components

🏗️ Architecture

grasshopper_mcp/
├── grasshopper_mcp/
│   ├── bridge.py              # Main MCP server
│   ├── rhino_bridge.py        # TCP client to Rhino
│   ├── gh_file_ops.py         # .gh/.ghx parsing
│   ├── component_library.py   # Component database
│   ├── code_generator.py      # Code templates
│   └── mentoring/
│       ├── ml_layout_learner.py        # DBSCAN/K-means
│       ├── advanced_layout_learner.py  # Advanced learning
│       ├── persistent_layout_learner.py # User patterns
│       ├── performance_predictor.py    # Optimization prediction
│       ├── alternative_suggester.py    # Pattern detection
│       ├── auto_grouper.py             # Wire-based grouping
│       ├── wire_crossing_detector.py   # Crossing detection
│       └── crossing_minimizer.py       # Layout optimization
├── rhino_listener/
│   └── rhino_bridge_listener.py  # Run IN Rhino
└── pyproject.toml

🤖 ML Layout System Details

How It Works

  1. Feature Extraction: Analyzes component positions, types, and connections
  2. Clustering: Groups components using DBSCAN or K-means
  3. Pattern Learning: Stores user preferences in layout_preferences.json
  4. Position Prediction: Uses K-NN to suggest optimal positions for new components
  5. Anomaly Detection: Identifies layout issues (isolated nodes, overlaps, wrong flow direction)

Supported Analyses

# Example: ML clustering analysis
result = ml_layout_analysis(gh_file_path, method="dbscan")
# Returns: clusters, anomalies, optimization suggestions

# Example: Position prediction
result = predict_component_position(gh_file_path, "Panel", near_component="Slider")
# Returns: predicted X, Y coordinates based on learned patterns

🎯 Use Cases

  • Design Automation: Let AI handle repetitive Grasshopper tasks
  • Code Review: Get suggestions for optimizing definitions
  • Learning: AI mentoring for Grasshopper best practices
  • Layout Cleanup: Automatic organization of messy definitions
  • Team Standards: Consistent component arrangement across projects

📄 License

MIT License - see LICENSE file.

🙏 Acknowledgments

  • Built on the Model Context Protocol by Anthropic
  • Grasshopper by David Rutten / McNeel
  • scikit-learn for ML algorithms

📬 Contact

Dongwoo Suk - Computational Design Specialist

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选