Skip to main content

Rhino and Grasshopper integration through the Model Context Protocol with uv package management

Project description

RhinoMCP with UV Package Management

RhinoMCP connects Rhino, Grasshopper and more to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Rhino + Grasshopper. This version uses UV for modern, fast package management and dependency resolution.

Features

Rhino Integration

  • Two-way communication: Connect Claude AI to Rhino through a socket-based server
  • Object manipulation and management: Create and modify 3D objects in Rhino including metadata
  • Layer management: View and interact with Rhino layers
  • Scene inspection: Get detailed information about the current Rhino scene (incl. screencapture)
  • Code execution: Run arbitrary Python code in Rhino from Claude

Grasshopper Integration

  • Code execution: Run arbitrary Python code in Grasshopper from Claude - includes the generation of gh components
  • Canvas inspection: Get detailed information about your Grasshopper definition, including component graph and parameters
  • Component management: Update script components, modify parameters, and manage code references
  • External code integration: Link script components to external Python files for better code organization
  • Real-time feedback: Get component states, error messages, and runtime information
  • Non-blocking communication: Stable two-way communication via HTTP server

AI Integration

  • Replicate API: Access thousands of AI models via API, including stable diffusion variants
  • Web search: Integrated web search capabilities
  • Email integration: Gmail integration for email search and management

Architecture

The system consists of three main components:

  1. MCP Server (src/rhino_gh_mcp_uv/): Python server implementing the Model Context Protocol
  2. Rhino Plugin (plugins/rhino_mcp_client.py): Socket server running inside Rhino (port 9876)
  3. Grasshopper Plugin (plugins/GHCodeMCP_new.py): HTTP server running inside Grasshopper (port 9999)

Installation

Prerequisites

  • Rhino 7 or newer
  • Python 3.10 or newer
  • UV package manager
  • A Replicate API token (optional, for AI-powered features)

Setting up the Environment

  1. Install UV (if not already installed):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    # or on Windows:
    # powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
    
  2. Clone and setup the project:

    cd rhino_gh_mcp_uv
    uv sync  # This creates a virtual environment and installs all dependencies
    
  3. Configure environment variables (optional):

    cp .env.sample .env
    # Edit .env file with your API tokens
    

Installing the Rhino Plugin

  1. Open Rhino 7
  2. Open the Python Editor:
    • Click on the "Tools" menu
    • Select "Python Script" -> "Run.."
    • Navigate to and select plugins/rhino_mcp_client.py
  3. The script will start automatically and you should see these messages in the Python Editor:
    RhinoMCP script loaded. Server started automatically.
    To stop the server, run: stop_server()
    

Installing the Grasshopper Plugin

  1. Open Grasshopper
  2. Add a GHPython component to your canvas
  3. Open the component editor
  4. Load the script from plugins/GHCodeMCP_new.py
  5. The HTTP server will start automatically on port 9999

Running the MCP Server

With UV, you can run the server in several ways:

  1. Using the installed script:

    uv run rhino-gh-mcp-uv
    
  2. Using the module directly:

    uv run python -m rhino_gh_mcp_uv.server
    
  3. For development:

    uv run python src/rhino_gh_mcp_uv/main.py
    

Claude Desktop Integration

To integrate with Claude Desktop, add this configuration to your claude_desktop_config.json:

{
  "mcpServers": {
    "rhino-gh-mcp-uv": {
      "command": "uv",
      "args": ["run", "rhino-gh-mcp-uv"],
      "cwd": "/path/to/rhino_gh_mcp_uv"
    }
  }
}

Usage

Starting the Complete System

  1. Start Rhino plugin:

    • Open Rhino 7
    • Run plugins/rhino_mcp_client.py in the Python Editor
    • Verify you see the startup messages
  2. Start Grasshopper plugin (optional):

    • Open Grasshopper
    • Load plugins/GHCodeMCP_new.py in a GHPython component
    • The HTTP server starts automatically
  3. Start Claude Desktop:

    • Claude will automatically start the MCP server when needed
    • The connection between Claude and Rhino/Grasshopper will be established automatically

Managing the Connection

  • Stop the Rhino server: In the Python Editor, type stop_server() and press Enter
  • Check server status: Use the logging output in both Rhino and the MCP server
  • Restart connections: Simply restart the respective components

Development

Project Structure

rhino_gh_mcp_uv/
├── src/rhino_gh_mcp_uv/          # Main MCP server package
│   ├── __init__.py
│   ├── server.py                 # Main MCP server
│   ├── rhino_tools.py           # Rhino integration tools
│   ├── grasshopper_tools.py     # Grasshopper integration tools
│   ├── replicate_tools.py       # AI rendering tools
│   ├── utility_tools.py         # Web search and email tools
│   └── main.py                  # Entry point
├── plugins/                      # Rhino/Grasshopper plugins
│   ├── rhino_mcp_client.py      # Rhino socket server
│   ├── GHCodeMCP_new.py         # Grasshopper HTTP server
│   └── *.gh                     # Grasshopper definition files
├── pyproject.toml               # UV project configuration
├── .env.sample                  # Environment variables template
└── README.md                    # This file

Adding Dependencies

# Add a new dependency
uv add package-name

# Add a development dependency
uv add --dev package-name

# Update all dependencies
uv sync --upgrade

Running Tests

# Run the server in development mode
uv run python src/rhino_gh_mcp_uv/main.py

# Test individual components
uv run python -c "from rhino_gh_mcp_uv.rhino_tools import RhinoConnection; print('Import successful')"

Benefits of UV Migration

  • Faster dependency resolution: UV is significantly faster than pip
  • Better dependency management: More reliable dependency resolution
  • Lockfile support: Ensures reproducible builds
  • Modern Python packaging: Uses the latest Python packaging standards
  • Cross-platform compatibility: Better support across different operating systems
  • Development workflow: Streamlined development and deployment process

Troubleshooting

Common Issues

  1. UV not found: Make sure UV is installed and in your PATH
  2. Port conflicts: Ensure ports 9876 (Rhino) and 9999 (Grasshopper) are available
  3. Connection issues: Check that both Rhino and Grasshopper plugins are running
  4. Import errors: Run uv sync to ensure all dependencies are installed

Logging

The system provides comprehensive logging:

  • MCP Server: Logs to console when running
  • Rhino Plugin: Logs to Rhino command line and log files
  • Grasshopper Plugin: Logs to Grasshopper console

Log files are stored in platform-specific locations:

  • macOS: ~/Library/Application Support/RhinoMCP/logs/
  • Windows: %LOCALAPPDATA%/RhinoMCP/logs/
  • Linux: ~/.rhino_mcp/logs/

License

MIT License - see LICENSE file for details.

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

landscape_mcp-0.1.8.tar.gz (79.2 kB view details)

Uploaded Source

Built Distribution

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

landscape_mcp-0.1.8-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file landscape_mcp-0.1.8.tar.gz.

File metadata

  • Download URL: landscape_mcp-0.1.8.tar.gz
  • Upload date:
  • Size: 79.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for landscape_mcp-0.1.8.tar.gz
Algorithm Hash digest
SHA256 219a5f2c4af6752a23549a903f3badc13de9ba38e226d7cf55743f198ee761b9
MD5 6e61d119a7bbc97faceef9bc3a45124a
BLAKE2b-256 4858d500c8533e5b3e64cf2cb5046a83ff170d858e9cf248170c23e0bfbbf006

See more details on using hashes here.

File details

Details for the file landscape_mcp-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: landscape_mcp-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for landscape_mcp-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3c997a858f9db0fab8cf0fa2f47754b7f9382a0547b941b9ae039c8522d60982
MD5 ee8b9216c344b9fd9a5577edafdd597e
BLAKE2b-256 b2f30827e9c3a958580aea72cbbde12744974fd10e63de2685b29a4970e22b2a

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