Skip to main content
Glama
README.md
# Neil MCP

An [MCP](https://modelcontextprotocol.io) server that lets Claude drive Neil, a 4-motor robot built with LEGO® SPIKE™ Prime elements.
It controls a Raspberry Pi with a [Build HAT](https://www.raspberrypi.com/products/build-hat/),
sees through a Pi Camera on the robot, and uses an iPhone that overlooks the scene as an external camera.

**New to Neil? Start at [neil-robot.github.io](https://neil-robot.github.io/)** to see what it offers: videos of Neil at work, how to build one, Neil in research, and teaching Physical AI with it.
Neil runs two kinds of AI on the same hardware, each in its own repo:

| Repo | How you give Neil a task |
| --- | --- |
| **neil-mcp** (this repo) | **Tell it.** Type a task in plain words, and an LLM agent such as Claude Code carries it out with Neil's MCP tools. |
| [neil-vla](https://github.com/neil-robot/neil-vla) | **Show it.** Drive Neil through the task with a gamepad a few dozen times, and a vision-language-action model learns it from the recordings. |

<p align="center">
  <img src="docs/media/robot-render.png" width="720"
       alt="3D render of the robot: two light-blue wheels, a yellow deck, and a black two-finger gripper at the front">
</p>

## From parts to a first task

1. **Build Neil** from the parts list and the wiring in [Hardware](#hardware); the site [shows the build](https://neil-robot.github.io/#build), and the step-by-step instructions are [on Gumroad](https://navat.gumroad.com/l/build-neil).
2. **Set up** the Pi, the phone camera and this repo, and tell the code where the Pi and the phone are: [Setup](#setup).
3. **Give Claude Code a task**, such as "grab the red cup": [Usage](#usage).

## Hardware

![Neil's digital model, made in BrickLink Studio](docs/media/neil-render.png)

<p align="center">
  <img src="docs/media/robot-real.jpg" width="720"
       alt="The robot as built, side view: a Raspberry Pi with Build HAT and a camera on the yellow deck, two light-blue wheels, and the black gripper at the front">
</p>

### Bill of materials

| Item | Qty. | Price each | Notes / link |
| --- | ---: | ---: | --- |
| [Raspberry Pi 4 Model B](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/) | 1 | $35+ | Runs the MCP robot scripts |
| [Argon NEO Case for Raspberry Pi 4](https://argon40.com/products/argon-neo-case-for-raspberry-pi-4) | 1 | $16 | Holds the Pi on the deck; used without its top lid, so the Build HAT sits on the Pi |
| [Raspberry Pi Build HAT](https://www.raspberrypi.com/products/build-hat/) | 1 | $30 | Connects and controls the LEGO motors |
| [Build HAT power supply](https://www.raspberrypi.com/documentation/accessories/build-hat.html) | 1 | $16 | 8 V, 6 A (48 W), barrel jack; motors cannot run from USB power |
| [LEGO SPIKE Prime Set (45678)](https://www.bricklink.com/v2/catalog/catalogitem.page?S=45678-1) | 1 | $400 | LEGO structural parts, wheels, 1 Large Angular Motor, and 1 Medium Angular Motor; SPIKE hub is not used. Retired by LEGO in 2026, so the price is for a used set |
| [LEGO Technic Large Angular Motor (45602)](https://www.bricklink.com/v2/catalog/catalogitem.page?P=54675c01) | 2 | $50 | Additional motors; with the one in the SPIKE set, provides 3 large motors for the wheels and arm. The price is for a used motor |
| [Raspberry Pi Camera Module documentation](https://www.raspberrypi.com/documentation/accessories/camera.html) | 1 | $20 | Camera v1 (OV5647), mounted facing forward |
| iPhone with [SimpleIPCamera](https://apps.apple.com/app/id6752223439) | 1 | — | Existing phone used as the overhead camera |
| [Generic USB Game Controller](https://www.adafruit.com/product/6285) | 1 | $5 | Any USB gamepad works; the link is one example |
| **Total** | | **about $620** | Without the phone |

Prices are rough US prices from November 2026; check them before you buy. The LEGO prices are BrickLink's averages for used items over the six months before ([set](https://www.bricklink.com/catalogPG.asp?S=45678-1), [motor](https://www.bricklink.com/catalogPG.asp?P=54675c01&ColorID=156)); new SPIKE Prime sets averaged about $450. The Raspberry Pi 4 costs more with more memory: $35 for 1 GB, $100 for 4 GB. The camera price is for a third-party OV5647 board. The Build HAT and its power supply are SparkFun's prices, the case is PiShop's, and the gamepad is Adafruit's.

The SPIKE Prime Set supplies the LEGO body/structure and the robot's Medium Angular Motor, plus one of its three Large Angular Motors. The set's SPIKE hub is not used; motor control is handled by the Raspberry Pi and Build HAT. See the [BrickLink set inventory](https://www.bricklink.com/catalogItemInv.asp?S=45678-1).

No SPIKE Prime set? The site has Neil's 108 LEGO parts as a [BrickLink Wanted List](https://neil-robot.github.io/parts/neil-parts-bricklink.xml) (upload it on BrickLink under Want → Upload) and as a [CSV](https://neil-robot.github.io/parts/neil-parts.csv). The step-by-step build instructions, the BrickLink Studio model and an 18-minute build video are [sold on Gumroad](https://navat.gumroad.com/l/build-neil); everything in this repository stays free and open source.

![Wiring, seen from above: the power supply into the Build HAT, ports A to D to the four motors, and the camera ribbon to the Pi](docs/media/wiring.svg)

The motors are connected as follows:

- **A** — left wheel
- **B** — right wheel
- **C** — gripper
- **D** — arm

## Setup

**Early release (v0.1).** This is the code our own robot runs. Expect rough edges in the steps below, and please open an issue when one of them doesn't work for you.

### 1. Raspberry Pi

1. Flash **Raspberry Pi OS Bookworm** with [Raspberry Pi Imager](https://www.raspberrypi.com/software/).
   In the customisation step, set hostname `rpi`, username `rpi`, your Wi-Fi, and enable SSH
   ([guide](https://www.raspberrypi.com/documentation/computers/getting-started.html)).
2. Set up key-based SSH from your computer, because the server logs in without a password
   ([SSH docs](https://www.raspberrypi.com/documentation/computers/remote-access.html)):
   ```bash
   ssh-copy-id rpi@rpi.local
   ssh rpi@rpi.local          # should log in without asking for a password
   ```
3. Enable the serial port that the Build HAT talks over
   ([Build HAT docs](https://www.raspberrypi.com/documentation/accessories/build-hat.html)):
   run `sudo raspi-config` → Interface Options → Serial Port → login shell **No**, serial hardware **Yes**, then reboot.
4. Install the Python libraries on the Pi. The server runs its scripts over SSH with the system `python3`:
   ```bash
   sudo apt install python3-build-hat python3-picamera2 gpiod lsof   # gpiod/lsof: to reset a stuck HAT
   ```
5. Check the camera and a motor
   ([camera docs](https://www.raspberrypi.com/documentation/computers/camera_software.html),
   [buildhat library](https://buildhat.readthedocs.io/)):
   ```bash
   rpicam-hello --list-cameras
   python3 -c "from buildhat import Motor; print(Motor('A').get_position())"
   ```

If you use a different hostname or user, set `ROBOT_HOST` / `ROBOT_USER` in `.env` (see [step 3](#3-this-repo)).
If your motors are wired differently, set `PORT_LEFT_WHEEL`, `PORT_RIGHT_WHEEL`, `PORT_GRIPPER` and `PORT_ARM`.

### 2. SimpleIPCamera (iPhone)

1. Install [SimpleIPCamera](https://apps.apple.com/app/id6752223439) and join the same Wi-Fi as the Pi.
2. Give the phone a fixed IP, for example `192.168.1.50`. Use a DHCP reservation on your router, or set it on the phone:
   Settings → Wi-Fi → ⓘ → Configure IP → Manual.
   You can also leave the phone's IP as it is and set `SIMPLEIPCAMERA_URL` in `.env` to its address instead.
3. In the app, set:
    1. FPS to **30**
    1. Resolution to **720p**
    1. Tap **Start Server**
   The server reads `http://192.168.1.50:8080/stream.mjpeg` unless `SIMPLEIPCAMERA_URL` says otherwise.
5. Keep the app in the foreground, because iOS stops the camera when the app goes to the background or the phone locks:
   - Settings → Display & Brightness → Auto-Lock → **Never**
   - Low Power Mode off
   - Phone on a charger
6. The app serves one viewer at a time. If you check the stream in a browser, close the tab afterwards.

The server rotates the frames 90° clockwise (`SIMPLEIPCAMERA_ROTATION`). Change that value if the image comes out sideways.

### 3. This repo

```bash
git clone https://github.com/neil-robot/neil-mcp && cd neil-mcp
python3 -m venv .venv                                   # Python 3.11+
.venv/bin/pip install -e ".[viz,yolo]" mcpmon mcp-memory-service
cp .env.example .env                                    # then edit it: the Pi's host, the phone's address, your Gemini API key
```

The `yolo` extra adds the YOLO11 and YOLOE object detectors from `ultralytics`, which is licensed AGPL-3.0, unlike this repo (see [License](#license)). Leave it out to install no AGPL code; the VLM then finds the objects instead. The tests need the extra.

All the settings are in `.env`, which git does not track, so your API key stays out of commits. `.env.example` lists the ones you are likely to change; [`neil_mcp/config.py`](neil_mcp/config.py) has every one, with its default. A variable that is already set in your shell wins over `.env`. `NEIL_ENV_FILE` names another file instead; set it empty to read none. The file is read when the server starts, so after you edit it, reconnect the server in Claude Code's `/mcp`.

## Scene text

While a task runs, the server reads new text in both camera streams, such as a sign or a label. It only reads a view that is still, clear, and changed since the last read. Text containing a word it hasn't seen before becomes a **visual signal**. The signal is appended to `output/signals/neil.jsonl`, which Claude Code tails in the background, and carried by the next tool result as `visual_signals`. Until a result has carried it, the robot pauses: multi-step motions stop at their next step, and motor commands return PAUSED without moving.

Claude Code decides whether the text matters and, if it does, revises its plan. The server only reports what it reads.

The frames behind each signal, with an `_ocr.jpg` overlay of what was read, are saved in `output/scene_text/`. The settings are the `SCENE_TEXT_*` and `SIGNALS_OUTBOX` entries in `neil_mcp/config.py`. See [neil_mcp/scene_text.py](neil_mcp/scene_text.py) for the design.

The instructions on handling signals reach Claude Code from the server itself, so they are only there when scene text is on.

## Usage

Start Claude Code in the repo with `claude`. It starts the servers listed in `.mcp.json`, and `/mcp` shows their status.
Then give it a task, e.g. "grab the red cup", or run `/grab`.

- Logs: `output/logs/mcp_server.log`
- All settings: `.env` (see [step 3](#3-this-repo)). Every one, with its default, is in `neil_mcp/config.py`.
- The rules Claude follows in this project: [CLAUDE.md](CLAUDE.md)

## License

The code is licensed under the [Apache License 2.0](LICENSE), and the images and videos in `docs/` under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The optional `yolo` extra (`ultralytics` and the YOLO weights) and the embeddings in `neil_mcp/yoloe_vpe/` are AGPL-3.0. [LICENSES.md](LICENSES.md) lists what is under which license, and the licenses of the dependencies and models.

## Trademarks

LEGO®, SPIKE™ and Technic™ are trademarks of the LEGO Group, which does not sponsor, authorize or endorse this project. Raspberry Pi is a trademark of Raspberry Pi Ltd, which does not sponsor or endorse this project.