Skip to main content

An MCP server for generating and managing Grasshopper Python components

Project description

Sand Martin

Sand Martin is an MCP (Model Context Protocol) server that enables real-time orchestration of the Grasshopper canvas within Rhino. It allows Large Language Models (like Claude) to create components, inject Python code, and wire nodes together directly in a live Grasshopper session.

Demo

1. Authenticate with the Agent

Sand Martin Auth

2. Update Slider Values

Update Slider

3. Inject and Run Code

Update Code

Architecture

Sand Martin uses a Client-Server model:

  1. SandMartin.Host (C#): A Grasshopper plugin (.gha) that runs an internal HTTP server inside the Rhino process. It has direct access to the Grasshopper.Kernel API.
  2. Sand Martin Bridge (Python): A lightweight MCP server that translates LLM requests into commands for the Host server.

Getting Started

1. Requirements

  • Rhino 8 (macOS/Windows)
  • .NET SDK 6.0+ (for building the Host)
  • Python 3.10+

2. Install the Python Bridge

You can install the Sand Martin bridge directly from PyPI:

pip install sand-martin

3. Install the Rhino/Grasshopper Plugin

Option A: Download from Food4Rhino (Recommended)

  1. Download the latest release from Food4Rhino.
  2. In Grasshopper, go to File > Special Folders > Components Folder.
  3. Place the downloaded .gha file (and any accompanying .dll files) into that folder.
  4. Restart Rhino.

Option B: Build from Source

From the root directory, open sand-martin.sln in your IDE (Visual Studio or Rider) and build the SandMartin.Host project. Copy the resulting .gha file to your Grasshopper components folder.

Configuration for Claude Desktop

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "sand-martin": {
      "command": "python",
      "args": ["/PATH/TO/YOUR/sand-martin/src/sand_martin/server.py"]
    }
  }
}

Note: Replace /PATH/TO/YOUR/ with the actual absolute path to this repository.

Usage

  1. Start Rhino and open Grasshopper.
  2. Start the Server: Drag the "Sand Martin Server" component onto the canvas and set the Run toggle to True.
  3. Authenticate the Agent:
    • Auto-Discovery (Default): The Python bridge automatically reads the security token from your system's temporary directory. No manual setup is usually required!
    • Manual Fallback: If auto-discovery fails, a unique token is printed to the Rhino Command Line.
    • Agent Behavior: If the agent cannot find the token, it will explicitly ask you to copy it from the Rhino Command History (look for "SAND MARTIN SECURITY TOKEN"). You can then paste it directly into the chat.
  4. Orchestrate: You can now ask Claude to:
    • "Create a Python component that calculates a Fibonacci sequence."
    • "Connect a Slider to the input of my component."
    • "Show me the current state of my canvas."

Security

Sand Martin includes built-in security features to protect your environment:

  • Auth Token: A unique token is generated every time the server starts. You must set this in your environment as SAND_MARTIN_TOKEN.
  • Code Gating: You can disable code injection at any time by setting AllowCodeInjection to False on the Grasshopper component.
  • Localhost Only: The server only accepts connections from 127.0.0.1.

See SECURITY.md for more details.

⚠️ Warning: Always set the Run toggle to False on the Sand Martin component when not in use.

Project Structure

  • src/SandMartin.Host/: C# source for the Grasshopper plugin.
  • src/sand_martin/: Python source for the MCP server.
  • sand-martin.sln: Visual Studio Solution file.
  • pyproject.toml: Python project configuration.

License

This project is licensed under the Apache License 2.0.

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

sand_martin-0.4.1.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

sand_martin-0.4.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file sand_martin-0.4.1.tar.gz.

File metadata

  • Download URL: sand_martin-0.4.1.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sand_martin-0.4.1.tar.gz
Algorithm Hash digest
SHA256 20d363461e6f8a25b1713ddd37f79e422a02be0dacd784171a98e539b8ae8f86
MD5 b4e30a1876eff76454134a9f75b7cb93
BLAKE2b-256 54977aba6a0704db75a2c8023aa30d292ca0e658811845fe3cbf2adf0c0b9e33

See more details on using hashes here.

Provenance

The following attestation bundles were made for sand_martin-0.4.1.tar.gz:

Publisher: pypi-publish.yml on LeoYuanjieLi/sand-martin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sand_martin-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: sand_martin-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sand_martin-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ab9dd93834579fd0bc1f8cbdc2eda9a7495349307e9108a0aacf9cb1fdc83bc
MD5 74a528ce4f86d0a403b964f05cc55a0f
BLAKE2b-256 4df56e1aec9328cf5b09c05e62abf27a8df143accf260df4ac7d3e927f0fe5cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sand_martin-0.4.1-py3-none-any.whl:

Publisher: pypi-publish.yml on LeoYuanjieLi/sand-martin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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