Skip to main content
Glama
README.md
# PrinterLink

Live status and **confirmed** control of Bambu Lab 3D printers on your local network, for you and for Claude.

- **Live:** an always-on background service keeps a read-only connection to every printer (they push each change) and knows the state, job, progress, layers, time left, nozzle/bed/chamber temperatures, fans, AMS slots and filament, and HMS errors with plain-English descriptions.
- **Claude:** an MCP server for Claude Desktop and Claude Code. Ask “how long is left on the H2D?” or “anything wrong with my printers?”.
- **Control with a human in the loop:** pause, resume, stop, print speed and chamber light. Nothing is sent until you click a confirmation dialog on your Mac. Claude can ask; it can't click.
- **Status file:** the service also writes `printers-status.md` / `.json` wherever you like (for example a Google Drive folder, so Claude on the web or your phone can read it).

PrinterLink is independent and not affiliated with Bambu Lab.

## Install (macOS)

```bash
curl -fsSL https://raw.githubusercontent.com/JeremyPappas/printerlink/main/install.sh | bash
```

Or from a checkout: `./install.sh`. It installs into your user account only (no admin password):

1. a Python environment in `~/Library/Application Support/PrinterLink/`, and the `printerlink` command;
2. guided setup to find your printers and their access codes (see below);
3. **PrinterLink.app** in `~/Applications`, a tiny app whose only job is to run the service. macOS grants local-network access to apps, not to bare scripts, so this is what appears in **System Settings → Privacy & Security → Local Network**. When macOS asks whether PrinterLink may find devices on your local network, click **Allow**;
4. a login item that starts the service at login and restarts it if it stops;
5. the Claude connector, registered with Claude Code (`claude mcp add`) and Claude Desktop (a backup of its config is kept). Quit and reopen Claude Desktop afterwards.

Needs macOS 13+, Python 3.10+ (Homebrew's, or Apple's Command Line Tools: `xcode-select --install`) and Apple's Command Line Tools (to build the small app).

Uninstall: `./uninstall.sh` (add `--all` to also delete your printer list and the access codes in your keychain).

## Finding printers and access codes

Use any of these, in any combination (`printerlink setup` walks you through them):

| Way | What it gives | Command |
|---|---|---|
| **Network discovery** | name, model, address, cloud/LAN mode | `printerlink discover` |
| **Bambu Studio import** | access codes Bambu Studio saved for your printers | `printerlink import-studio` |
| **Bambu account sign-in** | every printer on your account with its access code | `printerlink login` |
| **By hand** | the code shown on the printer (Settings → Network) | `printerlink add NAME SERIAL ADDRESS` |

> **About Bambu sign-in: it's unofficial.** Bambu Lab doesn't offer a sign-in API for third-party apps. `printerlink login` uses the same private endpoints Bambu Studio and the Home Assistant integration use (email + password, then the code Bambu emails you, or your authenticator code). It can stop working whenever Bambu changes them. Your password is sent only to Bambu and isn't stored; the token Bambu returns and the access codes are kept in your macOS keychain. If you'd rather not sign in, discovery plus Bambu Studio import or the code from the printer's screen work just as well.

Access codes live in the macOS keychain (service `printerlink.access-code`), never in files, logs, the status file or anything sent to Claude.

## Control needs LAN Only + Developer Mode

Reading status works whether your printer is in cloud mode or LAN Only mode. **Pause, resume, stop and speed changes** are another matter: since Bambu Lab's 2025 “Authorization Control” firmware, printers refuse these from third-party apps unless the printer is in **LAN Only mode with Developer Mode on** (printer screen → Settings → Network). That mode disconnects the printer from Bambu's cloud (Bambu Handy remote access and cloud printing stop). The chamber light works in either mode.

PrinterLink reads this from the printer (`print_controls: available` or `locked: needs LAN Only + Developer Mode`) and tells you or Claude instead of asking you to confirm something the printer would reject.

## Using it

```bash
printerlink status            # all printers, live, from the service (a few seconds if it isn't running)
printerlink status H2D --json
printerlink send H2D pause    # shows a confirmation dialog first
printerlink list
```

Actions: `pause`, `resume`, `stop`, `light_on`, `light_off`, `speed_silent`, `speed_standard`, `speed_sport`, `speed_ludicrous`. There is deliberately no flag to skip the confirmation.

### Claude tools

| Tool | What it does |
|---|---|
| `list_printers` | names, models, online, state, whether controls are available |
| `get_printer_status` | everything live for one printer or all |
| `explain_error` | describes an HMS / print error code |
| `control_printer` | asks you to confirm on the Mac, then sends; marked destructive so Claude also asks first |

Claude Code by hand: `claude mcp add --scope user printerlink -- "$HOME/Library/Application Support/PrinterLink/venv/bin/printerlink" mcp`

### Status file and settings

`~/Library/Application Support/PrinterLink/config.json` (see `config.example.json`):

```json
{
  "status_dirs": ["{home}/status", "~/Library/CloudStorage/GoogleDrive-*/My Drive/PrinterLink"],
  "status_basename": "printers-status",
  "cloud_region": "global",
  "confirm_timeout_s": 120
}
```

A folder pattern with `*` is used once its parent exists, so Google Drive for desktop can be installed later. Error descriptions use Bambu's HMS texts when a catalog is available (`hms_catalog`; the default points to one Bambu Bar ships, if you have it). Without one, codes are shown without descriptions.

## How it works

Bambu printers run an MQTT broker on port 8883. PrinterLink connects over TLS as `bblp` with the printer's access code, and trusts the printer only if its certificate chains to Bambu Lab's certificate authorities (in `printerlink/certs/`) **and** is issued to that printer's serial number, so another device can't collect the code. It asks once for a full report and merges the changes the printer pushes.

```
printers ⇄ PrinterLink service (PrinterLink.app → Python) → status files
                     ↑ private Unix socket (owner-only)
        printerlink CLI · MCP server ← Claude Desktop / Claude Code
```

The service is the only process that sends commands, and only after the dialog is confirmed. Code layout: `protocol.py` (MQTT/TLS), `report.py` (parsing), `sources.py` (discovery, Bambu Studio import), `cloud.py` (sign-in), `commands.py` (actions, confirmation), `daemon.py` (service), `mcp_server.py`, `cli.py`. The parts are kept separate so a native Swift app can replace the service and dialog later while keeping the same socket protocol.

Linux: `pip install .[cloud]`, `printerlink setup`, run `printerlink service run` under systemd; confirmations are asked on the terminal.

Tests: `python -m unittest discover -s tests` (offline, no printers needed).

## Credits

Protocol knowledge from [Bambu Bar](https://github.com/rolottr/bambu-bar) (MIT) and [ha-bambulab](https://github.com/greghesp/ha-bambulab) (MIT); the Bambu Lab CA certificates come from those projects. PrinterLink is a separate implementation. See `NOTICE`.

## License

MIT, see `LICENSE`.