FreeCAD MCP Server

FreeCAD MCP Server

Bridges Claude with a live FreeCAD instance to provide deep access to runtime state, document structure, and shape topology. It enables AI-assisted CAD work, sketch diagnostics, and development debugging through direct interaction with FreeCAD's internal data and viewport.

Category
访问服务器

README

FreeCAD MCP Server

An MCP (Model Context Protocol) server that bridges Claude with a live FreeCAD instance. It gives Claude deep access to FreeCAD's runtime state — document structure, object properties, shape topology, sketch constraint health, and more — enabling AI-assisted CAD work and FreeCAD development debugging.

What It Does

Unlike simple script-execution MCP servers, this project provides rich context extraction that lets Claude genuinely understand what's happening inside FreeCAD:

Tool What It Returns
list_documents All open documents with names, file paths, object counts
get_document_graph Full feature tree — every object with TypeId, properties, dependency links, validity state
inspect_object Complete property dump for a single object, with shape metadata
analyze_shape Topological analysis — face classifications (Plane/Cylinder/Cone/...), edge details, bounding box, volume
get_sketch_diagnostics Constraint health — DOF, conflicts, redundancies, every constraint and geometry element with coordinates
tracked_recompute Recompute with before/after diff — new errors, resolved errors, persistent errors
execute_script Run arbitrary Python inside FreeCAD (escape hatch for anything not covered above)
get_screenshot Capture the 3D viewport as a base64 PNG
reload_handlers Hot-reload handler code without restarting FreeCAD

Architecture

Claude (Code/Desktop)  ←stdio MCP→  Bridge Server  ←TCP:9876→  FreeCAD Addon
                                     (this project)              (inside FreeCAD)

The project has two components:

  1. FreeCAD addon (freecad_addon/) — runs inside FreeCAD as a workbench. Starts a threaded TCP server that accepts JSON-RPC requests and executes them on FreeCAD's main thread via a QTimer-polled work queue.

  2. MCP bridge server (src/freecad_mcp_agent/) — spawned by Claude via stdio. Connects to the addon over TCP and translates MCP tool calls into JSON-RPC requests.

Installation

1. Install the MCP bridge

# Clone the repo
git clone https://github.com/theosib/FreeCAD-MCP-Server.git
cd FreeCAD-MCP-Server

# Create a venv and install
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

2. Install the FreeCAD addon

FreeCAD doesn't reliably follow symlinks on macOS, so we use a thin loader file.

Find your FreeCAD Mod directory:

  • macOS: ~/Library/Application Support/FreeCAD/Mod/ (or ~/Library/Application Support/FreeCAD/v1-2/Mod/ for weekly builds)
  • Linux: ~/.local/share/FreeCAD/Mod/
  • Windows: %APPDATA%/FreeCAD/Mod/

Tip: Run FreeCAD.getUserAppDataDir() in FreeCAD's Python console to find the exact path.

Create the loader:

mkdir -p "<your-mod-dir>/FreeCADMCPAgent"

Create <your-mod-dir>/FreeCADMCPAgent/InitGui.py with:

import sys
_ADDON_DIR = "/absolute/path/to/FreeCAD-MCP-Server/freecad_addon"
if _ADDON_DIR not in sys.path:
    sys.path.insert(0, _ADDON_DIR)
_project_init = _ADDON_DIR + "/InitGui.py"
_ns = dict(globals())
_ns["__file__"] = _project_init
with open(_project_init) as _f:
    exec(compile(_f.read(), _project_init, "exec"), _ns)

Replace /absolute/path/to/FreeCAD-MCP-Server with the actual path to your clone.

3. Configure Claude Code

Add a .mcp.json to your working directory (or FreeCAD source tree):

{
  "mcpServers": {
    "freecad-debug": {
      "command": "/absolute/path/to/FreeCAD-MCP-Server/.venv/bin/freecad-mcp-agent",
      "env": {
        "FREECAD_MCP_HOST": "127.0.0.1",
        "FREECAD_MCP_PORT": "9876"
      }
    }
  }
}

Usage

  1. Start FreeCAD. The RPC server auto-starts on port 9876 (you'll see "MCP Debug Agent: RPC server auto-started" in FreeCAD's console). Set FREECAD_MCP_NO_AUTOSTART=1 to disable auto-start.

  2. Launch Claude Code in a directory with the .mcp.json config.

  3. Use the tools. Claude can now inspect your FreeCAD model:

"What objects are in the current document?"

"The Pocket001 feature looks wrong — can you diagnose it?"

"Is Sketch003 fully constrained? Are there any conflicts?"

"Recompute the document and tell me what changed."

Use Case: FreeCAD Development Debugging

This project was designed for debugging FreeCAD itself. When the .mcp.json is placed in a FreeCAD source tree, Claude Code gets simultaneous access to:

  • Source code — C++ and Python files, git history, build system (via Claude Code's native file access)
  • Live runtime state — object properties, shape topology, constraint solver state (via MCP tools)

This lets Claude correlate what the code should do with what the runtime actually produced. See docs/freecad-fork-instructions.md for detailed workflows and a TypeId-to-source-file mapping table.

Environment Variables

Variable Default Purpose
FREECAD_MCP_HOST 127.0.0.1 RPC server host
FREECAD_MCP_PORT 9876 RPC server port
FREECAD_MCP_NO_AUTOSTART (unset) Set to 1 to disable auto-start of the RPC server

Project Structure

FreeCAD-MCP-Server/
├── pyproject.toml                  # Python package config
├── src/freecad_mcp_agent/
│   ├── server.py                   # MCP server (stdio, all tool definitions)
│   └── bridge.py                   # TCP client connecting to FreeCAD addon
├── freecad_addon/
│   ├── InitGui.py                  # Workbench registration + auto-start
│   ├── mcp_commands.py             # Start/Stop commands, handler registration
│   ├── rpc_server.py               # Threaded TCP server + main-thread dispatch
│   ├── package.xml                 # FreeCAD addon metadata
│   └── handlers/
│       ├── document.py             # list_documents, get_document_graph
│       ├── inspection.py           # inspect_object, analyze_shape
│       ├── sketcher.py             # get_sketch_diagnostics
│       ├── recompute.py            # tracked_recompute
│       ├── execution.py            # execute_script
│       └── viewport.py             # get_screenshot
└── docs/
    └── freecad-fork-instructions.md

License

LGPL-2.1-or-later (same as FreeCAD)

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选