MCP server for G-code syntax validation using GCodeClean
Project description
mcp-server-gcodeclean
MCP server for G-code syntax validation and cleaning using GCodeClean. Validates G-code against NIST RS274 standards with bundled binaries for all platforms.
Installation
From PyPI (Recommended)
# Using uvx (recommended for MCP servers)
uvx mcp-server-gcodeclean
# Using pip
pip install mcp-server-gcodeclean
From Source
git clone https://github.com/ivan-loh/mcp-server-gcodeclean.git
cd mcp-server-gcodeclean
uv sync
Requirements:
- Python 3.10+
- uv (for development)
- Claude Desktop
Configuration
Add to Claude Desktop config:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Using uvx (PyPI installation)
{
"mcpServers": {
"gcodeclean": {
"command": "uvx",
"args": ["mcp-server-gcodeclean"]
}
}
}
Using local installation
{
"mcpServers": {
"gcodeclean": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-server-gcodeclean",
"run",
"mcp-server-gcodeclean"
]
}
}
}
Optional: Override bundled binary with custom path:
{
"mcpServers": {
"gcodeclean": {
"command": "uv",
"args": ["--directory", "/path/to/mcp-server-gcodeclean", "run", "mcp-server-gcodeclean"],
"env": {
"GCODECLEAN_PATH": "/path/to/custom/GCC"
}
}
}
}
Tools
validate_gcode_syntax
Validates and cleans G-code programs.
Parameters:
gcode_content(string, required): G-code to validatetolerance(float, optional, default: 0.01): Clipping tolerance in mmminimise(string, optional, default: "soft"): Token removal strategysoft: Remove F/Z codes only (10-20% reduction)medium: Remove all except IJK+spaces (30-50% reduction)hard: Maximum compression (50-70% reduction)
annotate(boolean, optional, default: false): Add explanatory comments
Response:
{
"status": "PASSED",
"passed": true,
"cleaned_gcode": "...",
"statistics": {
"original_lines": 100,
"output_lines": 85,
"reduction_percent": 25.0
},
"error": null
}
Status values: PASSED, FAILED, ERROR, TIMEOUT
Limits: 10MB max file size, 30 second timeout
get_gcodeclean_version
Verifies GCodeClean installation and returns diagnostic information.
Response:
{
"status": "SUCCESS",
"binary_path": "/path/to/GCC",
"platform": {
"os": "Darwin",
"architecture": "arm64"
},
"version_output": "1.4.2",
"exit_code": 0
}
Platform Support
Bundled binaries included for:
- Linux x64
- Linux ARM/aarch64
- macOS Intel (x64)
- macOS Apple Silicon (arm64)
- Windows x64
Total size: ~70MB. No .NET runtime required.
Development
Project Structure
mcp-server-gcodeclean/
├── src/mcp_server_gcodeclean/
│ └── server.py # Main implementation
├── resources/gcodeclean/
│ ├── version.json # Version metadata
│ └── 1.4.2/ # Platform binaries
├── tests/ # Test suite (42+ tests)
├── pyproject.toml
└── README.md
Running Tests
uv run python tests/test_server.py # Unit tests
uv run python tests/test_defaults_and_overrides.py # Comprehensive tests
Running Server
uv run mcp-server-gcodeclean
Troubleshooting
Binary not found:
ls -la resources/gcodeclean/1.4.2/
uv run python -c "from mcp_server_gcodeclean.server import get_gcodeclean_path; print(get_gcodeclean_path())"
Permission denied:
chmod +x resources/gcodeclean/1.4.2/*/GCC*
File too large: Split G-code into sections under 10MB
Validation timeout: File is very complex. Try validating in smaller sections or increase tolerance value.
Binary Selection Priority
GCODECLEAN_PATHenvironment variable (custom override)- Bundled binary for current platform (auto-detected)
- System PATH (
GCCcommand)
License
AGPL-3.0. This project bundles GCodeClean binaries (AGPL-3.0).
Full license: resources/gcodeclean/1.4.2/LICENSE
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_gcodeclean-0.1.0.tar.gz.
File metadata
- Download URL: mcp_server_gcodeclean-0.1.0.tar.gz
- Upload date:
- Size: 30.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a122b4e5dd5ab5dfe589af1b41e2701819f2d99bb1a2f3874c90df5ec89dceb
|
|
| MD5 |
2aa47be4adffe529f11b3f19eb59e67b
|
|
| BLAKE2b-256 |
980c054a0db0d2a5d808e8bbb502e982a88ecb4cc507368f8da768639fc5b587
|
File details
Details for the file mcp_server_gcodeclean-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_server_gcodeclean-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fd1b44d6e7cd06a3c1b1eca9d8da28d40e365602302929274002dad088756dd
|
|
| MD5 |
3d5e6c8b7b094d87b3f479dfbb7a3684
|
|
| BLAKE2b-256 |
8f5b6e6c9eb6f787a767f1999cf9e0d7ccd1d4876aadcb63b186dda90f6ff4b5
|