Cover image
Try Now
2025-03-20

FreeCADMCP通过模型上下文协议(MCP)将FREECAD连接到Claude AI和其他适合MCP的工具(例如光标),从而使Claude可以直接与FreeCad进行交互并控制。此集成启用及时辅助CAD 3D设计。

3 years

Works with Finder

1

Github Watches

7

Github Forks

41

Github Stars

FreeCAD MCP (Model Control Protocol)

Overview

The FreeCAD MCP (Model Control Protocol) provides a simplified interface for interacting with FreeCAD through a server-client architecture. This allows users to execute commands and retrieve information about the current FreeCAD document and scene.

https://github.com/user-attachments/assets/5acafa17-4b5b-4fef-9f6c-617e85357d44

Configuration

To configure the MCP server, you can use a JSON format to specify the server settings. Below is an example configuration:

{
    "mcpServers": {
        "freecad": {
            "command": "C:\\ProgramData\\anaconda3\\python.exe",
            "args": [
                "C:\\Users\\USER\\AppData\\Roaming\\FreeCAD\\Mod\\freecad_mcp\\src\\freecad_bridge.py"
            ]
        }
    }
}

Configuration Details

  • command: The path to the Python executable that will run the FreeCAD MCP server. This can vary based on your operating system:

    • Windows: Typically, it might look like C:\\ProgramData\\anaconda3\\python.exe or C:\\Python39\\python.exe.
    • Linux: It could be /usr/bin/python3 or the path to your Python installation.
    • macOS: Usually, it would be /usr/local/bin/python3 or the path to your Python installation.
  • args: An array of arguments to pass to the Python command. The first argument should be the path to the freecad_bridge.py script, which is responsible for handling the MCP server logic. Make sure to adjust the path according to your installation.

Example for Different Operating Systems

Windows

{
    "mcpServers": {
        "freecad": {
            "command": "C:\\ProgramData\\anaconda3\\python.exe",
            "args": [
                "C:\\Users\\USER\\AppData\\Roaming\\FreeCAD\\Mod\\freecad_mcp\\src\\freecad_bridge.py"
            ]
        }
    }
}

Linux

{
    "mcpServers": {
        "freecad": {
            "command": "/usr/bin/python3",
            "args": [
                "/home/USER/.FreeCAD/Mod/freecad_mcp/src/freecad_bridge.py"
            ]
        }
    }
}

macOS

{
    "mcpServers": {
        "freecad": {
            "command": "/usr/local/bin/python3",
            "args": [
                "/Users/USER/Library/Preferences/FreeCAD/Mod/freecad_mcp/src/freecad_bridge.py"
            ]
        }
    }
}

Features

The FreeCAD MCP currently supports the following functionalities:

1. get_scene_info

  • Description: Retrieves comprehensive information about the current FreeCAD document, including:
    • Document properties (name, label, filename, object count)
    • Detailed object information (type, position, rotation, shape properties)
    • Sketch data (geometry, constraints)
    • View information (camera position, direction, etc.)

2. run_script

  • Description: Executes arbitrary Python code within the FreeCAD context. This allows users to perform complex operations, create new objects, modify existing ones, and automate tasks using FreeCAD's Python API.

Example Usage

To use the FreeCAD MCP, you can connect to the server and send commands as follows:

import socket
import json

# Connect to the FreeCAD MCP server
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('localhost', 9876))

# Example: Get scene information
command = {
    "type": "get_scene_info"
}
client.sendall(json.dumps(command).encode('utf-8'))

# Receive the response
response = client.recv(4096)
print(json.loads(response.decode('utf-8')))

# Example: Run a script
script = """
import FreeCAD
doc = FreeCAD.ActiveDocument
box = doc.addObject("Part::Box", "MyBox")
box.Length = 20
box.Width = 20
box.Height = 20
doc.recompute()
"""
command = {
    "type": "run_script",
    "params": {
        "script": script
    }
}
client.sendall(json.dumps(command).encode('utf-8'))

# Receive the response
response = client.recv(4096)
print(json.loads(response.decode('utf-8')))

# Close the connection
client.close()

Installation

  1. Clone the repository or download the files.
  2. Place the freecad_mcp directory in your FreeCAD modules directory:
    • Windows: %APPDATA%/FreeCAD/Mod/
    • Linux: ~/.FreeCAD/Mod/
    • macOS: ~/Library/Preferences/FreeCAD/Mod/
  3. Restart FreeCAD and select the "FreeCAD MCP" workbench from the workbench selector.

Contributing

Feel free to contribute by submitting issues or pull requests. Your feedback and contributions are welcome!

License

This project is licensed under the MIT License. See the LICENSE file for details.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

    Reviews

    2 (1)
    Avatar
    user_YUEG22E6
    2025-04-18

    As a devoted user of freecad_mcp, I must say this is an absolute game-changer for anyone passionate about 3D modeling. Bonninr has done a fantastic job in creating a versatile and user-friendly application. It's packed with features that cater to both beginners and professional users, making model creation a breeze. Highly recommend checking it out at https://github.com/bonninr/freecad_mcp!