A powerful, terminal-native CLI for controlling and monitoring Klipper 3D printers via Moonraker.
Klipper Console provides an SSH-friendly REPL with advanced discoverability, comprehensive file management, real-time console streaming, and explicit control semantics designed for headless environments and power users.
- Features
- Prerequisites
- Installation
- Quick Start
- Usage
- Configuration
- Contributing
- Troubleshooting
- License
- Interactive REPL - SSH-friendly command-line interface with history and auto-suggestions
- Smart Tab Completion - Context-aware completion for commands, components, files, and parameters
- Real-time Console Viewer - View historical and live Klipper console output with WebSocket streaming
- File Management - Upload, download, and manage G-code files with shell-style flags
- Print Monitoring - Track print progress, timing, and filament usage in real-time
- Component Control - Manage fans, heaters, LEDs, pins, and macros with explicit commands
- Safe by Default - Explicit write commands with warnings for hardware control
- Historical Messages - Display last 100 console messages from Klipper's gcode_store
- Live Streaming - Real-time WebSocket connection for instant console updates
- Command Execution - Send G-code commands directly from console mode
- Tab Completion - Auto-complete G-code command names while typing
- Color-Coded Output - Visual distinction between commands, errors, warnings, and responses
- Timestamps - See exactly when each message was received
- Local Navigation -
pwd,ls,cdcommands for your local filesystem - Remote Management - Create directories, list files with advanced filtering
- Upload/Download - Transfer files between local system and printer
- Shell-Style Flags -
-t(time),-S(size),-r(reverse),-a(all/hidden) - Wildcard Patterns - Filter files with
*.gcode,test_*, etc. - Smart Quoting - Automatic quote handling for filenames with spaces
- Read Operations -
get_sensor,get_fan,get_heater,get_led,get_pin - Write Operations -
set_fan,set_led,set_heater,set_pinwith explicit parameters - Macro Execution - Run macros with parameter-aware completion
- Motion Control -
home,extrudecommands with safety checks
- Python 3.10+ - Required for modern type hints and async support
- Klipper - Running on your 3D printer
- Moonraker - API server for Klipper (http://localhost:7125 by default)
- Network Access - SSH access to your printer (for remote use)
- Raspberry Pi 4 with MainsailOS
- Raspberry Pi 3B+ with FluiddPi
- Linux x86_64 systems
- macOS (Intel and Apple Silicon)
# Clone the repository
git clone https://github.com/darkoperator/Klipper-Console.git
cd Klipper-Console
# Create virtual environment
python3 -m venv venv
# Install dependencies
./venv/bin/pip install -e .# Install directly from GitHub
pip install git+https://github.com/darkoperator/Klipper-Console.git# Clone and install in editable mode for development
git clone https://github.com/darkoperator/Klipper-Console.git
cd Klipper-Console
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"Enable automatic updates through Mainsail/Fluidd web interface alongside Klipper and Moonraker.
SSH into your printer and run:
cd ~
git clone https://github.com/darkoperator/Klipper-Console.git
cd Klipper-Console
./scripts/install.shThe installer will create a virtual environment and install all dependencies automatically.
Add this to your ~/printer_data/config/moonraker.conf file:
[update_manager klipper-console]
type: git_repo
path: ~/Klipper-Console
origin: https://github.com/darkoperator/Klipper-Console.git
primary_branch: main
virtualenv: ~/klipper-console-env
requirements: pyproject.toml
install_script: scripts/install.sh
channel: stablesudo systemctl restart moonrakerNow Klipper-Console will appear in your update manager and can be updated with one click!
~/klipper-console-env/bin/klipper-consoleOr create an alias in your ~/.bashrc:
alias klipper-console='~/klipper-console-env/bin/klipper-console'For detailed installation instructions and troubleshooting, see docs/user-guide/INSTALLATION.md.
If Moonraker is running on the same machine at the default port:
./klipper-console.shThis connects to http://localhost:7125 with no authentication.
Connect to a remote printer with custom URL:
./klipper-console.sh --url http://192.168.1.100:7125If your Moonraker instance requires authentication:
./klipper-console.sh --url http://192.168.1.100:7125 --api-key YOUR_API_KEYFor printers with slow homing or long operations:
./klipper-console.sh --timeout 180 # 3 minutes# Get help
klipper> help
klipper> help get_sensor
# Check printer status
klipper> get_status
klipper> get_print_status
# Monitor components
klipper> get_sensor # Show all temperature sensors
klipper> get_sensor chamber # Show specific sensor
klipper> get_fan # Show all fans
klipper> get_fan BedFans # Show specific fanWatch real-time console output and send commands:
klipper> console
[Loading historical console messages...]
[Connected to real-time console output]
[12:34:56] // Recv: ok
[12:34:57] M117 Test message
[12:34:57] // Recv: ok
█ > G28 # Send commands with tab completion
[12:35:10] // Recv: ok
Press Ctrl+C to exit# List files with sorting
klipper> get_file # List all G-code files
klipper> get_file -t # Sort by time (newest first)
klipper> get_file -S *.gcode # Sort by size, filter by pattern
klipper> get_file -t -r test_* # Oldest first, pattern filter
# Local filesystem navigation
klipper> pwd # Show current local directory
klipper> ls -t # List local files by time
klipper> cd ~/gcode # Change to local directory
# Upload and download
klipper> upload_file test.gcode # Upload from current directory
klipper> upload_file /tmp/part.gcode gcodes/subfolder # Upload to subfolder
klipper> download_file "my file.gcode" ./downloads/ # Download (auto-quoted)
# Directory management
klipper> mkdir test_prints # Create directory on printer
klipper> list_dir -S # List directories by size# Control fans
klipper> set_fan BedFans SPEED=0.5 # Set to 50%
klipper> set_fan BedFans SPEED=0 # Turn off
# Control heaters (⚠️ Physical hardware control)
klipper> set_heater extruder TEMP=200
klipper> set_heater bed TEMP=60
# Control LEDs
klipper> set_led chamber_light RED=1.0 GREEN=1.0 BLUE=1.0
# Run macros
klipper> run BED_MESH_CALIBRATE
klipper> run PRINT_START EXTRUDER=210 BED=60# Home axes
klipper> home # Home all axes
klipper> home X Y # Home specific axes
# Extrude/retract
klipper> extrude AMOUNT=10 FEEDRATE=300 # Extrude 10mm
klipper> extrude AMOUNT=-5 FEEDRATE=300 # Retract 5mm./klipper-console.sh [OPTIONS]
Options:
--url URL Moonraker URL (default: http://localhost:7125)
--api-key KEY API key for authentication
--timeout SECONDS Request timeout (default: 120)
-h, --help Show help messageYou can also configure via environment variables:
export MOONRAKER_URL="http://192.168.1.100:7125"
export MOONRAKER_API_KEY="your-api-key"
export MOONRAKER_TIMEOUT="180"
./klipper-console.shConfiguration file support is planned for v1.0. See PRD.md for details.
get_sensor [name]- Temperature sensorsget_fan [name]- Fansget_led [name]- LEDs and neopixelsget_heater [name]- Heatersget_pin [name]- Output pinsget_toolhead- Toolhead status and homing stateget_endstops- Endstop statusget_status- Overall printer statusget_print_status- Current print job with progressget_macro [name]- Macro informationget_gcode [command]- G-code command help
set_fan <name> SPEED=<0.0-1.0>- Set fan speedset_led <name> RED=<0-1> GREEN=<0-1> BLUE=<0-1>- Set LED colorset_heater <name> TEMP=<celsius>- Set heater temperature⚠️ set_pin <name> VALUE=<0.0-1.0>- Set output pin valuerun <macro> [PARAM=value ...]- Execute macrorun_gcode <command>- Execute G-code commandhome [X] [Y] [Z]- Home axesextrude AMOUNT=<mm> [FEEDRATE=<mm/min>]- Extrude/retract filament
pwd- Show current local directoryls [flags] [pattern]- List local filescd <path>- Change local directory
get_file [flags] [pattern]- List printer files with sorting/filteringmkdir <path>- Create directory on printerlist_dir [flags] [pattern]- List printer directoriesupload_file <local> [remote]- Upload file to printerdownload_file <remote> <local>- Download file from printerdelete_file <filename>- Delete filemove_file <source> <dest>- Move/rename filecopy_file <source> <dest>- Copy fileprint_file <filename>- Start printing file
console- Enter interactive console viewer with real-time output
help [command]- Show help informationexit/quit- Exit console
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
# Clone repository
git clone https://github.com/darkoperator/Klipper-Console.git
cd Klipper-Console
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black klipper_console/Found a bug or have a feature request? Please open an issue on GitHub.
Problem: Failed to connect to Moonraker
Solutions:
- Verify Moonraker is running:
systemctl status moonraker - Check the URL is correct:
curl http://localhost:7125/server/info - Verify network connectivity if using remote URL
- Check firewall settings
Problem: Commands timeout on operations like homing
Solution: Increase timeout with --timeout flag:
./klipper-console.sh --timeout 180Problem: 401 Unauthorized or authentication failures
Solutions:
- Verify API key is correct
- Check Moonraker authentication settings in
moonraker.conf - Ensure API key has proper permissions
Problem: Cannot read/write files
Solutions:
- Check file permissions on printer
- Verify you have write access to local directories
- Run with appropriate user permissions
Problem: Console viewer shows "WebSocket connection failed"
Solutions:
- Verify Moonraker WebSocket port (usually 7125)
- Check firewall allows WebSocket connections
- Console viewer will still show historical messages
Klipper Console is built with a modular architecture:
- Shell - Interactive REPL with prompt_toolkit
- Parser - Command parsing with shlex
- Registry - Command registration and routing
- Handlers - Business logic for commands
- Moonraker Client - HTTP client for Moonraker API
- WebSocket Client - Real-time streaming (console viewer)
- Render - Rich-based output formatting
- Completion - Context-aware tab completion
- Models - Data models for printer components
See PRD.md for detailed architecture and design decisions.
- ✅ Phase 0 - Foundation
- ✅ Phase 1 - Interactive MVP
- ✅ Phase 2 - Control & Discoverability
- ✅ Phase 3 - File Management
- ✅ Phase 4 - Console Viewer
- ✅ Phase 5 - Stability & Optimization
- Configuration file support
- Plugin/extension system
- Script mode with deterministic output
- Comprehensive documentation
- User guide and tutorials
See PRD.md for complete roadmap.
MIT License - see LICENSE file for details.
- Klipper - The amazing 3D printer firmware by Kevin O'Connor
- Moonraker - The API server by Arksine
- prompt_toolkit - Interactive command-line interfaces
- Rich - Beautiful terminal formatting
- httpx - Modern HTTP client
- GitHub Repository: https://github.com/darkoperator/Klipper-Console
- Issue Tracker: https://github.com/darkoperator/Klipper-Console/issues
- Klipper Documentation: https://www.klipper3d.org/
- Moonraker Documentation: https://moonraker.readthedocs.io/
Made with ❤️ for the Klipper community