bambu-mcp
by smarthomeaf
README.md
# bambu-mcp
A self-hosted [MCP](https://modelcontextprotocol.io) server for Bambu Lab printers. It lets an AI assistant check on your printers, print sliced files, slice simple STLs and edit meshes, while keeping a human in the loop for anything physical.
- **Home Assistant first.** Status, AMS, camera and simple controls come from the [ha-bambulab](https://github.com/greghesp/ha-bambulab) integration over one WebSocket subscription. Direct LAN (MQTT, FTPS, RTSPS) is used only for uploads and print commands, or when HA can't answer.
- **Multi-printer.** Printers have ids, names and aliases; `printer: auto` picks one that passes every check.
- **Safe by default.** Anything that moves, heats, prints or deletes returns a preview unless called with `confirm: true`. Temperatures are clamped, commands are rate-limited and audit-logged, and every print runs a preflight (model, nozzle, plate, AMS match, HMS errors).
- **Token-efficient.** 9 grouped tools with `action` enums; the whole set is under ~2k tokens.
Built and tested against X1C printers (firmware 01.12). Other models are modeled in `src/bambu/models.ts` but less tested.
## Tools
| Tool | What it does |
| --- | --- |
| `printers` | List printers, capabilities probe (HA, LAN, FTPS, camera, slicer) |
| `status` | State, job, temps, HMS errors; `events` since a cursor; `wait` until a print ends |
| `camera` | Snapshot from HA or RTSPS |
| `ams` | Inventory; match a file's filaments to trays |
| `files` | SD card list / download / delete |
| `control` | Pause, resume, stop, light, speed, temps, fans, skip objects (all confirm-gated) |
| `print_job` | Inspect, preflight, upload, start a `.gcode.3mf`; cross-printer queue |
| `mesh` | STL info, scale, rotate, lay flat, center, extend base, repair ([manifold-3d](https://github.com/elalish/manifold)) |
| `slice` | Optional: Bambu Studio CLI slicing with flattened presets and AMS-based filament |
## Quick start
Requires Node 22.12+.
```bash
npm ci && npm run build
cp bambu-mcp.example.yaml bambu-mcp.yaml # edit printers, HA url
export HA_TOKEN=... # HA long-lived token; serials and access codes also via env
node dist/index.js # stdio
```
Add it to an MCP client (e.g. Claude Desktop) as a stdio server running `node /path/to/dist/index.js` with `BAMBU_MCP_CONFIG` pointing at your config.
Streamable HTTP for a home server: `MCP_TRANSPORT=streamable-http MCP_HTTP_TOKEN=... node dist/index.js` (bearer token required; `/healthz`).
Docker:
```bash
docker build -t bambu-mcp . # slim image
docker build --target slicer -t bambu-mcp:slicer . # + Bambu Studio (x86-64, ~540 MB)
```
Mount a volume at `/data` holding `bambu-mcp.yaml`.
## Docs
- [`docs/SPEC.md`](docs/SPEC.md): architecture, tool catalog, config, safety model
- [`docs/PROTOCOL.md`](docs/PROTOCOL.md): Bambu LAN protocol and Bambu Studio CLI notes (what's verified and what isn't)
- [`docs/PRIOR-ART.md`](docs/PRIOR-ART.md): existing projects and what this one took from them
This is a clean-room implementation: no code was copied from the GPL/AGPL projects it learned from.
## Development
```bash
npm test # unit tests, no hardware
npm run test:live # read-only checks against real printers + HA
npm run lint && npm run format:check && npm run typecheck
```
Live tests that act on hardware are opt-in (`BAMBU_LIVE_ACTIONS=1`).
## License
[MIT](LICENSE). Not affiliated with Bambu Lab.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues