u1-mcp
# u1-mcp
A small MCP server for the [Snapmaker U1](https://www.snapmaker.com/) (Snapmaker's Klipper/Moonraker firmware). It lets an AI agent check the printer, look at the camera, upload G-code and pause or cancel, while **starting a print needs a human approval the model cannot give itself**.
Status: v0.1, early. Tested against firmware 1.5.1.2 (Moonraker 1.5.1) for read-only calls via curl; the Node live tests are pending.
## Why another one
Existing U1 MCP servers either have a `confirm: true` parameter the model can pass itself, or no print control at all. Here the start gate is out-of-band: a separate CLI that only a human runs.
## Tools
| Tool | What it does |
|------|--------------|
| `u1_status` | State, progress, bed and four toolhead temperatures |
| `u1_list_files` | G-code files on the printer |
| `u1_camera` | Latest camera frame, with its age (the U1 only refreshes it while a viewer is attached) |
| `u1_upload` | Upload a local `.gcode` (does not start it) |
| `u1_pause` / `u1_resume` / `u1_cancel` | Print control |
| `u1_request_start` | Ask for approval to print a file; returns a 6-digit code |
| `u1_start` | Start a print using an approved code |
Deliberately absent: heater control, raw G-code, config or firmware changes.
## The start gate
1. Agent calls `u1_request_start` and gets a code.
2. A human runs `u1-approve <code>` in a terminal and types `yes`.
3. Agent calls `u1_start` with the code. The code is single use, valid 10 minutes, and bound to that one file. The printer must be idle.
Approvals live in `~/.u1-mcp/approvals` (override with `U1_APPROVAL_DIR`).
**Limit:** if your agent can also run shell commands, it could run `u1-approve` itself. Add a deny rule for it in your agent's permissions.
## Setup
```bash
npm install && npm run build
U1_HOST=192.168.1.50 node build/index.js
```
Claude Code: `claude mcp add u1 -e U1_HOST=192.168.1.50 -- node /path/to/u1-mcp/build/index.js`
The Moonraker API on the U1 needs no auth on the LAN, so keep it off the internet. On macOS the process needs Local Network permission.
## Tests
```bash
npm test # approval gate
U1_HOST=... U1_LIVE=1 npm test # plus read-only calls against a real printer
```
## License
MIT
TDQS
Scored across 9 tools
Each tool has a clearly distinct action and resource: status, file listing, camera, upload, pause/resume/cancel, and a two-step approval/start flow. The related u1_request_start and u1_start pair is explicitly disambiguated by the approval-code descriptions.
All tools consistently use the u1_ prefix followed by snake_case verbs or verb_noun combinations. The pattern is predictable and readable throughout.
Nine tools is well-scoped for a 3D printer control server. Each tool maps to a necessary monitoring or print-control operation without obvious redundancy.
The surface covers the core print lifecycle: monitoring, file listing, upload, approval-gated start, pause, resume, and cancel. Minor gaps include file deletion or detailed job/file management, but core workflows are covered.