kobra-x-mcp
<a id="readme-top"></a>
# kobra-x-mcp: an MCP server to control an Anycubic Kobra X from Claude and other AI assistants
[](LICENSE)
[](pyproject.toml)
[](https://modelcontextprotocol.io)
[](#disclaimer)
**kobra-x-mcp** is an unofficial [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that lets an
AI assistant such as Claude Code monitor and control an **Anycubic Kobra X** 3D printer over your local network.
It talks to the printer in **LAN mode** (MQTT over TLS on port 9883, HTTP on port 18910), runs locally over stdio and
connects only to the printer address you give it. No Anycubic account and no cloud are involved.
You can ask your assistant things like "is the printer idle?", "what temperature is the nozzle?", "home the axes",
"turn the light off" or "upload this file and start it". Reading is always available. Anything that heats, moves or
starts the machine needs `confirm=true` and, by default, a confirmation from you.
Last checked against a real printer on **2026-12-01**, Kobra X firmware **2.0.2.8** (model id 20030).
## Disclaimer
> [!WARNING]
> **Unofficial project.** This software is not affiliated with, endorsed by or supported by Anycubic. "Anycubic"
> and "Kobra" are trademarks of their respective owners.
>
> The protocol was **reverse-engineered** and observed only on Kobra X firmware **2.0.2.8**. Other firmware versions
> or models may behave differently.
>
> **This server commands a physical machine** with hot parts (nozzle up to 260 °C, heated bed) and moving axes. A
> wrong command can damage the printer, the print or the surroundings, or hurt someone. Do not leave a printer that an
> AI controls unattended. **Use it at your own risk**; the software is provided "as is", without warranty of any
> kind (see [LICENSE](LICENSE)).
## At a glance
| | |
|---|---|
| What it is | A local MCP server (stdio, Python 3.13+) for the Anycubic Kobra X |
| Connection | Printer LAN mode: MQTT over TLS (9883) and HTTP (18910). No cloud, no account |
| Tested on | Kobra X, firmware 2.0.2.8, model id 20030. Other models are untested |
| Reads | Status, temperatures, current job, stored files, filament slots, device info |
| Actions | Light, temperatures, home, jog, motors off, fan, file upload, start, pause, resume, stop |
| Confirmation | `ask` (default): you approve each physical action. `auto`: opt-in, no prompt |
| Always enforced | Strict `confirm=true`, temperature and movement limits, state checks, no retries |
| Verified on a real printer | Reads, light, fan, temperatures, home, jog on X/Y/Z and motors off. Not yet: start, pause, resume, stop, upload |
| License | MIT |
## Contents
- [Quick start](#quick-start)
- [What you can ask](#what-you-can-ask)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Confirmation modes](#confirmation-modes)
- [Tools](#tools)
- [Safety model](#safety-model)
- [Human confirmation: what it does and does not guarantee](#human-confirmation-what-it-does-and-does-not-guarantee)
- [Limitations](#limitations)
- [Frequently asked questions](#frequently-asked-questions)
- [How it compares with other Anycubic tools](#how-it-compares-with-other-anycubic-tools)
- [Response format](#response-format)
- [Testing](#testing)
- [Protocol notes](#protocol-notes)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [Acknowledgements](#acknowledgements)
- [Citation](#citation)
- [License](#license)
## Quick start
1. On the printer, turn on **LAN mode** (this disconnects it from the Anycubic cloud while it is on).
2. Install the server:
```bash
git clone https://github.com/fralapo/kobra-x-mcp.git
cd kobra-x-mcp
uv venv --python 3.13
uv pip install -r requirements.lock
```
3. Register it with your MCP client. For Claude Code:
```bash
claude mcp add kobra -e KOBRA_HOST=192.168.1.50 -- "$PWD/.venv/bin/python" "$PWD/server.py"
```
Replace `192.168.1.50` with the printer's IP address (shown in its network settings).
4. Restart the client and ask: *"What is the state of my Kobra X?"* The assistant should call `get_status`.
## What you can ask
These are examples of requests a connected assistant can turn into tool calls:
- "Is the printer free? What are the nozzle and bed temperatures?"
- "How far along is the current print, and how long is left?"
- "List the files stored on the printer."
- "Which filaments are in the slots?"
- "Turn the light off." / "Set the part fan to 30 %."
- "Heat the nozzle to 200 °C." (only while idle, up to 260 °C)
- "Home the axes, then raise Z by 5 mm."
- "Pause the print." / "Stop the print."
- "Upload `bracket.gcode` and show me the exact message you would send first." (`dry_run`)
## Requirements
- **Python 3.13** or newer.
- An Anycubic Kobra X with **LAN mode** enabled. While it is enabled, the printer's Anycubic cloud connection is off.
- The printer and the computer running the server on the same, **trusted** local network (see
[Limitations](#limitations)).
- An MCP client that supports **form elicitation**, if you want physical actions in the default `ask` mode. Read-only
tools work with any MCP client.
## Installation
```bash
git clone https://github.com/fralapo/kobra-x-mcp.git
cd kobra-x-mcp
# with uv
uv venv --python 3.13
uv pip install -r requirements.lock
# or with the standard library
python3.13 -m venv .venv
.venv/bin/pip install -r requirements.lock
```
The direct dependencies are pinned in `pyproject.toml`. `requirements.lock` pins the exact versions of the whole
environment that the test suite passes with.
## Configuration
`KOBRA_HOST` is **required** and has no default value: there is no printer address anywhere in the code. If it is
missing, the server still starts, but every tool answers with an error that says so and no connection is attempted.
### Claude Code
```bash
claude mcp add kobra -e KOBRA_HOST=<printer-ip> -- /path/to/kobra-x-mcp/.venv/bin/python /path/to/kobra-x-mcp/server.py
```
### Other MCP clients (stdio)
Most clients accept a JSON configuration like this one:
```json
{
"mcpServers": {
"kobra": {
"command": "/path/to/kobra-x-mcp/.venv/bin/python",
"args": ["/path/to/kobra-x-mcp/server.py"],
"env": { "KOBRA_HOST": "192.168.1.50" }
}
}
}
```
A static DHCP lease for the printer is recommended, so the address does not change.
## Confirmation modes
The environment variable `KOBRA_CONFIRM_MODE` selects how physical actions are approved. It is read once, when the
server starts. Any value other than `ask` or `auto` falls back to `ask` with a warning in the log.
| Mode | What happens |
|---|---|
| `ask` (default) | Every physical action asks a person to confirm it through MCP elicitation. If the client does not support elicitation, the server **fails closed**: physical actions are refused. |
| `auto` (opt-in) | No confirmation prompt. The server approves the action itself and logs a warning to stderr for every action approved this way. The response field `human_confirmation` says `automatic (KOBRA_CONFIRM_MODE=auto)`. |
You choose the mode when you configure the server. A tool call cannot change it, and a client cannot fake the
server's internal approval.
> [!CAUTION]
> **`auto` removes the human prompt for each action.** A bug or a mistake of the AI client can then turn directly into
> a physical action: a hot nozzle, moving axes, a print started or stopped. Use it only if you accept that risk and
> stay near the printer.
To use `auto` with Claude Code:
```bash
claude mcp add kobra -e KOBRA_HOST=<printer-ip> -e KOBRA_CONFIRM_MODE=auto -- /path/to/kobra-x-mcp/.venv/bin/python /path/to/kobra-x-mcp/server.py
```
In a JSON configuration, add `"KOBRA_CONFIRM_MODE": "auto"` to `env`. When `auto` is active, the server's
`instructions` tell the client so.
Every other safeguard stays on in `auto` mode: the strict `confirm=true` boolean, the limits (nozzle at most 260 °C,
bed at most 100 °C, jog at most 10 mm, Z only upwards), the state checks (idle only, home before jogging), the recheck
of the plan inside the action lock right before sending, no retries, and `dry_run`.
`auto` mode has been tested only against the in-memory fake printer. Every real-printer result in the table below was
obtained in `ask` mode.
## Tools
"Verified" means that the behaviour was observed on a real Kobra X running firmware 2.0.2.8 (model id 20030). The
physical actions marked "yes" were run on 2026-12-01 on an idle printer, through this server in `ask` mode, with a
person confirming each action in an interactive Claude Code session. Every action has also been tested against the
in-memory fake printer and with `dry_run`; that is not counted as verification here.
| Tool | Kind | What it does | Verified on Kobra X fw 2.0.2.8 |
|---|---|---|---|
| `get_status` | read-only | state, temperatures, current job, light, fans, position, home in this session | yes |
| `get_temperatures` | read-only | nozzle and bed, current and target | yes |
| `get_current_job` | read-only | file, progress, layers, elapsed and remaining minutes | yes |
| `list_files` | read-only | files in the internal storage (`path`, e.g. `/test_model`) | yes |
| `get_filaments` | read-only | filament slots: material, colour, status | yes |
| `get_printer_info` | read-only | model, firmware, IP, peripherals, features | yes |
| `set_light` | **physical action** | light on/off, brightness 0-100 | yes: accepted; state read back: off (for brightness see [Limitations](#limitations)) |
| `set_temperature` | **physical action** | nozzle up to 260 °C and/or bed up to 100 °C, only while idle | yes: nozzle target 40 °C observed in the status, then 0 |
| `home_axes` | **physical action** | home X, Y and Z (up to ~45 s) | yes: position after the home X 120, Y 120, Z 4 then 8 mm; the server waited for the return to idle |
| `jog_axis` | **physical action** | 1-10 mm, only after a home in this session; Z only upwards | yes, on X, Y and Z: Z +5 mm (8 → 13), X +5 mm (120 → 125, Y unchanged), Y +5 mm (120 → 125), then X −5 and Y −5 back. Axis codes confirmed: 1 = X, 2 = Y, 3 = Z |
| `motors_off` | **physical action** | turns the stepper motors off (homing must be redone) | yes: accepted; the homed flag was reset |
| `set_fan` | **physical action** | part cooling fan 0-100 % | yes: 30 % observed in the status, then 0 % |
| `upload_file` | **action** | uploads a local `.gcode`/`.3mf` (up to 300 MB, never overwrites) | no: confirmed only by an external source |
| `start_print` | **physical action** | starts a file from the storage root with `use_ams=false` (no filament mapping) | no |
| `pause_print` | **physical action** | pause | no |
| `resume_print` | **physical action** | resume | no |
| `stop_print` | **physical action** | cancels the print (irreversible) | no |
"External source" (applies to `upload_file`): the behaviour was reported working on a Kobra X with firmware 2.0.2.8 by
the kobracontrol project's documentation, not by this server. `pause_print`, `resume_print`, `stop_print`,
`start_print` and `upload_file` were not verified because no print was started during the tests.
The human confirmation through elicitation was verified in an interactive Claude Code session: the dialog appeared
and the action ran only after it was accepted. It has not been verified in other MCP clients.
## Safety model
Every physical action goes through three barriers, all inside the server. In `auto` mode the second one is replaced
by the server's own approval (see [Confirmation modes](#confirmation-modes)).
1. **`confirm=true`**, as a strict boolean: `"true"`, `1` and similar values are rejected by the tool schema.
Without it, the tool only returns a preview.
2. **Human confirmation** requested by the server through MCP elicitation. The question describes the action and
its exact values. The action is not sent if the client does not declare elicitation support (the server **fails
closed**), if the person declines or cancels, if the "confirm" box is not ticked, or if the client fails.
3. **Recheck after the confirmation.** Right before sending, inside the action lock, the state is read again and the
action rebuilt. If the message, or what the person read (for example the file being printed), no longer matches
what was confirmed, the action is not sent. A confirmed action that had to wait for another one (an upload can
take minutes, a home up to ~90 s) never runs on a stale state.
Limits enforced in code and covered by the tests:
- Nozzle at most **260 °C**, bed at most **100 °C**. Temperatures can be set **only while the printer is idle**.
- Jogging: whole millimetres from **1 to 10**, **Z only upwards**, and only after a successful `home_axes` **in the
same session**.
- Home, jog, motors off, temperatures, upload and start are allowed **only while the printer is idle**. Before acting
the server reads the state again and refuses if it is unknown or unsuitable.
- **Stop** is the exception: it uses the known taskid or `"-1"`, refuses only when the printer is clearly idle, and
does **not** wait for the action lock, so it can interrupt a running home or upload.
- **One physical action at a time.** No action is ever **retried**. **An action never opens a connection**: if the
connection is missing or lost, the outcome is `not_sent`. If the connection drops during an action, the outcome
becomes `uncertain`.
<details>
<summary>More detail on the safety rules (homed state, late replies, readback, start window, uploads, dry run)</summary>
- **Home validity.** The home stops counting when the MCP session ends, when the connection drops or resumes
(including paho's automatic reconnection), as soon as a report shows the printer not idle or with another print, and
after `motors_off`, `start_print` or a new `home_axes`.
- **Signature.** The recheck signature covers the description shown, not only the message: LAN prints all have
`taskid` -1, so pausing, resuming or stopping two different prints produces the same message. For the stop, the
signature covers only the identity of the print (file and taskid), not the "state not confirmed" note: a missed read
between question and confirmation must not block a stop. With the newer protocol (`InputRequiredResult`) the plan is
rebuilt on every round: if the state changed, the question is **asked again** about the new action, and only what was
confirmed last is sent. The server uses the SDK's `Resolve`/`Elicit`, which works both with the server-initiated
request protocol (revisions up to 2025-11-25) and with `InputRequiredResult` (2026-07-28).
- **Late replies.** A report carrying the msgid of one of this server's commands counts only for that command. On
firmware 2.0.2.8, however, reports carry a msgid made up by the printer (only the ack on `/response` echoes ours),
so an old reply cannot always be told apart. That is why the readback has the final word.
- **Readback.** Temperatures, fan and light are verified by reading the values back (up to 3 readbacks). If the
requested value is read back and it was different before, the effect is proven and the outcome becomes `accepted`
even without a direct reply. If the value read back differs from the requested one, an `accepted` becomes
`uncertain` (`read_back_value` shows what is there). If the value was already equal before the command, the readback
proves nothing (`verified_by_readback: false` with a note).
- **Start.** After `start_print` the server judges every `print` report in a window of about 6 s. A stop (for example
`stop/stoped` 10111) gives `rejected`, even when it arrives alone or after a preparation phase. `accepted` needs a
preparation phase or `printing` and no stop until the window ends. `checking`, `updated` and `init` alone give
`uncertain`.
- **Stop code.** Code **10601** ("user initiated") counts as success for a stop.
- **Uploads** never overwrite: the root listing is read first, and if it is incomplete (more than 1000 entries, or a
repeated full page from a firmware that ignores paging) the upload is refused because an existing name cannot be
ruled out. The sha256 shown in the question is computed once. While sending, it is computed again on the bytes
actually read, and if it differs the body stops before the end (shorter than the declared `Content-Length`) and the
outcome is `uncertain`, never `accepted`. Size and modification time must still match the confirmed ones. Redirects
are never followed, so the file and the upload token go only to the configured host. The upload timeout is 300 s and
grows with the size (minimum speed 250 kB/s, about 21 minutes for 300 MB).
- **Dry run.** `dry_run=true` returns the exact topic and message without sending anything and without asking for
confirmation. The device id is masked. For `upload_file` the HTTP request is shown with the token hidden.
- Only reads reopen the connection (a new handshake), one at a time.
</details>
## Human confirmation: what it does and does not guarantee
> [!IMPORTANT]
> The human confirmation through elicitation has been verified against the MCP SDK's test client (in memory and
> over a real stdio transport) and in an interactive **Claude Code** session with a real Kobra X. It has **not** been
> verified in other MCP clients.
>
> The confirmation proves that *the client* answered "yes", not that a person did. **A client, an agent or a hook
> that answers elicitation requests automatically defeats this protection.** Do not configure any automatic answer
> to elicitation for this server.
>
> If the client does not support elicitation, the server **fails closed**: physical actions are refused and only
> read-only tools and `dry_run` work.
>
> `KOBRA_CONFIRM_MODE=auto` turns this protection off on purpose; see [Confirmation modes](#confirmation-modes).
## Limitations
- **No raw G-code.** The LAN protocol has no command for arbitrary G-code, and this server does not expose one.
There are also no tools for the Z offset, free extrusion, firmware updates, filament mapping or drying, or the
print speed.
- **Uploads and starts work only with files in the root** of the internal storage. The `filepath` value needed to
start a file in a subfolder (for example `/test_model`) is not verified, so `start_print` refuses folders.
- **`start_print` sends `use_ams=false`** (no filament mapping). Its behaviour with the 4-slot rack on the toolhead is
**not verified**: the sources disagree on the `ams_index` numbering and no test print was made with mapping.
- **TLS without certificate verification.** The printer's MQTT broker uses a self-signed certificate that differs
from printer to printer; both the `anycubic-lan` library and `kobra_own.py` accept it without verification
(`CERT_NONE`). The link is encrypted but not authenticated: someone on the local network able to impersonate the
printer could read the credentials and commands. Pinning the certificate fingerprint would require storing it on
disk at the first connection; this project stores nothing, so it does not do it. The handshake and the file upload
use plain HTTP, as the LAN protocol requires. **Use it only on a network you trust.**
- **Axis codes.** One source swaps the X and Y codes of `axis/move`. The map in the `AXIS_CODES` constant
(1 = X, 2 = Y, 3 = Z) was confirmed on firmware 2.0.2.8 by reading the position after real jogs on each axis.
- **Readback can lag behind.** For some actions (fan, temperature) the immediate readback returned
`verified_by_readback: false` although the state did change a few seconds later: the first status read can be
stale. The outcome is still reported from the printer's reply. Read the state again before drawing conclusions.
- **Temperature overshoot.** While heating to a 40 °C target, the nozzle went a few degrees past the target.
- **Light brightness.** On the Kobra X the light was once reported at 100% after a request for 5%. If that happens
again, `set_light` with a brightness other than 100 returns `uncertain`.
- **Other models are untested.** Several other Anycubic printers use the same LAN protocol family, but their messages
differ in places (for example the light type). Nothing here has been verified on them.
## Frequently asked questions
### Can Claude control an Anycubic Kobra X?
Yes, through this MCP server. Claude Code is the client it was tested with. The server exposes the printer as tools
(status, temperatures, files, light, fan, home, jog, upload, start, pause, resume, stop). Any other MCP client that
supports stdio can use the read-only tools, and the actions too if it supports form elicitation.
### Does it need the Anycubic cloud or an Anycubic account?
No. It uses the printer's LAN mode and talks to the printer directly. While LAN mode is on, the printer is not
connected to the Anycubic cloud, so it shows as offline under "Cloud Printer" in Anycubic Slicer Next.
### Is it safe to let an AI control my 3D printer?
It reduces the risk but does not remove it. Every physical action needs a strict `confirm=true`, is limited (nozzle
at most 260 °C, bed at most 100 °C, jogs of 1-10 mm with Z only upwards), is checked against a fresh printer state
and is never retried. By default it also asks you to confirm each action. The printer still heats and moves, so stay
near it. See [Safety model](#safety-model) and [Confirmation modes](#confirmation-modes).
### What is the difference between `ask` and `auto` mode?
In `ask` (the default) the server asks you to approve every physical action through MCP elicitation, and refuses the
action if your client cannot ask. In `auto` the server approves its own actions without asking you. You pick the mode
in the server configuration with `KOBRA_CONFIRM_MODE`. The other safeguards stay active in both modes.
### Does it work with the Kobra S1, Kobra 3, Kobra 4 or other Anycubic printers?
It has been tested only on the Kobra X (firmware 2.0.2.8). Other Kobra models use a related LAN protocol, but their
messages differ in places, and nothing here has been verified on them. Older Kobra models and the Photon resin
printers are outside the scope of this project.
### Can it print a file?
The code to upload a file and start it exists, with tests against a fake printer, but it has not been verified on a real
printer yet. It starts only files in the root of the printer's storage and does not map filaments (`use_ams=false`).
Treat `upload_file`, `start_print`, `pause_print`, `resume_print` and `stop_print` as untested on hardware.
### Can it send raw G-code?
No. The printer's LAN protocol has no command for arbitrary G-code, and the server does not offer one.
### Does it work from outside my home network?
No. It talks to the printer on the local network and does not open any remote access. LAN mode and the cloud are
mutually exclusive on this printer.
### Which ports does it use?
Port 18910 (HTTP) for the handshake and file uploads, and port 9883 (MQTT over TLS) for status and commands. Both are
on the printer. The server opens no listening port.
### How do I test changes without risking my printer?
Run the test suite against the in-memory fake printer: `env KOBRA_HOST=127.0.0.1 .venv/bin/python -m unittest
discover -s tests`. The suite refuses to start unless the host is a loopback address. See [Testing](#testing).
## How it compares with other Anycubic tools
This is a short, factual map of related open-source projects, not a ranking. They solve different problems.
| Project | What it is | Connection | Notes |
|---|---|---|---|
| **kobra-x-mcp** (this repo) | MCP server for AI assistants | LAN | Kobra X only, MIT license |
| [0xnolanyu/anycubic-mcp](https://github.com/0xnolanyu/anycubic-mcp) | MCP server for Anycubic cloud printers | Anycubic cloud | Its author reports testing on a Kobra X; works through the cloud, so it is not meant for LAN mode |
| [bloodf/kobracontrol](https://github.com/bloodf/kobracontrol) | OrcaSlicer plugin for the Kobra X | LAN | Device tab, ACE slots, camera and Spoolman; not an MCP server; GPL-3.0 |
| [nathacks/Kobralink](https://github.com/nathacks/Kobralink) | Moonraker bridge for Kobra X and Kobra 4 | LAN | Lets OrcaSlicer, Mainsail and Home Assistant talk to the printer; GPL-3.0 |
| [Nino6689/anycubic-lan](https://github.com/Nino6689/anycubic-lan) | Async Python library for Anycubic printers in LAN mode | LAN | The library this server builds on; MIT |
Choose this project if you want an AI assistant to read and control a Kobra X over LAN with limits and confirmations.
Choose one of the others if you want a slicer plugin, a Moonraker bridge, cloud access or a Python library.
## Response format
Every tool returns a JSON object with English snake_case keys.
- Read-only tools include `data_fresh`: `true` when the printer answered the queries just sent, `false` when the
values may be stale.
- Physical actions include `executed: false` with a `refused`, `preview`, `human_confirmation` or
`after_confirmation` field when nothing was sent, or an `outcome` when a command went out.
- `outcome` is one of:
| Outcome | Meaning |
|---|---|
| `accepted` | the printer accepted the command, or the readback proves the effect |
| `rejected` | the printer explicitly refused the command |
| `uncertain` | no conclusive answer: **read the state again before repeating the action** |
| `not_sent` | nothing left the server (no connection, failed publish, stale file) |
## Testing
```bash
env KOBRA_HOST=127.0.0.1 .venv/bin/python -m unittest discover -s tests
```
> [!CAUTION]
> **Never run the tests against a real printer, and especially not during a print.** The suite refuses to start
> unless `KOBRA_HOST` is a loopback address (`127.0.0.1`, `::1` or `localhost`).
The tests never touch a real printer. They use:
- `tests/spy.py`: an in-memory fake printer (a "spy" that records every message). `WireClient` exercises the real
`publish_wire` on top of a fake paho client. Any real handshake attempt makes the test fail;
- a fake HTTP server on 127.0.0.1 for uploads;
- `tests/fake_lan.py`: a signed HTTP handshake and an MQTT broker over TLS, on 127.0.0.1, for `kobra_own.py`.
| File | What it covers |
|---|---|
| `test_server.py` | validation, barriers (confirm, elicitation, strict types), actions, elicitation over stdio |
| `test_confirm_mode.py` | `KOBRA_CONFIRM_MODE`: `auto` skips the prompt but keeps `confirm=true`, strict types, limits, state checks and `dry_run`; `ask` unchanged; the internal marker cannot be forged; parsing of the variable |
| `test_regressions.py` | recheck inside the lock, no reconnection from actions, home invalidation, signature, late replies, start window |
| `test_upload.py` | single-pass digest, changed file, reply in pieces, redirects, truncated listing |
| `test_wire.py` | single MQTT exit, real `publish_wire`, required `KOBRA_HOST`, loopback-only suite, event-driven waits |
| `test_own.py` | `kobra_own.py`: complete handshake, read only, timeouts |
## Protocol notes
<details>
<summary>Topics, channels, exits towards the printer and observations on firmware 2.0.2.8</summary>
Topics have the form `anycubic/anycubicCloud/v1/{slicer|web}/printer/<modelId>/<deviceId>/<type>`. The
`COMMAND_CHANNEL` table in `server.py` fixes the channel of each command:
- `slicer`: axes, fan and print (start/pause/resume/stop), as in the sources tested on the Kobra X;
- `web`: `tempature/set` (sic, the protocol's spelling), the light (observed accepted) and the file listing.
A command missing from the table is refused. `print/update` and `multiColorBox/setInfo` are not in it because no tool
uses them. The read queries are those of the `anycubic-lan` library (`web` channel), in the same form.
**Exits towards the printer.** MQTT has a single exit, `_Client.publish_wire`: commands, the file listing and the
library's read queries (`query_all` and the automatic queries after each connection) all go through it. The library's
own commands (`pause`, `stop`, `set_light`, ...) are blocked there, so physical actions leave only after the barriers.
HTTP: `Printer._perform_upload` for files, plus the library's handshake when the connection is opened.
**Own read-only client.** `kobra_own.py` is a minimal client independent of the library (signed HTTP handshake on port
18910, MQTT with `paho-mqtt`). It can publish only the queries in its `READ_ACTIONS` allowlist; any other command
raises `PermissionError`. The server does not use it yet; it is kept as a second, read-only implementation. It
validates the `/info` document and the control reply, never follows redirects, always uses the configured host as the
MQTT broker (only the port is taken from the reply), and stops paho's thread when a connection times out or is refused.
Observations on firmware 2.0.2.8:
- The **light** has type 3, while the library assumes 2. The server uses the type reported by the printer.
- **Axis positions** arrive without the `coordinates` block. The server reads the raw data.
- The **filament** report showed only the 4-slot rack on the toolhead (box id `-1`). In some reads `loaded_slot` was
-1 with every slot at status 5: in that case the active slot is reported as `unknown`.
- **LAN prints** have `task_id` -1.
- A `print/start` with `filepath` set to `"/<name>"` ends with error 10111. The server sends the folder `"/"`.
- Reports carry a msgid made up by the printer. Only the ack on `/response` echoes the msgid that was sent.
</details>
## Troubleshooting
| Symptom | What to check |
|---|---|
| Every tool says `KOBRA_HOST is not set` | Pass `KOBRA_HOST` in the MCP server configuration and restart the client. |
| Handshake or connection errors | Enable LAN mode on the printer, check the IP address, and check that ports 18910 (HTTP) and 9883 (MQTT/TLS) are reachable from the computer. |
| Physical actions answer that the client does not support elicitation | Use an MCP client with form elicitation support, or act from the printer's panel. Read-only tools and `dry_run` still work. |
| `data_fresh: false` | The printer did not answer every query within 4 s; the values may be stale. Try again. |
| An action returned `uncertain` | Read the state (`get_status`, `get_current_job`, `list_files`) before repeating anything. |
| An action was refused with "state changed after the confirmation" | Something changed on the printer while you were confirming. Read the state and ask again. |
| `jog_axis` refuses with "Run home_axes first" | Home the axes in the same MCP session; the home stops counting after reconnections, other prints or `motors_off`. |
## Contributing
Issues and pull requests are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) first: any new physical command must go
through the same pattern (validated builder, fresh state, confirmation step, recheck under the lock, tests against the
fake printer). To report a security problem, see [SECURITY.md](SECURITY.md). If you test this on another Anycubic
model, an issue with what you observed is the most useful contribution.
## Acknowledgements
The printer's LAN protocol is not documented by Anycubic. This project used the public protocol documentation of
[Nino6689/anycubic-lan](https://github.com/Nino6689/anycubic-lan),
[bloodf/kobracontrol](https://github.com/bloodf/kobracontrol) and
[nathacks/Kobralink](https://github.com/nathacks/Kobralink) as **reference only**, and compared every payload with what a
real printer did. No code was copied from them. The server depends on the MIT-licensed `anycubic-lan` library
(pinned to 0.1.3).
## Citation
If you use this project in research or documentation, you can cite it with the metadata in
[CITATION.cff](CITATION.cff).
## License
[MIT](LICENSE) © 2026 fralapo
<p align="right">(<a href="#readme-top">back to top</a>)</p>
TDQS
Scored across 17 tools
Most tools have clearly distinct purposes, especially the physical-action tools versus the read-only status tools. There is some intentional overlap because get_status summarizes temperatures, current job, light, fans, and position, which can also be queried via more specific tools, but the boundaries remain understandable.
The set predominantly uses readable snake_case names with predictable verb_noun forms such as get_status, start_print, and set_temperature. Minor deviations like motors_off and domain-specific verbs such as home_axes are still clear and do not significantly undermine consistency.
At 17 tools, the server is slightly above the ideal compact range but still reasonable for a printer-control surface with many distinct physical operations. Each tool corresponds to a meaningful action or query, and the safety wrappers justify separate endpoints for start, pause, resume, and stop.
The surface covers the core printer lifecycle: status, temperatures, homing, jogging, motors, lighting, fan, file listing/upload, print start/pause/resume/stop, job state, filaments, and device info. Minor gaps remain around file management such as delete/rename and possible calibration or filament load/unload operations, but agents can work around these for most workflows.