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 (rhino_gh_mcp_uv/): Python server implementing the Model Context Protocol
  2. Rhino Plugin (../rhino_script_client/rhino_client.py): Socket server running inside Rhino (port 9876)
  3. Grasshopper Component (../rhino_gh_mcp/rhino_gh_mcpComponent.cs): C# Grasshopper component running HTTP server (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. Build the Rhino Plugin:

    • Open ../rhino_script_client/rhino_script_client.sln in Visual Studio
    • Build the project to create the .rhp plugin file
    • The plugin will be installed automatically when Rhino starts
  2. Start the Rhino MCP Service:

    • In Rhino, run the command ToggleMCPService or use the UI panel
    • The service will start a socket server on port 9876
    • Alternatively, you can run ../rhino_script_client/rhino_client.py directly in the Python Editor

Installing the Grasshopper Component

  1. Build the Grasshopper Component:

    • Open ../rhino_gh_mcp/rhino_gh_mcp.sln in Visual Studio
    • Build the project to create the .gha component file
    • The component will be available in Grasshopper under the "MCP" tab
  2. Start the Grasshopper MCP Server:

    • Open Grasshopper in Rhino
    • Add the "rhino_gh_mcp MCP Server" component to your canvas
    • Set the "RunServer" input to True to start the HTTP server on port 9999
    • Optionally set "CategoryFilter" to prioritize specific component categories (e.g., "MCP,Math") - this prioritizes components from these categories but allows access to all components

MCP Client Configuration

For Published Package:

{
  "mcpServers": {
    "rhino-gh-mcp": {
      "command": "uvx",
      "args": ["rhino-gh-mcp"]
    }
  }
}

For Local Development:

{
  "mcpServers": {
    "rhino-gh-mcp": {
      "command": "uv",
      "args": ["run", "--directory", "/absolute/path/to/rhino_gh_mcp_uv", "python", "-m", "rhino_gh_mcp_uv.server"],
      "cwd": "/absolute/path/to/rhino_gh_mcp_uv"
    }
  }
}

Usage

Starting the Complete System

  1. Start Rhino:

    • Open Rhino 7 or 8
    • Start the Rhino MCP service (see "Installing the Rhino Plugin" above)
  2. Start Grasshopper MCP Server (optional, for Grasshopper features):

    • Open Grasshopper
    • Add the "rhino_gh_mcp MCP Server" component
    • Set "RunServer" to True
  3. Start Claude Desktop or Cursor IDE:

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

Managing the Connection

  • Stop the Rhino server: Run the ToggleMCPService command again or use the UI panel
  • Stop the Grasshopper server: Set the "RunServer" input on the MCP Server component to False
  • Check server status: Use the "Status" output on the Grasshopper component or check the Rhino command line
  • Restart connections: Simply restart the respective components

Development

Adding Dependencies

uv add package-name          # Add dependency
uv add --dev package-name    # Add dev dependency
uv sync --upgrade           # Update all dependencies

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 the Rhino MCP service is running
    • Check that the Grasshopper MCP Server component has "RunServer" set to True
    • Verify both components are built and loaded correctly
  4. Import errors: Run uv sync to ensure all dependencies are installed
  5. Component not found: Make sure the Grasshopper component is built and the .gha file is in the correct location

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

rhino_gh_mcp-0.1.8.tar.gz (79.7 kB view details)

Uploaded Source

Built Distribution

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

rhino_gh_mcp-0.1.8-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rhino_gh_mcp-0.1.8.tar.gz
  • Upload date:
  • Size: 79.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rhino_gh_mcp-0.1.8.tar.gz
Algorithm Hash digest
SHA256 3d6ce70e8ba92082e94b45c04f986f7306c0bfd6215c92708de67aef4078afff
MD5 661640397d615694ec639da73ac4aff3
BLAKE2b-256 8b30c51b9066df927bb5ba9ae563620c7a07f696ace96bb0eefd271150688bc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rhino_gh_mcp-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rhino_gh_mcp-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 77add8d2b4801b2c808244c7f4399e3f7f68d604c42394dabfce9b1e0ccd4663
MD5 edaae36d9cc31f35575057e5489f9c99
BLAKE2b-256 8eae37c7592abce5ca0dffc0323662528684a4bc3007b8857dc92db7996261df

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