# What Is the Bambu Labs Skill in text-to-cad? Complete CLI Guide

> Explore the Bambu Labs skill in text-to-cad. Learn how to validate, package, and send G-code files to Bambu Lab 3D printers for automated workflows. This CLI guide simplifies your printing process.

- Repository: [earthtojake/text-to-cad](https://github.com/earthtojake/text-to-cad)
- Tags: how-to-guide
- Published: 2026-07-31

---

**The Bambu Labs skill provides a command-line interface to validate, package, and send G-code files to Bambu Lab 3D printers using FTPS file transfers and MQTT printer control, enabling automated printing workflows from text-to-cad generated models.**

The **Bambu Labs skill** in the `earthtojake/text-to-cad` repository bridges the gap between AI-generated CAD models and physical fabrication. This skill module enables direct integration with Bambu Lab 3D printers through a secure CLI workflow that handles file preparation, encrypted upload, and printer job management. By implementing both **FTPS** transport and **MQTT** messaging protocols, the skill transforms raw G-code into ready-to-print jobs without manual slicer intervention.

## Core Functionality of the Bambu Labs Skill

The skill provides a self-contained automation pipeline that manages the complete handoff from generated G-code to physical print.

### G-code Validation and Packaging

Before transmission, the skill validates input files using `inspect_gcode_file` to verify file size, MD5 checksums, and proper `.gcode` extensions. For advanced workflows, the skill integrates with the external **bambox** CLI through `build_bambox_pack_command` and `build_bambox_validate_command` to generate Bambu-compatible `.gcode.3mf` project files that include material profiles and printer settings.

### Secure File Upload via FTPS

The `upload_ftps` function establishes implicitly-TLS FTP connections to transfer validated G-code directly to the printer's internal storage. This implementation uses the printer's access code for authentication, ensuring encrypted transport of print files over the local network without exposing plaintext credentials.

### Printer Control through MQTT

Once files are uploaded, the skill communicates through the `publish_mqtt` function to execute printer commands including `start`, `stop`, `cancel`, and `clear errors`. The `subscribe_mqtt_reports` capability enables status monitoring and confirmation of command execution, creating a bidirectional control channel for job management.

### Serial Number Discovery

The `discover_printer_serial` function extracts the device's unique serial number from its TLS certificate during the initial connection. This identifier is cached and used in subsequent MQTT commands to address the correct device, eliminating the need to manually specify serial numbers for repeated operations.

## Key Implementation Components

According to the source code in `earthtojake/text-to-cad`, the skill architecture separates planning from execution to ensure safety and repeatability.

### Main Script Architecture

The core implementation resides in [`skills/bambu-labs/scripts/bambu_lan_print.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/bambu-labs/scripts/bambu_lan_print.py), which defines the orchestration logic. Key builder functions—including `build_send_plan`, `build_print_control_plan`, and `build_clear_error_plan`—assemble JSON payloads describing intended actions. These plans serve both dry-run previews and actual execution workflows.

### Dry-Run Safety Mode

All network actions operate behind a **dry-run** mode by default. Real FTPS uploads and MQTT commands require the explicit `--execute` flag and a valid access code. This design prevents accidental print starts during testing and allows users to preview exactly what files and commands would be transmitted before committing to physical operations.

## Practical CLI Usage Examples

The Bambu Labs skill exposes several command modes for different stages of the print workflow.

### Packaging G-code with bambox

Convert plain G-code into a Bambu-specific project file using the packaging command:

```bash
text-to-cad bambu-labs package \
    --gcode part.gcode \
    --bambox-profile p1s-0.4 \
    --filament PLA \
    --execute

```

Omit `--execute` to preview the packaging plan without creating the `.gcode.3mf` file.

### Uploading and Starting Prints

Send validated G-code to the printer and immediately start the job:

```bash
text-to-cad bambu-labs send \
    --gcode part.gcode \
    --host 192.168.1.42 \
    --access-code 12345678 \
    --action start \
    --handoff plain \
    --execute

```

This command invokes `upload_ftps` to transfer the file, then publishes an MQTT `gcode_file` command to begin printing.

### Managing Active Jobs

Control running prints using the control subcommand:

```bash

# Cancel a running print

text-to-cad bambu-labs control \
    --host 192.168.1.42 \
    --access-code 12345678 \
    --action cancel \
    --execute

# Clear printer errors after resolving the cause

text-to-cad bambu-labs clear-error \
    --host 192.168.1.42 \
    --access-code 12345678 \
    --execute

```

## Source Code Structure

The skill implementation spans three primary locations in the repository:

- **[`skills/bambu-labs/scripts/bambu_lan_print.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/bambu-labs/scripts/bambu_lan_print.py)** — Core logic for FTPS upload, MQTT messaging, bambox integration, and TLS serial discovery
- **[`skills/bambu-labs/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/bambu-labs/SKILL.md)** — User-facing documentation defining CLI options, parameters, and safety procedures
- **[`tests/python/skills/bambu-labs/test_bambu_lan_print.py`](https://github.com/earthtojake/text-to-cad/blob/main/tests/python/skills/bambu-labs/test_bambu_lan_print.py)** — Comprehensive test suite verifying dry-run plan generation, error handling, and protocol interactions

## Summary

The **Bambu Labs skill** enables automated fabrication workflows in text-to-cad by:

- Validating and optionally packaging G-code via `inspect_gcode_file` and bambox CLI integration
- Uploading files securely through implicit-TLS FTP using `upload_ftps`
- Controlling printer state through MQTT commands via `publish_mqtt` and `subscribe_mqtt_reports`
- Discovering printer identity automatically using `discover_printer_serial` from TLS certificates
- Operating in safe dry-run mode by default, requiring explicit `--execute` flags for physical actions

## Frequently Asked Questions

### How does the Bambu Labs skill handle security when connecting to printers?

The skill uses **implicitly-TLS FTP** (FTPS) for all file transfers, encrypting both credentials and G-code payload during transmission. The `upload_ftps` function requires the printer's access code for authentication, and the `discover_printer_serial` function validates the printer's identity by extracting the serial from its TLS certificate, preventing connections to unauthorized devices.

### What is the difference between plain G-code and bambox-packaged files?

Plain G-code contains only movement instructions, while **bambox-packaged** files (`.gcode.3mf`) include embedded material profiles, printer settings, and metadata required for Bambu Lab's native workflow. The `build_bambox_pack_command` function generates these project files when the `--bambox-profile` flag is specified, ensuring compatibility with Bambu's slicer ecosystem.

### Can I use the Bambu Labs skill without executing actual printer commands?

Yes. The skill operates in **dry-run mode** by default, generating execution plans through functions like `build_send_plan` without transmitting data. Real FTPS uploads and MQTT commands only occur when you append the `--execute` flag to your CLI command, allowing safe testing of workflows before physical deployment.

### What protocols does the skill use to communicate with Bambu Lab printers?

The skill implements two primary protocols: **FTPS** (FTP over implicit TLS) on port 990 for encrypted file uploads via `upload_ftps`, and **MQTT** over port 8883 for printer command and control via `publish_mqtt`. These protocols enable both the transport of print files and real-time job management without requiring cloud connectivity.