Skip to main content

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 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_gcodeclean-0.1.0.tar.gz (30.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_gcodeclean-0.1.0-py3-none-any.whl (30.2 MB view details)

Uploaded Python 3

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

Hashes for mcp_server_gcodeclean-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a122b4e5dd5ab5dfe589af1b41e2701819f2d99bb1a2f3874c90df5ec89dceb
MD5 2aa47be4adffe529f11b3f19eb59e67b
BLAKE2b-256 980c054a0db0d2a5d808e8bbb502e982a88ecb4cc507368f8da768639fc5b587

See more details on using hashes here.

File details

Details for the file mcp_server_gcodeclean-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_gcodeclean-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fd1b44d6e7cd06a3c1b1eca9d8da28d40e365602302929274002dad088756dd
MD5 3d5e6c8b7b094d87b3f479dfbb7a3684
BLAKE2b-256 8f5b6e6c9eb6f787a767f1999cf9e0d7ccd1d4876aadcb63b186dda90f6ff4b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page