mcp-3D-printer-server
by: DMontgomery40
Connects MCP to major 3D printer APIs (OctoPrint, Klipper, Duet, Repetier, Bambu, Prusa, Creality). Control prints, monitor status, and perform advanced STL operations like scaling, rotation, sectional editing, and base extension. Includes slicing and visualization.
πOverview
Purpose: The MCP 3D Printer Server aims to facilitate seamless interaction between users and various 3D printer management systems through a unified API.
Overview: This server serves as a Model Context Protocol (MCP) interface, enabling users to manage and control a wide range of 3D printers, including prominent models from OctoPrint, Klipper, Duet, Repetier, Bambu Labs, and Prusa Connect. It supports various functionalities from printer status checks to advanced STL file manipulations.
Key Features:
-
Printer Management: Retrieve real-time printer status, manage print jobs (start, cancel, upload G-code), and set temperatures for different components.
-
Advanced STL Manipulation: Perform intricate modifications to STL files, including scaling, rotating, translating, and generating multi-angle visualizations, facilitating better print preparation.
-
Comprehensive Workflows: Complete end-to-end support from STL modifications through slicing to printing, ensuring a streamlined process for users, coupled with error handling and diagnostics.
MCP 3D Printer Server
β¨ What's New / Significant Updates (as of last session)
- Bambu
.3mf
Printing: Added theprint_3mf
tool for Bambu Lab printers. Uploads.3mf
files and sends print commands via MQTT based on OpenBambuAPI specs. - Direct MQTT Communication (Bambu): Refactored Bambu commands to use direct MQTT (TLS port 8883) instead of relying solely on
bambu-js
. .3mf
File Parsing: Implemented a parser to read metadata and Bambu-specific slicer settings within.3mf
files.- Bambu Preset Resources: Support for reading Bambu Studio preset files (
machine
,filament
,process
) as MCP resources ifBAMBU_STUDIO_CONFIG_PATH
is set. - OrcaSlicer Integration: Added support for OrcaSlicer via CLI for slicing.
- New STL Manipulation Tools: Added
merge_vertices
,center_model
, andlay_flat
for model preparation usingthree.js
. - Configuration Update: Added
BAMBU_STUDIO_CONFIG_PATH
environment variable for preset loading. - FTP Usage Note: File operations for Bambu currently use potentially unsecured FTP via
bambu-js
.
πΊοΈ Roadmap / TODO
- Achieve feature parity for OctoPrint, Klipper, Duet, Repetier, Prusa Connect, and Creality Cloud similar to Bambu.
- Implement full MQTT status subscription for Bambu.
- Improve AMS mapping and support for print command overrides.
- Calculate MD5 hash for
.3mf
files in MQTT commands. - Explore replacing FTP operations with direct MQTT or FTPS support.
- Improve preset discovery and expand
.3mf
printing support to other printers. - Enhance MQTT error handling and print progress reporting.
- Conduct thorough testing for Bambu features.
Description
MCP 3D Printer Server allows Model Context Protocol (MCP) users to connect to various 3D printer management systems through their API endpoints. It supports:
- OctoPrint
- Klipper (Moonraker)
- Duet
- Repetier
- Bambu Labs
- Prusa Connect
- Creality/Ender
It enables interaction with 3D printers via their management system APIs, facilitating printing and model manipulation.
Note: Advanced 3D model manipulation features can be memory-intensive with large STL files. See "Limitations and Considerations" for details.
Features
- Retrieve printer status (temperatures, progress)
- List files on printer
- Upload G-code files
- Start, cancel, and monitor print jobs
- Set printer temperatures
- Advanced STL file manipulation (extend base, scale, rotate, translate, modify sections)
- Detailed STL analysis with model info
- Generate multi-angle SVG visualizations of STL files
- Real-time progress reporting and error diagnostics
- Slice STL files into G-code
- Confirm temperatures in G-code files
- End-to-end STL modification, slicing, and printing workflow
- Direct
.3mf
printing on Bambu Lab printers (via MQTT) - Read Bambu Studio preset files as resources
Installation
Prerequisites
- Node.js 18 or higher
- npm or yarn
Install from npm
npm install -g mcp-3d-printer-server
Install from source
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
Running with Docker
- Ensure Docker and Docker Compose are installed.
- Copy
.env.example
to.env
and configure settings. - Build and run container:
docker-compose up --build -d
Using Slicers with Docker
The default Docker setup cannot use slicers installed on the host machine reliably. Recommended is to install slicers like PrusaSlicer or OrcaSlicer inside the Docker image by modifying the Dockerfile
and setting SLICER_PATH
environment variable accordingly. After modification, rebuild the image.
Configuration
Create a .env
file or set environment variables:
API_KEY=your_api_key_here
PRINTER_HOST=localhost
PRINTER_PORT=80
PRINTER_TYPE=octoprint # octoprint, klipper, duet, repetier, bambu, prusa, creality
TEMP_DIR=/path/to/temp/dir
# Bambu Labs specific
BAMBU_SERIAL=your_printer_serial
BAMBU_TOKEN=your_access_token
# Slicer config
SLICER_TYPE=prusaslicer # prusaslicer, cura, slic3r, orcaslicer
SLICER_PATH=/path/to/slicer/executable
SLICER_PROFILE=/path/to/slicer/profile
# Bambu Studio presets path (optional)
BAMBU_STUDIO_CONFIG_PATH=
Usage with Claude Desktop
- Edit Claude Desktop config file with printer server command and environment:
{
"mcpServers": {
"3dprint": {
"command": "mcp-3d-printer-server",
"env": {
"API_KEY": "your_api_key_here",
"PRINTER_HOST": "your_printer_ip",
"PRINTER_TYPE": "octoprint"
}
}
}
}
For Bambu printers:
{
"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"
}
}
}
}
- Restart Claude Desktop and connect.
Supported Printer Management Systems
OctoPrint
- Default port: 80/443
- Requires API key
Klipper (via Moonraker)
- Default port: 7125
- Authentication per Moonraker config
Duet
- Default port: 80/443
- Authentication per Duet config
Repetier
- Default port: 3344
- Requires API key
Bambu Labs
- Uses MQTT for status/control and FTP for file operations
- Requires serial number and access token (
BAMBU_SERIAL
,BAMBU_TOKEN
) - Compatible with X1C, P1S, P1P, A1, others
Finding Your Bambu Serial Number and Access Token
- Serial number on printer sticker or via Bambu Studio Device Management
- Access token from printer touchscreen in Settings > Network > LAN Mode or via Bambu Handy app
- Printer must be on the same network or have cloud connection enabled
Bambu Communication Notes
- MQTT (port 8883 TLS) used for commands
- FTP used for file transfer (may be unsecured)
Prusa Connect
- Default port: 80/443
- Requires API key
- Compatible with Prusa MK4, Mini, XL
Setup steps include firmware update, Wi-Fi network connection, account creation, and API key generation.
Creality Cloud
- Default port: 80/443
- Requires bearer token
- Compatible with Ender, CR series, and other networked Creality printers
Setup involves app installation, account creation, enabling local network access, and token generation.
Available Tools
STL Manipulation Tools
Memory Warning: These tools load full 3D models into memory and may use significant resources for large files (>10MB).
get_stl_info
β Get STL file info (dimensions, vertex count, bounding box).extend_stl_base
β Extend STL base by specified amount.scale_stl
β Uniform or axis-specific scaling.rotate_stl
β Rotate model around axes in degrees.translate_stl
β Translate model along axes in mm.merge_vertices
β Merge vertices within a tolerance to close gaps.center_model
β Center model bounding box at origin.lay_flat
β Orient model so largest flat surface lies on XY plane.modify_stl_section
β Apply transformation to selected section.generate_stl_visualization
β Create SVG visualization from multiple angles.slice_stl
β Slice STL to G-code using specified slicer.confirm_temperatures
β Confirm temperatures in G-code.process_and_print_stl
β Full workflow: modify STL, slice, confirm temperatures, start print.
Printer Control Tools
get_printer_status
β Get current printer status.list_printer_files
β List printer files.upload_gcode
β Upload G-code file (optionally start print).start_print
β Start printing file on printer (not recommended for Bambu; useprint_3mf
).cancel_print
β Cancel current job.set_printer_temperature
β Set temperature of a component (unsupported on Bambu).
Bambu-Specific Tools
print_3mf
β Upload.3mf
file via FTP and start print via MQTT. Supports overrides for AMS mapping and calibration flags. Does not support overriding slicer settings like layer height or temperature.
Available Resources
Printer Resources
printer://{host}/status
β Printer status (limited for Bambu)printer://{host}/files
β List printer files (FTP for Bambu)printer://{host}/file/{filename}
β Retrieve specific file content (existence check only for Bambu)
Bambu Preset Resources
If BAMBU_STUDIO_CONFIG_PATH
is set, you can access:
preset://bambu/machine/{preset_name}
β Machine presetspreset://bambu/filament/{preset_name}
β Filament presetspreset://bambu/process/{preset_name}
β Process presets
Examples: Access specific presets by name for reading configuration.
Example Commands for Claude
Printer Control
- "What's the current status of my 3D printer?"
- "Show me the list of files on my printer."
- "Upload this G-code to my printer: [G-code content]"
- "Start printing the file named 'benchy.gcode'."
- "Cancel the current print job."
- "Set the extruder temperature to 200Β°C."
- "Set the bed temperature to 60Β°C."
STL Manipulation and Printing
- "Extend the base of this STL file by 2 inches, slice, and print."
- "Scale this STL file by 150% uniformly."
- "Rotate this model 90 degrees around the Z axis."
- "Translate this STL model up by 5mm."
- "Modify the top part of this model to be 20% larger."
- "Analyze this STL file's dimensions and details."
- "Generate SVG visualizations from different angles."
- "Slice the modified STL using PrusaSlicer."
- "Confirm temperatures in the G-code."
- "Process STL, extend base 2 inches, slice, confirm temps, and start printing."
- "Print
~/Downloads/my_model.3mf
on the Bambu printer." - "Upload
.3mf
to Bambu using AMS slots 0 and 2, disable bed leveling." - "Cancel the print on my Bambu P1S."
- "Show the settings in my Bambu filament preset 'Generic PETG'."
- "List my Bambu process presets."
Bambu Lab Printer Limitations
- Starting prints require detailed parameters not fully supported yet (e.g., MD5 hash).
- Temperature control via API is not provided; requires G-code.
- Files must upload to "gcodes" directory.
- FTP is currently unsecured (plain FTP).
- Only MQTT
project_file
command parameters can be overridden during printing (AMS, calibration flags); slicer settings cannot. - Full real-time MQTT status monitoring is pending implementation.
Limitations and Considerations
Memory Usage
- Large or complex STL files consume significant memory.
- Sequential STL operations on large files may accumulate memory usage.
- MCP environments have memory constraints; large STL processes may cause OOM.
STL Manipulation Limitations
- Section modification works best on simple geometries.
- Base extension may not perfectly handle complex undersides.
- Robust error handling is included but edge cases may exist.
Visualization Limitations
- SVG visualizations are simplified schematics, not true 3D renders.
- Complex models may not display accurately.
Performance Considerations
- Slicing is CPU-intensive and time-consuming for complex models.
- Progress may appear stalled during long operations.
Testing Recommendations
- Use STL files smaller than 10MB for testing.
- Monitor memory usage on large files.
- Test modifications on simple geometries before complex ones.
- Use a system with at least 4GB RAM for larger operations.
License
GPL-2.0