Skip to main content

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 validate
  • tolerance (float, optional, default: 0.01): Clipping tolerance in mm
  • minimise (string, optional, default: "soft"): Token removal strategy
    • soft: 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

  1. GCODECLEAN_PATH environment variable (custom override)
  2. Bundled binary for current platform (auto-detected)
  3. System PATH (GCC command)

License

AGPL-3.0. This project bundles GCodeClean binaries (AGPL-3.0).

Full license: resources/gcodeclean/1.4.2/LICENSE

References

Release files for mcp-server-gcodeclean 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-gcodeclean 0.2.0
File Size Uploaded
mcp_server_gcodeclean-0.2.0.tar.gz 44.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-gcodeclean 0.2.0
File Interpreter ABI Platform
mcp_server_gcodeclean-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 75.0 MB

Release files / mcp_server_gcodeclean-0.2.0.tar.gz

Download URL mcp_server_gcodeclean-0.2.0.tar.gz
Size 44.8 MB
Tags Source
SHA-256 checksum
How to use checksums
59d5e8c8e9d1b9869c400bdb1a7d6b88c7ae75f5c8d3ff9c28eff3f6e4ad711d
BLAKE2b-256 checksum
How to use checksums
5a979621d6e60f4c2883b70752686db81411513ed929cbd6707f86ab22d84f04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / mcp_server_gcodeclean-0.2.0-py3-none-any.whl

Download URL mcp_server_gcodeclean-0.2.0-py3-none-any.whl
Size 30.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1cb321c5d5e7a63f2dc9e60b0512e1c08197a5820cca83e2ff82f065ef9f00ae
BLAKE2b-256 checksum
How to use checksums
3f15f622922fdf89f302ea14c731d1d3f7d33e0e2391132804bfc5c3747ff521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page