Bambu Lab Printer (LAN)

io.github.b84330808由 GitHub 账号 b84330808 发布v0.3.0更新于 Nov 2, 2026

Unofficial. Status, AMS filament, print control and maintenance for Bambu Lab 3D printers via LAN

已验证STDIO仅桌面位置与生活效率与工作流

概览

AI 生成的概览

非官方本地 MCP 服务器,让助手通过局域网读取并控制 Bambu Lab 3D 打印机,涵盖状态、AMS 耗材、打印控制与维护记录。

可以做什么
  • 读取打印机状态、阶段、进度、温度、层数与 Wi-Fi 信号,以及带 wiki 链接的 HMS 警告
  • 查看 AMS 各槽位的耗材类型、品牌、颜色、剩余百分比与当前槽位
  • 查看维护状态、按近期打印速率预测到期任务,并列出最近打印记录
  • 记录已完成的维护任务,可回填时间
  • 控制打印机:暂停、继续、取消、腔体灯、速度档位、预热、切换 AMS 槽位与发送原始 G-code
  • 执行首次设置并查看设置状态,保存前先实测连接
适用场景
适合在本地网络中拥有 Bambu Lab 打印机、希望让助手查询状态、耗材与警告,或代为暂停、预热、调整乃至取消打印并记录维护的用户,且不依赖云端服务。
运行要求
通过 npx 在本地运行,需要 Node.js 20 或更高版本。打印机须在同一网络并开启 LAN Mode Liveview,还需其 IP、序列号和 8 位局域网访问码,可通过 BAMBU_IP、BAMBU_SERIAL、BAMBU_ACCESS_CODE 提供,或用 setup_printer 工具录入。无需云端账号。
安装前请注意
可移动加热中的打印头并取消耗时数小时的打印;stop_print、run_gcode 与 change_active_tray 需显式确认,设置 BAMBU_READ_ONLY=1 可仅注册只读工具。预热后加热器会持续保持目标温度。打印机使用自签名证书,身份未经校验,应在可信网络使用且切勿把 MQTT 端口暴露到公网。访问码保存在本地配置文件中。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Bambu Lab Printer (LAN),将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-server-for-bambu

[npm version] [CI] [License: MIT]

Ask Claude (or Cursor, or VS Code) what your Bambu Lab printer is doing, and have it pause, preheat or log maintenance, over your LAN with no cloud.

An MCP server for Bambu Lab 3D printers. It talks to the printer directly over its local MQTT interface. Built and tested against the P1S; other MQTT-speaking models (P1P, X1C, A1) should work.

⚠️ Unofficial — not affiliated with Bambu Lab

This is a community-built project. It is not affiliated with, endorsed by, or sponsored by Bambu Lab / Shenzhen Tuozhu Technology Co., Ltd. "Bambu Lab", "Bambu Studio", "P1S", "P1P", "X1C", and "AMS" are trademarks of their respective owners; references in this project are descriptive only (nominative fair use), made for compatibility purposes. Provided "as is" with no warranty.

Demo

[Tool calls against the simulated printer: status, AMS, pause and light, then a cancel that is refused without confirmation]

Real tool calls and output, run against the built-in printer simulator (npm run sim). Regenerate with scripts/demo/; docs/demo-script.md covers recording a session with a real printer.

Features

Live statusState, current stage, progress, layer, time left, nozzle/bed/chamber temperatures, Wi-Fi signal
AMSFilament type, brand, color and remaining % per slot, plus the active slot
HealthActive HMS warnings decoded to module and severity, each with its Bambu wiki link
ControlPause, resume, cancel, chamber light, speed profile, preheat, AMS slot switch, raw G-code
Maintenance ledgerCounts print-hours locally and tells you when rails, carbon rods or the hotend are due
Guided setupNo config editing: tell Claude your IP, serial and access code; it tests them before saving
SafetyCancel, G-code and AMS switch need explicit confirmation; read-only mode; LAN addresses only
Works anywhere MCP doesClaude Code plugin, Claude Desktop, Cursor, VS Code, any stdio MCP client
Printer simulatornpm run sim starts a fake printer for trying it out, demos and tests

Quick start

You need Node.js 20+ and a printer on the same network with LAN Mode Liveview turned on.

Claude Code

Install the plugin (MCP server plus a short skill that teaches Claude the confirmation rules):

/plugin marketplace add b84330808/mcp-server-for-bambu/plugin install bambu-printer@mcp-server-for-bambu

Or add just the MCP server:

bash
claude mcp add --transport stdio --scope user bambu -- npx -y mcp-server-for-bambu

Claude Desktop

Open Settings → Developer → Edit Config (%APPDATA%\Claude\claude_desktop_config.json on Windows, ~/Library/Application Support/Claude/claude_desktop_config.json on macOS) and add:

json
{  "mcpServers": {    "bambu": {      "command": "npx",      "args": ["-y", "mcp-server-for-bambu"]    }  }}

Fully quit Claude Desktop (tray icon → Quit) and reopen it.

Cursor

[Add bambu MCP server to Cursor]

Or put this in ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project):

json
{  "mcpServers": {    "bambu": {      "command": "npx",      "args": ["-y", "mcp-server-for-bambu"]    }  }}

VS Code

bash
code --add-mcp "{\"name\":\"bambu\",\"type\":\"stdio\",\"command\":\"npx\",\"args\":[\"-y\",\"mcp-server-for-bambu\"]}"

Or add it to .vscode/mcp.json. This version passes the credentials as env vars and asks for the access code as a hidden input:

json
{  "inputs": [    {      "type": "promptString",      "id": "bambu-access-code",      "description": "Bambu LAN access code (Settings > WLAN > LAN Mode Liveview)",      "password": true    }  ],  "servers": {    "bambu": {      "type": "stdio",      "command": "npx",      "args": ["-y", "mcp-server-for-bambu"],      "env": {        "BAMBU_IP": "192.168.1.50",        "BAMBU_SERIAL": "01P00A1234567890",        "BAMBU_ACCESS_CODE": "${input:bambu-access-code}"      }    }  }}

All of these are in examples/.

Connect your printer

On first start the server is in setup mode and offers one tool, setup_printer. Read three values off the printer's touchscreen:

  • IP: Settings → WLAN → tap the connected network
  • Serial: Settings → Device → Device Info (P1S: 01P00A…)
  • Access code: Settings → WLAN → LAN Mode Liveview, 8 characters, not the Wi-Fi password. LAN Mode Liveview must be ON.

Then tell your assistant:

"Set up my Bambu printer. IP is 192.168.1.50, serial 01P00A1234567890, access code 12345678."

setup_printer checks the format, connects to the printer, and saves the credentials only if the connection works. Restart the server once (Claude Desktop: quit and reopen; Claude Code: /mcp → reconnect bambu) and the printer tools appear.

You can skip this and pass BAMBU_IP, BAMBU_SERIAL and BAMBU_ACCESS_CODE as env vars instead, as in the VS Code example.

Try it

  • "What's my printer doing right now?"
  • "What filament is in AMS slot 2?"
  • "Any HMS warnings?"
  • "Anything overdue on the printer maintenance?"
  • "Pause the print." / "Resume."
  • "Preheat the nozzle to 210 and bed to 60."
  • "Cancel this print." (asks you to confirm first)
  • "I just lubricated the rails, log it."

Tools

ToolWhat it doesAsks first?
get_statusState, stage, temperatures, progress, layer, HMS warnings, Wi-Fi
get_ams_infoPer-slot filament type / color / remaining %, active slot
list_active_warningsActive HMS warnings with links to Bambu's wiki
get_maintenance_statusPrint-hours and lube / clean / inspect warnings
forecast_maintenanceWhen each maintenance task will be due at your recent print rate
get_recent_printsLast N print sessions: name, duration, finish time
mark_maintenance_doneLog a maintenance task (optionally back-dated by hours_ago)
pause_print / resume_printPause and resume the current print
set_lightChamber light on/off
set_speedsilent / standard / sport / ludicrous
preheatSet nozzle and/or bed target temperature
stop_printCancel the print. Not reversibleyes (confirm: true)
run_gcodeSend raw G-code (homing, Z moves, manual unload…)yes (confirm: true)
change_active_traySwitch the AMS to another slotyes (confirm: true)

Every tool also carries MCP annotations (readOnlyHint, destructiveHint), so clients that ask before running tools can treat the read tools and the destructive ones differently.

Safety

This server can move a heated toolhead and cancel hours of printing. It is built to make that hard to do by accident:

  • Confirmation for destructive tools. stop_print, run_gcode and change_active_tray refuse to run unless called with confirm: true, and their descriptions tell the model to set it only after you agree in plain words. Keep your client's own tool-approval prompts on as a second check.
  • Read-only mode. Set BAMBU_READ_ONLY=1 and the server registers only the read tools. Nothing can pause, cancel, heat or move the printer. A good default for a shared machine or a demo.
  • LAN only. It connects to the one printer IP you configure, on port 8883, and nowhere else: no Bambu cloud, no telemetry. setup_printer rejects addresses outside private ranges (192.168.x.x, 10.x.x.x, 172.16–31.x.x, plus link-local, loopback and the 100.64/10 range Tailscale uses). Never forward the printer's MQTT port to the internet.
  • Trusted network. The printer uses a self-signed certificate, so the connection is encrypted but the printer's identity is not verified. Use it on a network you trust.
  • Heaters stay on. preheat and M104/M140 leave the heaters at the target until something changes them. Turn them off (set 0) before you walk away.
  • Credentials stay local. They are stored in your user config directory (below), with owner-only permissions on macOS and Linux.

Configuration

Env varDefaultMeaning
BAMBU_IP, BAMBU_SERIAL, BAMBU_ACCESS_CODEfrom the saved .envPrinter credentials. Env vars win over the saved file
BAMBU_READ_ONLY01 registers only the read tools
BAMBU_CONFIG_DIRsee belowWhere the .env and the maintenance ledger live
MAINTENANCE_LEDGER_PATH<config dir>/maintenance.jsonLedger file location

The config directory is:

  • Windows: %APPDATA%\mcp-server-for-bambu\
  • macOS: ~/Library/Application Support/mcp-server-for-bambu/
  • Linux: ~/.config/mcp-server-for-bambu/ (or $XDG_CONFIG_HOME)

Versions up to 0.2.0 kept .env and maintenance.json inside the installed package, where npx updates could delete them. 0.3.0 still reads an old .env from there and copies an old ledger into the config directory on first start.

The ledger persists to a local JSON file and survives crashes (active sessions are checkpointed every 5 elapsed minutes). Thresholds are in src/types.ts:

TaskInterval
Clean carbon rods100 print-hours
Lubricate linear rails200 print-hours
Inspect hotend / nozzle wear500 print-hours

A task flips to DUE_SOON (🔔) within 10 hours of the threshold and OVERDUE (⚠️) past it.

Try it without a printer

npm run sim (from a clone, after npm install) starts a simulated P1S halfway through a Benchy, with a 4-slot AMS, on mqtts://127.0.0.1:8883. It answers status requests and applies pause, resume, cancel, speed, preheat, light and AMS commands. Point the server at it:

bash
BAMBU_IP=127.0.0.1 BAMBU_SERIAL=01P00ASIMULATOR BAMBU_ACCESS_CODE=12345678 node dist/index.js

Set SIM_PORT to use another port, then pass the same value as BAMBU_MQTT_PORT. The test suite uses the same simulator.

Development

bash
git clone https://github.com/b84330808/mcp-server-for-bambu.gitcd mcp-server-for-bambunpm installnpm test             # builds, then runs unit + end-to-end tests against the simulatornpm run dev          # tsc --watchnpm run sim          # simulated printer

To run your local build from an MCP client, point it at node /absolute/path/to/mcp-server-for-bambu/dist/index.js.

src/  index.ts          MCP server bootstrap + tool definitions  config.ts         Env / .env loading, LAN address check  paths.ts          Per-user config directory  mqtt-client.ts    TLS MQTT client for the printer (port 8883, self-signed cert)  setup.ts          setup_printer: validate, test the connection, save  maintenance.ts    Print-time ledger with crash-safe atomic writes + recovery  hms.ts            Bambu HMS error code → human label  stages.ts         Stage / speed / tray code → human label  commands.ts       MQTT command payloadssim/printer.mjs     Simulated printer (aedes broker over TLS)plugins/            Claude Code plugin; .claude-plugin/marketplace.json lists itserver.json         MCP Registry metadata

Protocol notes:

  • Subscribe: device/{serial}/report
  • Publish: device/{serial}/request with {"pushing":{"sequence_id":"...","command":"pushall"}}
  • Auth: username bblp, password = access code, a random client ID per connection (reusing one makes two clients kick each other off)
  • Cert is self-signed → rejectUnauthorized: false

License

MIT

来源:README.md,提交 403c049

工具

2

setup_printer

Set up printer

FIRST-TIME SETUP. Configure this MCP server with your Bambu Lab printer's LAN credentials (IP / serial / access code). Tests the connection live and only saves on success. Find the values on the printer touchscreen: Settings → WLAN (IP), Settings → Device → Device Info (serial), Settings → WLAN → LAN Mode Liveview (8-char access code). Make sure LAN Mode Liveview is ON.

输入参数ip必填serial必填access_code必填

setup_status

Setup status

Show the current setup state — whether credentials are configured and where the .env file is located.

无需输入参数。

版本历史

1
  1. v0.3.0最新Oct 26, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分