Skip to main content
Glama
freecad-mcp

freecad-mcp

README.md
# freecad-mcp

MCP (Model Context Protocol) server for FreeCAD parametric 3D CAD modeling. Provides 165 tools across 15 modules for document management, primitives, booleans, sketching, part design, meshing, FEM, BIM, and more.

## Prerequisites

- [Node.js](https://nodejs.org/) >= 18
- [FreeCAD](https://www.freecad.org/) 0.21 or later installed

## Installation

```bash
git clone https://github.com/sergiudanstan/freecad-mcp.git
cd freecad-mcp
npm install
npm run build
```

## Setup

The server supports two modes: **GUI mode** (recommended) and **headless mode** (fallback).

### GUI Mode (recommended)

GUI mode connects to a running FreeCAD instance so you can see changes live in the 3D viewport.

**Step 1 — Start the FreeCAD socket server macro:**

1. Open FreeCAD
2. Go to **Macro > Macros...**
3. Click **"..."** (browse) and navigate to the `freecad_server.FCMacro` file in this repo
4. Select it and click **Execute**
5. You should see in the FreeCAD console:
   ```
   MCP Socket Server listening on 127.0.0.1:12345
   MCP Server macro loaded. Waiting for connections...
   ```

The macro must be running **before** the MCP server connects. The server auto-detects the socket on startup.

**Step 2 — Configure your MCP client:**

Add the server to your MCP client configuration. For Claude Code, add to `~/.claude/settings.json`:

```json
{
  "mcpServers": {
    "freecad": {
      "command": "node",
      "args": ["/path/to/freecad-mcp/dist/index.js"]
    }
  }
}
```

Or via the CLI:

```bash
claude mcp add freecad node /path/to/freecad-mcp/dist/index.js
```

### Headless Mode (fallback)

If FreeCAD GUI is not running, the server automatically falls back to headless mode using `freecadcmd`. This works for scripting and automation but you won't see visual output.

The server looks for `freecadcmd` at `/Applications/FreeCAD.app/Contents/Resources/bin/freecadcmd` by default. Override with:

```json
{
  "mcpServers": {
    "freecad": {
      "command": "node",
      "args": ["/path/to/freecad-mcp/dist/index.js"],
      "env": {
        "FREECAD_CMD": "/your/path/to/freecadcmd"
      }
    }
  }
}
```

## Tool Modules

| Module | Tools | Description |
|--------|-------|-------------|
| Document | 7 | New, open, save, close, list objects, get info |
| Primitives | 11 | Box, cylinder, sphere, cone, torus, tube, prism, helix, spiral, ellipsoid, wedge |
| Operations | 17 | Boolean (fuse/cut/intersect/XOR/fragments), fillet, chamfer, move, rotate, copy, mirror, slice |
| Sketcher | 12 | Create sketches, add lines, arcs, circles, constraints, close/validate |
| Part Design | 10 | Pad, pocket, revolve, hole, groove, chamfer, fillet, mirror, linear/polar pattern |
| Import/Export | 16 | STEP, STL, OBJ, IGES, DXF, SVG, BREP import/export, measurements, Python execution |
| Draft | 10 | Wire, rectangle, circle, polygon, BSpline, array, clone, offset, upgrade/downgrade |
| Mesh | 7 | Tessellate, mesh-to-shape, repair, decimate, refine, info, boolean |
| TechDraw | 8 | Drawing pages, views, dimensions, annotations |
| Advanced | 12 | Loft, sweep, pipe, thickness, offset surface, section, projection |
| Spreadsheet | 6 | Create, set cells, get cells, alias, formulas |
| BIM | 8 | Walls, columns, slabs, windows, roofs, stairs, spaces |
| FEM | 10 | Analysis, material, constraints, mesh generation, solver |
| Surface | 8 | Filling, curves on mesh, extending, trimming |
| Assembly | 8 | Assembly creation, constraints, bill of materials |

## Security

- All inputs are validated at runtime (numeric ranges, string sanitization, path traversal prevention)
- File operations block access to system paths (`/etc/`, `/proc/`, etc.)
- The `freecad_execute_python` tool allows arbitrary Python execution by design — only use in trusted environments
- The GUI socket server listens only on localhost (`127.0.0.1:12345`)

See [SECURITY.md](SECURITY.md) for vulnerability reporting.

## License

[MIT](LICENSE) - Dan Stan

TDQS

C2.8/5.0

Scored across 165 tools

Disambiguation2/5

Several tool pairs are near-duplicates: freecad_fillet vs freecad_partdesign_fillet, freecad_thickness vs freecad_partdesign_thickness, freecad_mirror_object vs freecad_partdesign_mirrored, freecad_linear_array vs freecad_linear_pattern, and freecad_extrude vs freecad_pad. The descriptions hint at Part vs PartDesign contexts, but with 165 tools an agent has many plausible-looking candidates for a single action, making misselection likely.

Naming Consistency4/5

Almost every tool follows a freecad_ prefix plus snake_case action, and workbench-scoped tools (draft_, partdesign_, arch_, fem_, assembly_, techdraw_, surface_, mesh_) are grouped predictably. A few names are noun-only (freecad_fillet, freecad_pad, freecad_hole) and verb choices vary slightly (create_/add_/import_), but overall the pattern is reliable.

Tool Count1/5

165 tools is far beyond what an agent can navigate effectively in one surface, even for a CAD domain as broad as FreeCAD. Many workbenches (FEM, TechDraw, Arch/BIM, Surface, Assembly) could be separate, opt-in tool sets instead of one flat list.

Completeness4/5

Coverage is remarkably broad: document lifecycle, primitives, booleans, sketching, PartDesign features, Draft, mesh ops, import/export across STEP/STL/OBJ/IGES/DXF/SVG/BREP/IFC, TechDraw, spreadsheet-driven parametric design, FEM, surfaces, and assemblies with joints. Minor gaps remain (no undo/history, limited view/camera control, thin annotation features), but core workflows have no dead ends.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues