fcgen-mcp
Enables LLMs to safely generate parametric CAD parts (STEP/STL) using verified templates and FreeCAD, with validation and assembly support.
README
fcgen-mcp
An MCP server that lets LLMs safely generate parametric CAD parts through verified templates and FreeCAD.
LLM が検証済みテンプレートを通じて安全にパラメトリック CAD パーツを生成する MCP サーバー
What is this?
Large Language Models can describe mechanical parts in natural language, but giving them unconstrained access to a CAD kernel is a recipe for broken geometry, invalid dimensions, and non-manufacturable output. fcgen-mcp solves this by placing a structured safety layer between the LLM and FreeCAD.
Instead of generating raw CAD scripts, the LLM selects from verified parametric templates, fills in parameters validated against JSON Schema and semantic rules, and receives deterministic STEP/STL output.
┌─────────────────────────────────┐
│ LLM (Claude, etc.) │
└────────────┬──────────────────────┘
│ MCP protocol
┌────────────▼──────────────────────┐
│ fcgen MCP Server │
│ ┌───────────┐ ┌──────────────┐ │
│ │ JSON │ │ Semantic │ │
│ │ Schema │ │ Validation │ │
│ └─────┬─────┘ └──────┬───────┘ │
│ └────────┬──────┘ │
│ ┌────────▼─────────┐ │
│ │ Template Registry │ │
│ │ (verified only) │ │
│ └────────┬─────────┘ │
└────────────────┼─────────────────┘
│ headless execution
┌────────────────▼─────────────────┐
│ FreeCAD (freecadcmd) │
│ → STEP / STL output │
└──────────────────────────────────┘
Key Features
- 11 MCP tools -- complete workflow from discovery to generation, including assembly
- Template registry with candidate → verified lifecycle for quality control
- JSON Schema + semantic validation -- catches invalid geometry before it reaches FreeCAD
- Multi-part assembly with explicit placement (position + rotation)
- FreeCAD headless generation -- produces industry-standard STEP and STL files
- Deterministic artifact hashing -- identical parameters always produce identical output
Quick Start
Installation
pip install -e ".[mcp]"
Launch the MCP server
python -m fcgen.mcp.server
Claude Desktop configuration
Add to your Claude Desktop claude_desktop_config.json:
{
"mcpServers": {
"fcgen": {
"command": "python",
"args": ["-m", "fcgen.mcp.server"]
}
}
}
FreeCAD setup
If freecadcmd is not on your PATH, set the environment variable:
export FCGEN_FREECADCMD="/path/to/freecadcmd"
Windows:
set FCGEN_FREECADCMD=C:\Program Files\FreeCAD 1.0\bin\freecadcmd.exe
MCP Tools Reference
| Tool | Description |
|---|---|
check_freecad |
Verify FreeCAD is available and return version info |
list_templates |
List all verified templates with purpose, tags, and parameter count |
get_template_schema |
Return the full JSON Schema for a template |
get_template_example |
Return example parameters for a template |
validate_params |
Dry-run validation (schema + semantic) without generating output |
find_template |
Search templates by purpose description, ranked by simplicity |
generate_part |
Generate a single CAD part (STEP/STL) from a verified template |
generate_assembly |
Generate a multi-part assembly with placement |
list_candidates |
List unverified candidate templates |
propose_template |
Register a new template as a candidate |
verify_template |
Run verification checks and promote candidate to verified |
Usage Examples
Example 1: Discover and generate a bracket
A typical MCP tool call flow follows five steps -- discover, inspect, preview, validate, generate:
1. list_templates → see what's available
2. get_template_schema → inspect full parameter schema
3. get_template_example → get working sample parameters
4. validate_params → dry-run safety check
5. generate_part → produce STEP/STL files
Step 1 -- list_templates returns all verified templates:
{
"templates": {
"bracket": {
"purpose": "L-bracket with configurable holes",
"tags": ["structural", "mounting"],
"param_count": 10,
"top_level_keys": ["units", "material_hint", "bracket", "output"],
"has_example": true
},
"adapter_plate": {
"purpose": "Flat plate with two bolt circle patterns",
"tags": ["structural", "mounting", "plate"],
"param_count": 12,
"top_level_keys": ["units", "material_hint", "adapter_plate", "output"],
"has_example": true
}
}
}
Step 3 -- get_template_example("bracket") returns ready-to-use parameters:
{
"units": "mm",
"material_hint": "al6061",
"bracket": {
"thickness": 3.0,
"leg_a": 40.0,
"leg_b": 60.0,
"width": 25.0,
"fillet": 1.0,
"chamfer": 0.5,
"holes": {
"pattern": "line",
"diameter": 5.5,
"count": 2,
"edge_offset": 8.0
}
},
"output": { "step": true, "stl": true, "tolerance": 0.1 }
}
Step 4 -- validate_params("bracket", params) confirms validity before generation:
{ "valid": true }
Step 5 -- generate_part("bracket", params) produces the CAD files:
{
"ok": true,
"result": {
"template": "bracket",
"artifact_hash": "77bd1e4cb686862707a2977db293aaed...",
"freecad_version": "1.0.0",
"outputs": {
"step": "output/bracket/model.step",
"stl": "output/bracket/model.stl",
"report_json": "output/bracket/report.json",
"report_md": "output/bracket/report.md"
}
}
}
Example 2: Multi-part bolted assembly
The generate_assembly tool composes multiple parts with explicit placement. Here is a 7-part assembly: an adapter plate, two L-brackets, and four bolts.
{
"units": "mm",
"parts": [
{
"id": "base",
"template": "adapter_plate",
"params": { "...adapter_plate params..." },
"placement": { "position": [0, 0, 0], "rotation": [0, 0, 0] }
},
{
"id": "bracket_upper",
"template": "bracket",
"params": { "...bracket params..." },
"placement": { "position": [67.622, 17.417, 6.0], "rotation": [135, 0, 0] }
},
{
"id": "bracket_lower",
"template": "bracket",
"params": { "...bracket params..." },
"placement": { "position": [-67.622, -17.417, 6.0], "rotation": [-45, 0, 0] }
},
{
"id": "bolt_1",
"template": "bolt",
"params": { "...bolt params..." },
"placement": { "position": [53.126, 14.235, 9.0], "rotation": [0, 0, 0] }
}
],
"output": { "step": true, "stl": true }
}
Each part is generated independently with full validation, then placed in a combined STEP/STL assembly. The remaining three bolts follow the same pattern at their respective positions.
Template Lifecycle
Templates go through a quality gate before they can be used for generation:
[Create files] → propose_template → candidate → verify_template → verified
│ │
▼ ▼
templates_candidate/ templates/
- Candidate: template files exist and are registered, but not yet validated
- Verified: passed schema checks, test generation, and semantic validation -- available to
generate_part
LLMs can only generate parts from verified templates.
Available Templates
| Template | Description | Param Count |
|---|---|---|
bracket |
L-bracket with configurable holes, fillet, and chamfer | 10 |
adapter_plate |
Flat plate with two bolt circle patterns (PCD) | 12 |
enclosure |
Rectangular box with lid and screw bosses | 10 |
bolt |
Simple cylindrical bolt with head | 4 |
table_top |
Flat table top plate with optional edge fillet | 4 |
simple_leg |
Rectangular leg with chamfer and mounting hole | 5 |
Creating Custom Templates
Each template is a directory containing four files:
templates_candidate/my_part/
├── schema.json # JSON Schema defining all parameters
├── generator.py # Python logic: params → FreeCAD script args
├── freecad_generate.py # FreeCAD script: runs inside freecadcmd
└── examples/
└── basic.json # Working example parameters
Workflow:
- Create the template directory and files under
templates_candidate/ - Call
propose_template("my_part", purpose="...", tags=[...])to register it - Call
verify_template("my_part")to run automated checks - On success, the template is promoted to
templates/and becomes available for generation
FreeCAD Compatibility
| Version | |
|---|---|
| Minimum | FreeCAD 0.19+ |
| Recommended | FreeCAD 1.0 |
| Tested | 0.21, 1.0 |
The project uses FreeCAD's Part module (primitives, booleans), Mesh module (STL export), and basic Placement API.
Project Structure
src/fcgen/
├── mcp/server.py # MCP tools (primary interface for LLMs)
├── core/runner.py # Generation engine
├── assembly/engine.py # Multi-part assembly with placement
├── validators/
│ ├── semantic.py # Dimensional & geometric validation
│ └── geometry.py # Geometry constraint checks
├── registry.py # Template lifecycle management
└── cli/main.py # CLI interface (secondary)
templates/ # Verified templates (ready for generation)
templates_candidate/ # Candidate templates (pending verification)
tests/ # Test suite
Documentation
| Document | Description |
|---|---|
| Quick Start | Build a desk in 5 minutes |
| MCP Tools Reference | All 11 MCP tools with examples |
| Template Guide | How to create custom templates |
| Assembly Guide | Multi-part assembly creation |
Assembly Examples
Pre-built assembly examples in templates/assembly_examples/:
| File | Description |
|---|---|
simple_desk.json |
Standard 4-leg desk (1200 x 600 x 725mm) |
compact_desk.json |
Compact desk for small rooms (800 x 500 x 700mm) |
standing_desk.json |
Standing desk (1400 x 700 x 1050mm) |
desk_with_shelf.json |
Desk with under-shelf storage |
plate_brackets_bolts.json |
Bolted plate assembly with L-brackets |
plate_with_brackets.json |
Plate with L-brackets |
Development
Install in development mode with MCP support:
pip install -e ".[mcp]"
Run the test suite:
python -m pytest tests/ -v
There are currently 39 tests covering validation, generation, registry operations, and assembly logic.
License
MIT -- Copyright (c) 2026 kouya-group
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。