MCP Hub
Back to servers

freecad-addon-robust-mcp-server

The FreeCAD Robust MCP server and MCP Bridge Workbench/Addon

GitHub
Stars
40
Forks
13
Updated
Mar 14, 2026
Validated
Mar 15, 2026

FreeCAD Robust MCP Server

License: MIT PyPI Version Python Versions Docker Image Version Documentation

CI Tests Docker Build Pre-commit CodeQL

An MCP (Model Context Protocol) server that enables integration between AI assistants (Claude, GPT, and other MCP-compatible tools) and FreeCAD, allowing AI-assisted development and debugging of 3D models, macros, and workbenches.

Table of Contents

The macros that were originally in this repo under the /macros directory have been permanently moved to two new GitHub repos:

FreeCAD Forum: addon discussion post

Features

  • 150+ MCP Tools: Comprehensive CAD operations including primitives, PartDesign, booleans, export
  • Multiple Connection Modes: XML-RPC (recommended), JSON-RPC socket, or embedded
  • GUI & Headless Support: Full modeling in headless mode, plus screenshots/colors in GUI mode
  • Macro Development: Create, edit, run, and template FreeCAD macros via MCP

Installation Requirements / Dependencies

  • FreeCAD 0.21+ or 1.0+
  • Python 3.11 (required for FreeCAD ABI compatibility)

For Users

This section covers installation and usage for end users who want to use the Robust MCP Server with AI assistants.

Quick Links

ResourceDescription
DocumentationFull documentation, guides, and API reference
Docker HubPre-built Docker images for easy deployment
PyPIPython package for pip installation
GitHub ReleasesRelease archives and changelogs

Robust MCP Server

Note: The Linux container and PyPI package are both named freecad-robust-mcp which differs slightly from this git repository name.

Installation

Using pip (recommended)

pip install freecad-robust-mcp

Using mise and just (from source)

git clone https://github.com/spkane/freecad-addon-robust-mcp-server.git
cd freecad-addon-robust-mcp-server

# Install mise via the Official mise installer script (if not already installed)
curl https://mise.run | sh

mise trust
mise install
just setup

Using Docker

Run the Robust MCP Server in a container. This is useful for isolated environments or when you don't want to install Python dependencies on your host.

# Pull from Docker Hub (when published)
docker pull spkane/freecad-robust-mcp

# Or build locally
git clone https://github.com/spkane/freecad-addon-robust-mcp-server.git
cd freecad-addon-robust-mcp-server
docker build -t freecad-robust-mcp .

# Or use just commands (if you have mise/just installed)
just docker::build        # Build for local architecture
just docker::build-multi  # Build multi-arch (amd64 + arm64)

Note: The containerized Robust MCP Server only supports xmlrpc and socket modes since FreeCAD runs on your host machine (not in the container). The container connects to FreeCAD via host.docker.internal.

Configuration

Environment Variables

VariableDescriptionDefault
FREECAD_MODEConnection mode: xmlrpc, socket, or embeddedxmlrpc
FREECAD_PATHPath to FreeCAD's lib directory (embedded mode only)Auto-detect
FREECAD_SOCKET_HOSTSocket/XML-RPC server hostnamelocalhost
FREECAD_SOCKET_PORTJSON-RPC socket server port9876
FREECAD_XMLRPC_PORTXML-RPC server port9875
FREECAD_TIMEOUT_MSExecution timeout in ms30000

Connection Modes

ModeDescriptionPlatform Support
xmlrpcConnects to FreeCAD via XML-RPC (port 9875)All platforms (recommended)
socketConnects via JSON-RPC socket (port 9876)All platforms
embeddedImports FreeCAD directly into processLinux only (crashes on macOS)

Note: Embedded mode crashes on macOS because FreeCAD's FreeCAD.so links to @rpath/libpython3.11.dylib, which conflicts with external Python interpreters. Use xmlrpc or socket mode on macOS and Windows.

MCP Client Configuration

Add something like the following to your MCP client settings. For Claude Code, this is ~/.claude/claude_desktop_config.json or a project .mcp.json file:

{
  "mcpServers": {
    "freecad": {
      "command": "freecad-mcp",
      "env": {
        "FREECAD_MODE": "xmlrpc"
      }
    }
  }
}

If installed from source with mise/uv:

{
  "mcpServers": {
    "freecad": {
      "command": "/path/to/mise/shims/uv",
      "args": ["run", "--project", "/path/to/freecad-addon-robust-mcp-server", "freecad-mcp"],
      "env": {
        "FREECAD_MODE": "xmlrpc"
      }
    }
  }
}

If using Docker:

{
  "mcpServers": {
    "freecad": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "--add-host=host.docker.internal:host-gateway",
        "-e", "FREECAD_MODE=xmlrpc",
        "-e", "FREECAD_SOCKET_HOST=host.docker.internal",
        "spkane/freecad-robust-mcp"
      ]
    }
  }
}

Docker configuration notes:

  • --rm removes the container after it exits
  • -i keeps stdin open for MCP communication
  • --add-host=host.docker.internal:host-gateway allows the container to connect to FreeCAD on your host (Linux only; macOS/Windows have this built-in)
  • FREECAD_SOCKET_HOST=host.docker.internal tells the Robust MCP Server to connect to FreeCAD on your host machine

Usage

Starting the MCP Bridge in FreeCAD

Before your AI assistant can connect, you need to start the MCP bridge inside FreeCAD:

Option A: Using the Workbench (Recommended)
  1. Install the Robust MCP Bridge workbench via FreeCAD's Addon Manager:

    • Edit -> Preferences -> Addon Manager
    • Search for "Robust MCP Bridge"
    • Install and restart FreeCAD
  2. Start the bridge:

    • Switch to the Robust MCP Bridge workbench
    • Click the Start MCP Bridge button in the toolbar
    • Or use the menu: MCP Bridge -> Start Bridge
  3. You should see in the FreeCAD console:

    MCP Bridge started!
      - XML-RPC: localhost:9875
      - Socket: localhost:9876
    
Option B: Using just commands (from source)
# Start FreeCAD with MCP bridge auto-started
just freecad::run-gui

# Or for headless/automation mode:
just freecad::run-headless

After starting the bridge, start/restart your MCP client (Claude Code, etc.) - it will connect automatically

Uninstalling the MCP Bridge

To uninstall the Robust MCP Bridge workbench:

  1. Open FreeCAD
  2. Go to Edit -> Preferences -> Addon Manager
  3. Find "Robust MCP Bridge" in the list
  4. Click Uninstall
  5. Restart FreeCAD
Checking for Legacy Components

If you previously used older versions of this project, you may have legacy components installed. Run this command to check what's installed and get cleanup instructions:

just install::status
Manual Cleanup (if needed)

Remove any legacy files that may conflict with the workbench:

# macOS - remove legacy plugin and macro
rm -rf ~/Library/Application\ Support/FreeCAD/Mod/MCPBridge/
rm -f ~/Library/Application\ Support/FreeCAD/Macro/StartMCPBridge.FCMacro

# Linux - remove legacy plugin and macro
rm -rf ~/.local/share/FreeCAD/Mod/MCPBridge/
rm -f ~/.local/share/FreeCAD/Macro/StartMCPBridge.FCMacro

Running Modes

XML-RPC Mode (Recommended)

Connects to a running FreeCAD instance via XML-RPC. Works on all platforms.

FREECAD_MODE=xmlrpc freecad-mcp
Socket Mode (JSON-RPC)

Connects via JSON-RPC socket. Works on all platforms.

FREECAD_MODE=socket freecad-mcp
Headless Mode

Run FreeCAD in console mode without GUI. Useful for automation.

# If installed from source:
just freecad::run-headless

Note: Screenshot and view features are not available in headless mode.

Embedded Mode (Linux Only)

Runs FreeCAD in-process. Only works on Linux - crashes on macOS/Windows.

FREECAD_MODE=embedded freecad-mcp

Available Tools

The Robust MCP Server provides 150+ tools organized into categories. Tools marked with GUI require FreeCAD to be running in GUI mode; they will return an error in headless mode.

Execution & Debugging (5 tools)

ToolDescriptionMode
execute_pythonExecute arbitrary Python code in FreeCAD's contextAll
get_freecad_versionGet FreeCAD version, build date, and Python versionAll
get_connection_statusCheck MCP bridge connection status and latencyAll
get_console_outputGet recent FreeCAD console output (up to N lines)All
get_mcp_server_environmentGet Robust MCP Server environment (OS, hostname, instance_id)All

Document Management (7 tools)

ToolDescriptionMode
list_documentsList all open documents with metadataAll
get_active_documentGet information about the active documentAll
create_documentCreate a new FreeCAD documentAll
open_documentOpen an existing .FCStd fileAll
save_documentSave a document to diskAll
close_documentClose a document (with optional save)All
recompute_documentForce recomputation of all objectsAll

Object Creation - Primitives (8 tools)

ToolDescriptionMode
create_objectCreate a generic FreeCAD object by type IDAll
create_boxCreate a Part::Box with length, width, heightAll
create_cylinderCreate a Part::Cylinder with radius, height, angleAll
create_sphereCreate a Part::Sphere with radiusAll
create_coneCreate a Part::Cone with two radii and heightAll
create_torusCreate a Part::Torus (donut) with radii and anglesAll
create_wedgeCreate a Part::Wedge (tapered box)All
create_helixCreate a Part::Helix curve for sweeps and threadsAll

Object Management (12 tools)

ToolDescriptionMode
list_objectsList all objects in a documentAll
inspect_objectGet detailed object info (properties, shape, etc.)All
edit_objectModify properties of an existing objectAll
delete_objectDelete an object from a documentAll
set_placementSet object position and rotationAll
scale_objectScale an object uniformly or non-uniformlyAll
rotate_objectRotate an object around an axisAll
copy_objectCreate a copy of an objectAll
mirror_objectMirror an object across a plane (XY, XZ, YZ)All
boolean_operationFuse, cut, or intersect objectsAll
get_selectionGet currently selected objectsGUI
set_selectionSelect specific objects by nameGUI
clear_selectionClear all selectionsGUI

PartDesign - Sketching (14 tools)

ToolDescriptionMode
create_partdesign_bodyCreate a PartDesign::Body containerAll
create_sketchCreate a sketch on a plane or faceAll
add_sketch_rectangleAdd a rectangle to a sketchAll
add_sketch_circleAdd a circle to a sketchAll
add_sketch_lineAdd a line (with optional construction flag)All
add_sketch_arcAdd an arc by center, radius, and anglesAll
add_sketch_pointAdd a point (useful for hole centers)All
pad_sketchExtrude a sketch (additive)All
pocket_sketchCut into solid using a sketch (subtractive)All
revolution_sketchRevolve a sketch around an axis (additive)All
groove_sketchRevolve a sketch around an axis (subtractive)All
create_holeCreate parametric holes with optional threadingAll
loft_sketchesCreate a loft through multiple sketchesAll
sweep_sketchSweep a profile along a spine pathAll

PartDesign - Patterns & Edges (5 tools)

ToolDescriptionMode
linear_patternCreate linear pattern of a featureAll
polar_patternCreate polar/circular pattern of a featureAll
mirrored_featureMirror a feature across a planeAll
fillet_edgesAdd fillets (rounded edges)All
chamfer_edgesAdd chamfers (beveled edges)All

View & Display (11 tools)

ToolDescriptionMode
get_screenshotCapture a screenshot of the 3D viewGUI
set_view_angleSet camera to standard views (Front, Top, etc.)GUI
fit_allZoom to fit all objects in viewGUI
zoom_inZoom in by a factorGUI
zoom_outZoom out by a factorGUI
set_camera_positionSet camera position and look-at pointGUI
set_object_visibilityShow/hide objectsGUI
set_display_modeSet display mode (Shaded, Wireframe, etc.)GUI
set_object_colorSet object color as RGB valuesGUI
list_workbenchesList available FreeCAD workbenchesAll
activate_workbenchSwitch to a different workbenchAll

Undo/Redo (3 tools)

ToolDescriptionMode
undoUndo the last operationAll
redoRedo a previously undone operationAll
get_undo_redo_statusGet available undo/redo operationsAll

Export/Import (7 tools)

ToolDescriptionMode
export_stepExport to STEP format (ISO CAD exchange)All
export_stlExport to STL format (3D printing)All
export_3mfExport to 3MF format (modern 3D printing)All
export_objExport to OBJ format (Wavefront)All
export_igesExport to IGES format (older CAD exchange)All
import_stepImport a STEP fileAll
import_stlImport an STL file as meshAll

Macro Management (6 tools)

ToolDescriptionMode
list_macrosList all available FreeCAD macrosAll
run_macroExecute a macro by nameAll
create_macroCreate a new macro fileAll
read_macroRead macro source codeAll
delete_macroDelete a user macroAll
create_macro_from_templateCreate macro from template (basic, part, etc.)All

Parts Library (2 tools)

ToolDescriptionMode
list_parts_libraryList parts in FreeCAD's parts libraryAll
insert_part_from_libraryInsert a part from the libraryAll

For Developers

This section covers development setup, contributing, and working with the codebase.

Robust MCP Server Development

Prerequisites

Initial Setup

# Clone the repository
git clone https://github.com/spkane/freecad-addon-robust-mcp-server.git
cd freecad-addon-robust-mcp-server

# Install mise via the Official mise installer script (if not already installed)
curl https://mise.run | sh

# Install all tools (Python 3.11, uv, just, pre-commit)
mise trust
mise install

# Set up the development environment
just setup

This installs:

  • Python 3.11 - Required for FreeCAD ABI compatibility
  • uv - Fast Python package manager
  • just - Command runner for development workflows
  • pre-commit - Git hooks for code quality

MCP Client Configuration (Development)

Create a .mcp.json file in the project directory:

{
  "mcpServers": {
    "freecad": {
      "command": "/path/to/mise/shims/uv",
      "args": ["run", "--project", "/path/to/freecad-addon-robust-mcp-server", "freecad-mcp"],
      "env": {
        "FREECAD_MODE": "xmlrpc",
        "FREECAD_SOCKET_HOST": "localhost",
        "FREECAD_XMLRPC_PORT": "9875",
        "PATH": "/path/to/mise/shims:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}

Replace the paths with your actual paths:

PlaceholderDescriptionExample
/path/to/mise/shims/uvFull path to uv via mise shims~/.local/share/mise/shims/uv
/path/to/freecad-addon-robust-mcp-serverProject directory/home/me/dev/freecad-addon-robust-mcp-server
/path/to/mise/shimsmise shims directory for PATH~/.local/share/mise/shims

Finding your mise shims path:

mise where uv | sed 's|/installs/.*|/shims|'
# Example: /home/user/.local/share/mise/shims (on Linux) or ~/.local/share/mise/shims (on macOS)

Development Workflow

Commands are organized into modules. Use just to see top-level commands, or just list-<module> to see module-specific commands.

# Show top-level commands and available modules
just

# Show commands in a specific module
just list-mcp           # Robust MCP Server commands
just list-freecad       # FreeCAD plugin/macro commands
just list-install       # Installation commands
just list-quality       # Code quality commands
just list-testing       # Test commands
just list-docker        # Docker commands
just list-documentation # Documentation commands
just list-dev           # Development utilities

# List ALL commands from all modules
just list-all

# Install/update dependencies
just install::mcp-server

# Run all checks (linting, type checking, tests)
just all

# Quality commands
just quality::lint       # Run ruff linter
just quality::typecheck  # Run mypy type checker
just quality::format     # Format code
just quality::check      # Run all pre-commit hooks

# Testing commands
just testing::unit       # Run unit tests
just testing::cov        # Run tests with coverage
just testing::integration # Run integration tests

# Run the Robust MCP Server (or with debug logging)
just mcp::run
just mcp::run-debug

# Docker commands
just docker::build        # Build image for local architecture
just docker::build-multi  # Build multi-arch image (amd64 + arm64)
just docker::run          # Run container

Running FreeCAD with the MCP Bridge

GUI Mode (recommended for development)

# Start FreeCAD with auto-started bridge
just freecad::run-gui

Headless Mode (for automation/CI)

just freecad::run-headless

Running Tests

# Unit tests only (no FreeCAD required)
just testing::unit

# Unit tests with coverage
just testing::cov

# Integration tests (requires running FreeCAD bridge)
just testing::integration

# Integration tests with automatic FreeCAD startup
just testing::integration-auto

Code Quality

The project uses strict code quality checks via pre-commit:

  • Ruff - Linting and formatting
  • MyPy - Type checking
  • Bandit - Security scanning
  • Codespell - Spell checking
  • Secrets scanning - Gitleaks, detect-secrets, TruffleHog
# Run all pre-commit hooks
just quality::check

# Run security/secrets scans
just quality::security
just quality::secrets

Architecture

See the detailed architecture document for design documentation covering:

  • Module structure
  • Bridge communication protocols
  • Tool registration patterns
  • FreeCAD plugin architecture

Acknowledgements

This project was developed after analyzing several existing FreeCAD Robust MCP implementations. We are grateful to these projects for their pioneering work and the ideas they contributed to the FreeCAD + AI ecosystem:

Related Projects

  • neka-nat/freecad-mcp (MIT License) - The queue-based thread safety pattern and XML-RPC protocol design (port 9875) were directly inspired by this project. Our implementation maintains protocol compatibility while being a complete rewrite with additional features.

  • jango-blockchained/mcp-freecad - Inspired our connection recovery mechanisms and multi-mode architecture approach.

  • contextform/freecad-mcp - Informed our comprehensive PartDesign and Part workbench tool coverage.

  • ATOI-Ming/FreeCAD-MCP - Inspired our macro development toolkit including templates, validation, and automatic imports.

  • bonninr/freecad_mcp - Influenced our simple socket-based communication approach.

See docs/COMPARISON.md for a detailed analysis of these implementations and the design decisions they informed.


License

MIT License - see LICENSE for details.

Reviews

No reviews yet

Sign in to write a review