klipper-prusaslicer-mcp
by rhamblen
README.md
# klipper-prusaslicer-mcp
An MCP server that lets Claude (or any MCP client) **slice models with PrusaSlicer using
your own saved profiles** and **drive a Klipper printer through Moonraker**: status, camera,
upload, start, pause, resume, cancel, and excluding single objects.
Built for a talk-to-print pipeline: design (e.g. Fusion MCP) → `slice_model` → `upload_gcode`
→ `start_print`, with a camera-based failure detector such as Obico watching the print.
## Safety model
Every tool that starts, resumes, cancels, heats or moves the printer refuses to run unless it
is called with `confirmed=True`. The server instructions tell the assistant to pass that only
after the user has explicitly approved that action in the conversation, e.g. "bed's clear,
go". Read-only tools and `pause_print` never need it.
Hard temperature limits are set by `MAX_EXTRUDER_C` / `MAX_BED_C`.
## Tools
| Tool | What it does | Needs approval |
|---|---|---|
| `printer_status` | State, progress, ETA, temps, filament sensor, position, objects | – |
| `camera_snapshot` | JPEG from the printer camera | – |
| `console_log` | Recent Klipper console lines | – |
| `list_printer_files` / `printer_file_info` | G-code on the printer + slicer metadata | – |
| `print_history` | Recent jobs and outcomes | – |
| `active_spool` | Spoolman's active spool (via Moonraker) | – |
| `list_slicer_profiles` / `list_models` | Available profiles and models | – |
| `slice_model` | PrusaSlicer CLI with saved profiles + overrides (infill, supports, brim, scale, rotate, copies) → time, filament, objects, warnings | – |
| `upload_gcode` | Upload sliced file to the printer (does not start) | – |
| `pause_print` | Pause (parks the head) | – |
| `start_print` | Start a file on the printer | ✅ |
| `resume_print` / `cancel_print` | | ✅ |
| `exclude_object` | Cancel one object on a multi-part plate | ✅ |
| `set_temperature` | Preheat (cool-down needs no approval) | ✅ |
| `send_gcode` | Any G-code; read-only queries (M105, M114, QUERY_*) run freely | ✅ |
| `emergency_stop` | M112 | ✅ |
## Run with Docker (Unraid)
Image: `ghcr.io/rhamblen/klipper-prusaslicer-mcp:latest` (amd64 + arm64).
1. Copy [`unraid/klipper-prusaslicer-mcp.xml`](unraid/klipper-prusaslicer-mcp.xml) to
`/boot/config/plugins/dockerMan/templates-user/` on the flash drive (or fill in the same
fields by hand under **Docker → Add Container**).
2. Set **Moonraker URL**, an **MCP API key**, and the two paths:
- `/config` → appdata. Copy your PrusaSlicer `.ini` files into
`profiles/printer`, `profiles/print` and `profiles/filament`. On Windows they are in
`%APPDATA%\PrusaSlicer\{printer,print,filament}`.
- `/data` → a share with `models/` (STL/3MF in) and `gcode/` (sliced out). Make it an SMB
share and your CAD tool can save straight into `models/`.
3. Start it and open `http://<ip>:8765/health`. It should report Moonraker `ok` and your
profile counts.
Plain Docker:
```bash
docker run -d --name printer-mcp -p 8765:8765 \
-e MOONRAKER_URL=http://192.168.1.50 -e MCP_API_KEY=change-me \
-v /path/to/config:/config -v /path/to/3dprint:/data \
ghcr.io/rhamblen/klipper-prusaslicer-mcp:latest
```
### Connect Claude Code
```bash
claude mcp add --transport http printer http://<ip>:8765/mcp \
--header "Authorization: Bearer <MCP_API_KEY>"
```
## Run locally (stdio)
Needs Python 3.11+, [uv](https://docs.astral.sh/uv/) and PrusaSlicer installed. Locally it
reads profiles straight from PrusaSlicer's own config folder.
```bash
cp .env.example .env # set MOONRAKER_URL etc.
uv sync
uv run printer-mcp --check # health check
claude mcp add printer -- uv --directory /path/to/klipper-prusaslicer-mcp run printer-mcp
```
## Configuration
All settings are environment variables. See [`.env.example`](.env.example) for the full list.
Key ones: `MOONRAKER_URL`, `MCP_API_KEY`, `DEFAULT_PRINTER_PROFILE`, `DEFAULT_PRINT_PROFILE`,
`DEFAULT_FILAMENT_PROFILE`, `PROFILE_DIR`, `DATA_DIR`.
## Notes
- **PrusaSlicer 2.9 CLI crash workaround.** Profiles saved by the GUI can contain
`bed_temperature_extruder = 0` or `wipe_tower_extruder = 0`, and either one makes the
2.9.x CLI segfault. The server strips those lines from a temporary copy before slicing;
your files are never changed.
- G-code is sliced with `--gcode-label-objects firmware`, so Klipper's `exclude_object`
works. That needs `[exclude_object]` in `printer.cfg`.
- CLI slicing has no painted supports, seam painting or manual arranging. Overrides cover
the common cases.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues