Files
KlipperAnywhere/docs/agent-config.md
T
2026-05-14 02:27:26 +01:00

2.9 KiB

Agent Config

The agent can be configured with a JSON file and optional CLI overrides.

The agent also writes a small local status file by default at /var/lib/klipperanywhere/agent-state.json. You can change that with state_file in the JSON config or -state-file on the command line if the host needs a different persistent path.

Example

{
  "server_url": "wss://remote.example.com/agent/tunnel",
  "printer_id": "ender3-v3-ke",
  "token": "replace-with-agent-token",
  "moonraker_url": "http://127.0.0.1:7125",
  "ui_url": "http://127.0.0.1",
  "ui_auto_detect": true,
  "cameras": [
    {
      "name": "default",
      "snapshot_url": "http://127.0.0.1:8080/?action=snapshot",
      "stream_url": "http://127.0.0.1:8080/?action=stream"
    }
  ]
}

Run With A Config File

klipperanywhere-agent -config /etc/klipperanywhere/agent.json

CLI Overrides

The CLI flags override values from the config file:

klipperanywhere-agent \
  -config /etc/klipperanywhere/agent.json \
  -server wss://remote.example.com/agent/tunnel \
  -printer-id ender3-v3-ke

Suggested Printer Path

On a full Linux host:

/etc/klipperanywhere/agent.json

On constrained rooted printer firmware, use whichever persistent path survives firmware restarts and updates. The exact path should be confirmed per printer model.

Cameras

The agent automatically checks Moonraker's webcam API:

GET /server/webcams/list

Moonraker returns webcam entries with stream_url and snapshot_url fields. The agent resolves relative URLs against the configured moonraker_url.

Manual camera entries remain supported. If a manual camera has the same name as a Moonraker-discovered camera, the manual config overrides the discovered URLs.

Camera URLs are always resolved by the agent, not by the server. This keeps the server from requesting arbitrary LAN resources through the printer network.

Each camera needs a stable name. Snapshot and stream support are independent:

  • snapshot_url: a single image response.
  • stream_url: an MJPEG-style multipart/x-mixed-replace response.

Common webcam stacks expose paths similar to:

http://127.0.0.1/webcam/?action=snapshot
http://127.0.0.1/webcam/?action=stream

The authenticated server routes are:

/p/{printer_id}/camera/{camera_name}/snapshot
/p/{printer_id}/camera/{camera_name}/stream

Printer UI

The agent can proxy a local Mainsail or Fluidd instance through the authenticated server route:

/printers/{printer_id}/ui/

Set ui_url when the UI origin is known. If ui_url is empty and ui_auto_detect is enabled, the agent tries these local origins in order:

http://127.0.0.1
http://127.0.0.1:80
http://127.0.0.1:4408
http://127.0.0.1:8080

The agent reports ui_url, ui_reachable, and ui_source in heartbeat data so the dashboard can show whether the printer UI was configured explicitly or found automatically.