UGS-MCP
This MCP server lets an AI assistant connect to, monitor, and control CNC machines via Universal GCode Sender (UGS), with built-in safety confirmation mechanisms to prevent autonomous machine movement.
Connection Management
Connect to a CNC machine via serial port (configurable firmware and baud rate), disconnect, and troubleshoot issues by listing available ports and checking pendant reachability.
Machine & Job Status
Retrieve real-time machine state (Idle/Run/Alarm), current position, feed rate, spindle speed, and monitor running job progress.
Motion Control (Token-Protected) All motion commands require a two-step token confirmation — the AI cannot self-confirm movement:
Jog a single axis (X, Y, or Z) by a specified distance and feed rate
Run the homing cycle ($H)
Rapid return to G54 work zero (X0 Y0 Z0)
Set G54 work coordinate offsets at the current position
Stream and run G-code files (with a built-in safety check and preview before execution)
Execute saved macros by name
Job Control
Pause a running job (feed hold)
Cancel a running job (uses a simple boolean confirmation instead of a token, since stopping is always safer)
G-code Analysis & Macros
Translate G-code into plain English, line by line, with machine state context
Perform safety checks (spindle off during cuts, missing unit declarations, zero feedrate on cut moves, etc.)
Estimate cycle time from feed rates and distances (returns HH:MM:SS)
List all tools referenced in a file with first-use line and usage count
Save validated G-code snippets as named, reusable macros
List all saved macros with names and descriptions
ugs-mcp
MCP server for controlling CNC machines via Universal GCode Sender.
Lets Claude (or any MCP-compatible AI assistant) connect to a CNC machine, inspect G-code, and issue motion commands — all through the UGS Pendant REST API.
⚠️ STOP. READ THIS FIRST.
This software controls machines that can damage equipment, destroy parts, and injure or kill people.
CNC machines move fast and don't know where your hands are. Before you use this:
Read SAFETY.md. All of it.
Understand the token confirmation system that prevents Claude from moving your machine autonomously.
Know where your E-stop is.
If you skim the safety docs and something goes wrong, that's on you. We warned you.
Related MCP server: CNCjs MCP Server
What it does
Connection tools — Connect/disconnect UGS to your CNC, troubleshoot serial port issues
Status tools — Read machine state, position, feed rate, spindle speed
Motion tools (token-protected) — Jog axes, home, return to work zero, run G-code files and macros
G-code inspector — Translate G-code to English, safety check, cycle time estimate, tool list
Every motion command uses a two-step token protocol: Claude generates a token, shows it to you, and the machine only moves when you read the token back. Claude cannot bypass this — tokens are generated and validated server-side.
Requirements
Universal GCode Sender 2.x (winder.github.io/ugs_website)
UGS Pendant plugin installed and active (Tools → Plugins → Installed)
Pendant running at
http://localhost:8080(default)Python 3.11+
Installation
Via pip
pip install ugs-mcpFrom source
git clone https://github.com/zackpeters93/ugs-mcp.git
cd ugs-mcp
pip install -e .Claude Code setup
claude mcp add ugs-cnc ugs-mcpOr from source (without pip install):
claude mcp add ugs-cnc /path/to/ugs-mcp/ugs_mcp/run_server.shClaude Desktop setup
In ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"ugs-cnc": {
"command": "ugs-mcp"
}
}
}Or from source:
{
"mcpServers": {
"ugs-cnc": {
"command": "/opt/homebrew/opt/python@3.11/libexec/bin/python3",
"args": ["-m", "ugs_mcp.server"],
"cwd": "/path/to/ugs-mcp"
}
}
}Configuration
Environment variables (all optional):
Variable | Default | Description |
|
| UGS Pendant host |
|
| UGS Pendant port |
|
| Directory for saved G-code macros |
|
| Rapid speed used in return-to-zero |
Copy .env.example to .env to customize.
The token system
Every motion tool uses a mandatory two-step confirmation:
Step 1 — Call the tool without a token. Claude shows you a preview (axis, distance,
resulting position, safety warnings) and a token like [A3F8B2C1].
Step 2 — Read the preview. If you agree, tell Claude the token. Claude calls the tool
again with confirmation_token="A3F8B2C1". The machine moves.
Tokens are generated server-side via uuid4(), expire in 2 minutes, and are single-use.
Claude cannot predict, fabricate, or reuse them. The only way movement happens is if you
type the token back.
Tools
See USER_GUIDE.md for the full tool reference with parameters, examples, and typical workflows.
Category | Tools |
Connection |
|
Status |
|
Job |
|
Motion |
|
G-code |
|
Tested with
SainSmart Genmitsu 3018 Pro (GRBL)
UGS 2.x with Pendant plugin
macOS / Python 3.11
Likely works with any GRBL-based machine. TinyG/FluidNC/Smoothieware untested.
License
MIT — see LICENSE.
No warranty. No liability. Read SAFETY.md.
Available Tools
19 toolsgcode_estimate_timeC
Estimate machining cycle time from G-code feedrates and distances. Returns HH:MM:SS.
Inputs: file_path_or_code (required). Returns: result
gcode_list_macrosA
List all saved macros with their names and descriptions.
Inputs: no named parameters. Returns: result
gcode_list_toolsB
List all tools referenced in a G-code file, with first use line and usage count.
Inputs: file_path_or_code (required). Returns: result
gcode_run_macroA
Run a saved macro by name. Call with no token first to get the G-code preview, safety check, and confirmation token. The user must provide the token back before the macro runs. Claude CANNOT self-confirm - the token enforces this at the server level.
Inputs: name (required), confirmation_token. Returns: result
gcode_safety_checkB
Check G-code for safety issues: spindle off during cuts, missing unit declaration, zero feedrate on cut moves, and other DANGER/WARNING/CAUTION issues. Run this before ugs_run_file for any G-code you did not write yourself.
Inputs: file_path_or_code (required). Returns: result
gcode_save_macroA
Save a G-code macro to the macros directory after running a safety check. Claude writes the G-code content; this tool handles validation and persistence. Use gcode_list_macros to see saved macros, gcode_run_macro to execute one.
Inputs: name (required), gcode_content (required), description. Returns: result
gcode_translateA
Translate G-code to plain English, line by line. Accepts either a file path or raw G-code string. Shows each command, its meaning, and the current machine state context.
Inputs: file_path_or_code (required), max_lines. Returns: result
ugs_cancel_jobA
Cancel the running job. Stopping mid-cut will leave a mark on the part. Uses simple confirmed=True/False (not a token) because stopping is always safer than continuing - token friction on an emergency stop would be dangerous. Call with confirmed=False first to preview, then confirmed=True to cancel.
Inputs: confirmed. Returns: result
ugs_connectC
Connect UGS to the CNC machine via serial port.
Inputs: port (required), baud_rate, firmware. Returns: result
ugs_disconnectA
Disconnect UGS from the CNC machine.
Inputs: no named parameters. Returns: result
ugs_get_job_statusB
Get current job progress and machine state.
Inputs: no named parameters. Returns: result
ugs_get_statusA
Get current machine state: position, status (Idle/Run/Alarm), feed rate, spindle speed.
Inputs: no named parameters. Returns: result
ugs_homeA
Run the GRBL homing cycle ($H). All axes move toward limit switches at full speed. Call with no token first to get a preview and confirmation token. The user must provide the token back before homing executes. Claude CANNOT self-confirm movement - the token enforces this at the server level.
Inputs: confirmation_token. Returns: result
ugs_jogA
Jog a single axis (X, Y, or Z) by distance_mm at feedrate mm/min. Call with no token first to get a preview and confirmation token. The user must provide the token back before movement executes. Claude CANNOT self-confirm movement - the token enforces this at the server level.
Inputs: axis (required), distance_mm (required), feedrate (required), confirmation_token. Returns: result
ugs_pause_jobA
Pause the currently running G-code job (sends feed hold).
Inputs: no named parameters. Returns: result
ugs_return_to_zeroA
Rapid (G0) to G54 work zero (X0 Y0 Z0). Call with no token first to get a preview and confirmation token. The user must provide the token back before movement executes. Claude CANNOT self-confirm movement - the token enforces this at the server level.
Inputs: confirmation_token. Returns: result
ugs_run_fileA
Stream a G-code file to the machine. Runs safety check in preview mode. Call with no token first to get the safety report and confirmation token. The user must provide the token back before the job starts. Claude CANNOT self-confirm - the token enforces this at the server level.
Inputs: file_path (required), confirmation_token. Returns: result
ugs_set_work_zeroA
Set G54 work zero at the current machine position for the specified axes. This does NOT move the machine - only sets coordinate offsets. Call with confirmed=False first to preview, then confirmed=True to apply.
Inputs: axes, confirmed. Returns: result
ugs_troubleshoot_connectionA
Diagnose connection issues: lists serial ports, checks pendant reachability, suggests fixes.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Every tool targets a distinct operation within two clear groups (gcode_ and ugs_). No two tools have overlapping purposes; even similar-sounding tools like ugs_get_job_status and ugs_get_status are clearly differentiated by scope.
All tools follow a consistent prefix (gcode_ or ugs_) combined with a verb or verb_noun pattern (e.g., gcode_estimate_time, ugs_run_file). The pattern is uniform, making it easy to infer tool behavior from the name.
With 19 tools, the server is slightly above the ideal 3-15 range but still reasonable for covering both G-code analysis and CNC control. Each tool serves a clear purpose, and no tools feel redundant.
The tool surface covers essential G-code operations (estimation, translation, safety, macros) and CNC control (connection, jogging, homing, job management). Minor gaps exist (e.g., no G-code editor, no spindle control), but core workflows are well-supported.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI assistants to control and monitor Klipper 3D printers via the Moonraker API. It supports comprehensive printer management, including G-code execution, toolchanger operations, and real-time status monitoring.30-
- AlicenseBqualityDmaintenanceBridges Claude Code to CNCjs to enable remote control and monitoring of GRBL-based CNC machines. It provides a comprehensive toolset for managing G-code jobs, machine movement, and safety operations through natural language.302MIT
- AlicenseAqualityDmaintenanceAn MCP server that enables Claude to control CNC routers running FluidNC firmware using natural language. It provides 27 tools for monitoring status, jogging axes, executing G-code, and managing SD card files and machine configurations.27MIT
- AlicenseAqualityDmaintenanceMCP server for controlling Meticulous espresso machines via Claude and other AI clients.22105 npmMIT