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.
Unlike basic Grasshopper-to-LLM connectors that only generate code, this tool includes:
- 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
- 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
- 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
| 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 |
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 .Add to your claude_desktop_config.json:
{
"mcpServers": {
"grasshopper": {
"command": "path/to/rhino_grasshopper_mcp/.venv/Scripts/python.exe",
"args": ["-m", "rhino_grasshopper_mcp"]
}
}
}To enable real-time Rhino/Grasshopper control:
- Open Rhino 7 or 8
- Run
EditPythonScriptcommand - Open and run
rhino_listener/rhino_bridge_listener.py - You'll see:
Rhino Bridge Listener started on localhost:8080
| 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 |
| 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 |
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 |
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
- Feature Extraction: Analyzes component positions, types, and connections
- Clustering: Groups components using DBSCAN or K-means
- Pattern Learning: Stores user preferences in
layout_preferences.json - Position Prediction: Uses K-NN to suggest optimal positions for new components
- Anomaly Detection: Identifies layout issues (isolated nodes, overlaps, wrong flow direction)
# 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- 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
MIT License - see LICENSE file.
- Built on the Model Context Protocol by Anthropic
- Grasshopper by David Rutten / McNeel
- scikit-learn for ML algorithms
Dongwoo Suk - Computational Design Specialist
- GitHub: dongwoosuk
- LinkedIn: dongwoosuk