MCP Hub
Back to servers

grasshopper-mcp

A specialized MCP server connecting AI models to Rhino/Grasshopper workflows, offering unique ML-powered layout optimization and an AI mentoring system for computational design.

Forks
1
Tools
10
Updated
Dec 12, 2025
Validated
Jan 9, 2026

🚀 Rhino 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

CategoryFeatures
Rhino BridgeLive connection, remote Python execution, canvas state
GH File OpsParse .gh/.ghx files, analyze structure, extract components
Component LibrarySearchable database of 500+ GH components
Code GenerationGHPython and C# script templates
AI MentoringPerformance prediction, alternatives, auto-grouping
ML LayoutClustering, position prediction, crossing minimization

🛠️ Installation

git clone https://github.com/dongwoosuk/rhino-grasshopper-mcp.git
cd rhino-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/rhino_grasshopper_mcp/.venv/Scripts/python.exe",
      "args": ["-m", "rhino_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)

ToolDescription
rhino_statusCheck connection status
rhino_execute_pythonExecute Python in Rhino
gh_canvas_stateGet current canvas state
gh_load_definitionLoad a .gh file
gh_solveTrigger recompute

AI Mentoring Tools

ToolDescription
predict_performancePredict optimization impact
suggest_alternativesDetect patterns, suggest better approaches
auto_groupAnalyze connectivity, suggest groupings
ml_layout_analysisML clustering analysis
predict_component_positionK-NN based position prediction

Pattern Detection Examples

The suggest_alternatives tool detects these inefficient patterns:

PatternBetter Alternative
Multiple Move componentsSingle Transform Matrix
Flatten + Graft sequencePath Mapper
Python loops for geometryNative GH components
Serial Boolean operationsBatch Boolean
Expression for simple mathNative Math components

🏗️ Architecture

rhino_grasshopper_mcp/
├── rhino_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

Reviews

No reviews yet

Sign in to write a review