Skip to main content
Glama
sk7n4k3d

PrusaLink MCP

by sk7n4k3d
README.md
# PrusaLink MCP

A [Model Context Protocol](https://modelcontextprotocol.io) server for **PrusaLink** —
control and monitor a Prusa 3D printer (including multi-tool models like the **XL 5T**)
directly from an AI assistant.

Talks to the printer's local HTTP API over **Digest authentication**. No cloud, no
account, nothing leaves your network.

## Tools

| Tool | Description |
|------|-------------|
| `prusa_status` | Printer state, temperatures (with targets), job progress, axis position, speed/flow |
| `prusa_info` | Serial, hostname, nozzle info, MMU state |
| `prusa_job` | Current job: file, progress, time remaining |
| `prusa_files(path)` | List files/folders on a storage (`/usb/`, `/local/`) |
| `prusa_print(path)` | Start printing a file already on the printer |
| `prusa_pause` | Pause the current print |
| `prusa_resume` | Resume a paused print |
| `prusa_stop` | Stop the current job |
| `prusa_snapshot` | Camera snapshot (if a camera is attached) |
| `prusa_upload_and_print(local_path, remote_name)` | Upload a `.bgcode`/`.gcode` file and start it |

## Configuration

Credentials are read from an env-style file (never hardcoded):

```
# ~/.config/prusalink-mcp/prusa-env
PRUSA_HOST=192.168.1.100
PRUSA_USER=maker
PRUSA_PASS=your-printer-password
```

The path defaults to `~/.config/opencode/prusa-env`; adjust `ENV_FILE` at the top of
`prusalink_mcp.py` if you store it elsewhere.

The printer password is the one displayed in **PrusaLink → Settings → Password**
(or your Prusa Connect / local credentials).

## Install

```bash
python3 -m venv venv
./venv/bin/pip install "mcp<2"
```

> This server uses the **FastMCP v1** API (`mcp.server.fastmcp`). It is pinned to
> `mcp<2` because v2 renames `FastMCP` to `MCPServer`.

## Usage

### As a stdio MCP server

```bash
./venv/bin/python prusalink_mcp.py
```

### Register it with an MCP client

```json
{
  "mcpServers": {
    "prusalink": {
      "command": "/path/to/venv/bin/python",
      "args": ["/path/to/prusalink_mcp.py"]
    }
  }
}
```

## API reference

Built against the official PrusaLink OpenAPI spec:
[github.com/prusa3d/Prusa-Link-Web](https://github.com/prusa3d/Prusa-Link-Web).

Tested against a **Prusa XL 5T** running PrusaLink 2.0.

## Notes

- `prusa_upload_and_print` uses the **upload-by-PUT** endpoint
  (`PUT /api/v1/files/usb/{name}`), which is how PrusaLink 2.0 accepts uploads.
- Uploads can be slow: the upload request uses a longer timeout than the other calls.
- Digest auth is handled transparently by a persistent opener.

## License

MIT — see [LICENSE](LICENSE).