David Montgomery/mcp-3D-printer-server
Built by Metorial, the integration platform for agentic AI.
David Montgomery/mcp-3D-printer-server
Server Summary
Monitor print status
Manage print files
Pause and resume prints
Adjust print settings
Retrieve printer information
Queue print jobs
✨ What's New / Significant Updates (as of last session)
.3mf
Printing: Added the print_3mf
tool specifically for Bambu Lab printers. This uploads the .3mf
file and sends the print command directly via MQTT based on OpenBambuAPI specs.print_3mf
, cancelJob
) to use direct MQTT (TLS port 8883) instead of relying solely on bambu-js
for commands..3mf
File Parsing: Implemented a parser (src/3mf_parser.ts
) to read metadata and Bambu-specific slicer settings (from project_settings.config
) within .3mf
files.machine
, filament
, process
) as MCP resources (e.g., preset://bambu/process/MyPreset
) if BAMBU_STUDIO_CONFIG_PATH
is set.slice_stl
tool.merge_vertices
, center_model
, and lay_flat
tools for basic model preparation using three.js
.BAMBU_STUDIO_CONFIG_PATH
environment variable for preset loading.bambu-js
.🗺️ Roadmap / TODO
getStatus
for Bambu to subscribe to MQTT reports and maintain real-time state..3mf
slicer config or user overrides for the MQTT print command..3mf
Print Overrides: Add logic to the print_3mf
tool to handle user-provided overrides (e.g., calibration flags) and potentially common slicer settings if feasible via MQTT/G-code..3mf
file in the MQTT print command (optional but recommended by protocol).bambu-js
FTP operations (getFiles
, uploadFile
) with direct MQTT methods if possible/stable, or contribute FTPS support to bambu-js
..3mf
Support: Add .3mf
printing support for other printer types where applicable.Click to expand Table of Contents
This is a server that allows MCP users to connect with the API endpoints of these 3D Printers:
This server is a Model Context Protocol (MCP) server for connecting Claude with 3D printer management systems. It allows MCP to interact with 3D printers through the APIs of various printer management systems such as OctoPrint, Klipper (via Moonraker), Duet, Repetier, and Bambu Labs printers.
Note on Resource Usage: This MCP server includes advanced 3D model manipulation features that can be memory-intensive when working with large STL files. Please see the "Limitations and Considerations" section for important information about memory usage and performance.
.3mf
files directly on Bambu Lab printers (via MQTT command)npm install -g mcp-3d-printer-server
git clone https://github.com/dmontgomery40/mcp-3d-printer-server.git
cd mcp-3d-printer-server
npm install
npm link # Makes the command available globally
You can also run the server using Docker and Docker Compose for a containerized environment.
.env.example
to .env
and configure your settings.docker-compose up --build -d
Please note that the default Docker setup cannot directly use a slicer installed on your host machine. Mounting the slicer executable directly from the host into the container is unreliable due to operating system and library differences between your host and the container.
The recommended approach is to install your preferred slicer inside the Docker image. This makes the container self-sufficient.
To do this, you will need to modify the Dockerfile
. Here's a conceptual example of how you might add PrusaSlicer or OrcaSlicer (specific commands may vary depending on the slicer, its dependencies, and current Alpine packages):
# ... other Dockerfile commands ...
# Example: Install PrusaSlicer or OrcaSlicer (adjust command as needed)
# Check Alpine package repositories first (e.g., apk add prusaslicer or apk add orcaslicer)
# If not available, download and install manually (e.g., AppImage):
# RUN apk add --no-cache fuse # FUSE might be needed for AppImages
# RUN wget https://example.com/path/to/OrcaSlicer_Linux_Vxxxx.AppImage -O /usr/local/bin/orcaslicer && \
# chmod +x /usr/local/bin/orcaslicer
# Set the SLICER_PATH env var accordingly in docker-compose.yml or when running
# Example for installed executable:
ENV SLICER_PATH=/usr/local/bin/orcaslicer
# ... rest of Dockerfile ...
After modifying the Dockerfile
, rebuild your image (docker-compose build
). You'll also need to ensure the SLICER_PATH
environment variable in your .env
file or docker-compose.yml
points to the correct path inside the container (e.g., /usr/local/bin/orcaslicer
). Set SLICER_TYPE
to orcaslicer
as well.
Apologies for not including a specific slicer out-of-the-box, but given the wide variety of slicers (PrusaSlicer, OrcaSlicer, Cura, etc.) and configurations available, pre-installing one would unnecessarily bloat the image for many users. If a particular slicer becomes a very common request, I can certainly look into adding official support for it in a future version.
Create a .env
file in the directory where you'll run the server or set environment variables:
# Required for authentication with your printer management system
API_KEY=your_api_key_here
# Default printer connection settings
PRINTER_HOST=localhost
PRINTER_PORT=80 # Port for non-Bambu HTTP APIs
PRINTER_TYPE=octoprint # Options: octoprint, klipper, duet, repetier, bambu, prusa, creality
# Optional: Directory for temporary files
TEMP_DIR=/path/to/temp/dir
# Bambu Labs specific configuration
BAMBU_SERIAL=your_printer_serial # REQUIRED for Bambu
BAMBU_TOKEN=your_access_token # REQUIRED for Bambu
# Slicer configuration (for slice_stl tool)
SLICER_TYPE=prusaslicer # Options: prusaslicer, cura, slic3r, orcaslicer
SLICER_PATH=/path/to/slicer/executable
SLICER_PROFILE=/path/to/slicer/profile
# Optional: Path to Bambu Studio user config dir (for loading presets)
# Example macOS: /Users/your_user/Library/Application Support/BambuStudio/user/YOUR_USER_ID
# Example Windows: C:\Users\your_user\AppData\Roaming\BambuStudio\user\YOUR_USER_ID
# Example Linux: /home/your_user/.config/BambuStudio/user/YOUR_USER_ID
BAMBU_STUDIO_CONFIG_PATH=
{
"mcpServers": {
"3dprint": {
"command": "mcp-3d-printer-server",
"env": {
"API_KEY": "your_api_key_here",
"PRINTER_HOST": "your_printer_ip",
"PRINTER_TYPE": "octoprint"
}
}
}
}
{
"mcpServers": {
"3dprint": {
"command": "mcp-3d-printer-server",
"env": {
"PRINTER_HOST": "your_printer_ip",
"PRINTER_TYPE": "bambu",
"BAMBU_SERIAL": "your_printer_serial",
"BAMBU_TOKEN": "your_access_token"
}
}
}
}
OctoPrint is a popular web interface for 3D printers. It provides a REST API for controlling the printer.
Klipper is a firmware for 3D printers that works with the Moonraker API server.
Duet is a control board for 3D printers with its own web interface (DuetWebControl).
Repetier-Server is a host software for 3D printers.
Bambu Lab printers use MQTT for status and control and FTP for file operations.
BAMBU_SERIAL
and BAMBU_TOKEN
)To connect to your Bambu Lab printer, you need two things:
Printer Serial Number:
Access Token:
Note: If your printer is not on the same local network or you can't find the access token, you may need to update your printer's firmware to the latest version to enable LAN Mode.
bambu-js
library helper). Note: This FTP connection might be unsecured (plain FTP) based on current library limitations. Use with awareness of your network security.Prusa Connect is Prusa's own cloud-based solution for managing their printers.
Creality Cloud is Creality's management system for their printers.
Click to expand STL Manipulation Tools
Memory Usage Warning: The following STL manipulation tools load entire 3D models into memory. For large or complex STL files (>10MB), these operations can consume significant memory. When using these tools within the MCP environment, be mindful of memory constraints.
Get detailed information about an STL file, including dimensions, vertex count, and bounding box.
{
"stl_path": "/path/to/file.stl"
}
Extend the base of an STL file by a specified amount.
{
"stl_path": "/path/to/file.stl",
"extension_inches": 2
}
Scale an STL model uniformly or along specific axes.
{
"stl_path": "/path/to/file.stl",
"scale_factor": 1.5
}
Or for non-uniform scaling:
{
"stl_path": "/path/to/file.stl",
"scale_x": 1.2,
"scale_y": 1.0,
"scale_z": 1.5
}
Rotate an STL model around specific axes (in degrees).
{
"stl_path": "/path/to/file.stl",
"rotate_x": 45,
"rotate_y": 0,
"rotate_z": 90
}
Move an STL model along specific axes (in millimeters).
{
"stl_path": "/path/to/file.stl",
"translate_x": 10,
"translate_y": 5,
"translate_z": 0
}
Merge vertices that are closer than a specified tolerance. Helps close small gaps and can slightly simplify the mesh.
{
"stl_path": "/path/to/model.stl",
"tolerance": 0.01 // Optional, default = 0.01mm
}
Translate the model so the center of its bounding box is at the world origin (0,0,0).
{
"stl_path": "/path/to/model.stl"
}
Attempt to identify the largest flat surface of the model (that isn't already facing directly up or down) and rotate the model so this face is oriented downwards on the XY plane (Z=0). Useful for orienting models for printing.
{
"stl_path": "/path/to/model.stl"
}
Apply a specific transformation to a selected section of an STL file. This allows for detailed modifications of specific parts of a model.
{
"stl_path": "/path/to/file.stl",
"section": "top",
"transformation_type": "scale",
"value_x": 1.5,
"value_y": 1.5,
"value_z": 1.5
}
For custom section bounds:
{
"stl_path": "/path/to/file.stl",
"section": "custom",
"transformation_type": "rotate",
"value_x": 0,
"value_y": 0,
"value_z": 45,
"custom_min_x": -10,
"custom_min_y": 0,
"custom_min_z": -10,
"custom_max_x": 10,
"custom_max_y": 20,
"custom_max_z": 10
}
Generate an SVG visualization of an STL file from multiple angles (front, side, top, and isometric views).
{
"stl_path": "/path/to/file.stl",
"width": 400,
"height": 400
}
Slice an STL file to generate G-code.
{
"stl_path": "/path/to/file.stl",
"slicer_type": "prusaslicer",
"slicer_path": "/path/to/prusaslicer",
"slicer_profile": "/path/to/profile.ini"
}
Confirm temperature settings in a G-code file.
{
"gcode_path": "/path/to/file.gcode",
"extruder_temp": 200,
"bed_temp": 60
}
Process an STL file (extend base), slice it, confirm temperatures, and start printing.
{
"stl_path": "/path/to/file.stl",
"extension_inches": 2,
"extruder_temp": 200,
"bed_temp": 60,
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY"
}
Note: Automatic orientation for optimal printing (minimizing supports, etc.) is a complex task typically handled by slicer GUIs (like OrcaSlicer or PrusaSlicer) and is not implemented in this server.
Click to expand Printer Control Tools
Get the current status of the 3D printer.
{
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY"
}
For Bambu printers, this currently only confirms MQTT connection.
List files available on the printer.
{
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY"
}
For Bambu printers, lists files in the gcodes
directory via FTP.
Upload a G-code file to the printer.
{
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY",
"filename": "my_print.gcode",
"gcode": "G28\nG1 X100 Y100 Z10 F3000\n...",
"print": true
}
For Bambu printers, uploads to the gcodes
directory via FTP. Cannot start print automatically.
Start printing a file that is already on the printer.
{
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY",
"filename": "my_print.gcode"
}
Not recommended for Bambu printers. Use print_3mf
for Bambu .3mf
files.
Cancel the current print job.
{
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY"
}
For Bambu printers, sends the stop_print
command via MQTT.
Set the temperature of a printer component.
{
"host": "192.168.1.100",
"type": "octoprint",
"api_key": "YOUR_API_KEY",
"component": "extruder",
"temperature": 200
}
Not supported for Bambu printers via direct MQTT commands.
Click to expand Bambu-Specific Tools
Uploads a .3mf
file to a Bambu printer via FTP and initiates the print job via an MQTT command. Allows overriding some print parameters like AMS mapping.
{
"three_mf_path": "/path/to/your_model.3mf",
"host": "your_bambu_ip", // Optional if default is set
"bambu_serial": "YOUR_SERIAL", // Optional if default is set
"bambu_token": "YOUR_TOKEN", // Optional if default is set
// Optional Overrides:
"use_ams": true, // Default: true
"ams_mapping": [0, 1, 2, 3], // Array of AMS slot indices to use
"bed_leveling": true, // Default: true
"flow_calibration": false, // Default: false
"vibration_calibration": false, // Default: false
"timelapse": false // Default: false
}
Note: Overriding slicer settings like layer height or temperature via this tool is not supported by the printer's MQTT command. Apply those changes before generating the .3mf
file.
Click to expand Printer Resources
printer://{host}/status
- Current status of the 3D printer (limited for Bambu currently)printer://{host}/files
- List of files available on the 3D printer (FTP for Bambu)printer://{host}/file/{filename}
- Content of a specific G-code file (checks existence only for Bambu)Click to expand Bambu Preset Resources
If the BAMBU_STUDIO_CONFIG_PATH
environment variable is set to your Bambu Studio user settings directory, you can read your saved presets.
preset://bambu/machine/{preset_name}
- Reads a machine preset file (e.g., Bambu Lab P1S 0.4 nozzle.json
)preset://bambu/filament/{preset_name}
- Reads a filament preset file (e.g., Generic PLA.json
)preset://bambu/process/{preset_name}
- Reads a process preset file (e.g., 0.20mm Standard @BBL P1S.json
)Example Usage:
"Read the content of my Bambu process preset named '0.16mm Optimal @BBL P1S'"
(Claude would call ReadResource with preset://bambu/process/0.16mm%20Optimal%20%40BBL%20P1S
)
Here are some example commands you can give to Claude after connecting the MCP server:
~/Downloads/my_model.3mf
on the Bambu printer."~/Desktop/calibration_cube.3mf
to the Bambu printer using AMS slots 0 and 2, and turn off bed leveling."Due to the nature of the Bambu Lab printer API, there are some limitations:
Starting prints: Starting a print requires the 3MF project file path, gcode file name, print name, and MD5 hash. The simplified API in this server doesn't support this fully yet.
Temperature control: The Bambu API doesn't provide direct methods to set temperatures. This would require custom G-code commands.
File management: Files must be uploaded to the "gcodes" directory on the printer.
FTP Security: File operations currently use the printer's FTP server, which may be unsecured (plain FTP).
Parameter Overrides: Only parameters supported by the MQTT project_file
command can be overridden via the print_3mf
tool (e.g., AMS usage, calibration flags). Slicer settings like layer height or temperature cannot be changed at print time via this command.
Status Updates: Full real-time status monitoring via MQTT needs further implementation.
GPL-2.0