FreeCAD MCP

by bonninr

Integrations

  • Enables creation and manipulation of 3D objects, parametric modeling operations, document management, and export/import capabilities in FreeCAD through natural language commands.

FreeCAD MCP(模型控制协议)

概述

FreeCAD MCP(模型控制协议)提供了一个简化的接口,用于通过服务器-客户端架构与 FreeCAD 进行交互。这允许用户执行命令并检索有关当前 FreeCAD 文档和场景的信息。

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

配置

要配置 MCP 服务器,您可以使用 JSON 格式指定服务器设置。以下是示例配置:

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

配置详细信息

  • command :运行 FreeCAD MCP 服务器的 Python 可执行文件的路径。这可能会因操作系统而异:
    • Windows :通常,它可能看起来像C:\\ProgramData\\anaconda3\\python.exeC:\\Python39\\python.exe
    • Linux :它可以是/usr/bin/python3或 Python 安装的路径。
    • macOS :通常,它是/usr/local/bin/python3或 Python 安装的路径。
  • args :传递给 Python 命令的参数数组。第一个参数应为freecad_bridge.py脚本的路径,该脚本负责处理 MCP 服务器逻辑。请务必根据您的安装情况调整路径。

不同操作系统的示例

视窗
{ "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" ] } } }

特征

FreeCAD MCP 目前支持以下功能:

1. get_scene_info

  • 描述:检索有关当前 FreeCAD 文档的综合信息,包括:
    • 文档属性(名称、标签、文件名、对象数量)
    • 详细的对象信息(类型、位置、旋转、形状属性)
    • 草图数据(几何形状、约束)
    • 查看信息(摄像机位置、方向等)

2. run_script

  • 描述:在 FreeCAD 环境中执行任意 Python 代码。这允许用户使用 FreeCAD 的 Python API 执行复杂的操作、创建新对象、修改现有对象以及自动执行任务。

示例用法

要使用 FreeCAD MCP,您可以连接到服务器并发送以下命令:

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()

安装

  1. 克隆存储库或下载文件。
  2. freecad_mcp目录放在您的 FreeCAD 模块目录中:
    • Windows: %APPDATA%/FreeCAD/Mod/
    • Linux: ~/.FreeCAD/Mod/
    • macOS: ~/Library/Preferences/FreeCAD/Mod/
  3. 重新启动 FreeCAD 并从工作台选择器中选择“FreeCAD MCP”工作台。

贡献

欢迎通过提交问题或拉取请求来贡献代码。欢迎您的反馈和贡献!

执照

本项目遵循 MIT 许可证。详情请参阅 LICENSE 文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

一个实现模型上下文协议 (MCP) 的 FreeCAD 插件,以实现 FreeCAD 和 Claude AI 通过 Claude Desktop 之间的通信。

  1. Overview
    1. Configuration
      1. Configuration Details
      2. Example for Different Operating Systems
    2. Features
      1. 1. get_scene_info
      2. 2. run_script
      3. Example Usage
    3. Installation
      1. Contributing
        1. License

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            Connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender for AI-assisted 3D modeling, scene manipulation, and rendering.
            Last updated -
            10,093
            Python
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            This repository is a FreeCAD MCP that allows you to control FreeCAD from Claude Desktop.
            Last updated -
            10
            111
            Python
            MIT License
            • Apple
            • Linux
          • -
            security
            A
            license
            -
            quality
            A utility tool that enables Claude Desktop to interact with external tools via the Model Context Protocol, providing features like email sending and simple calculations while simplifying the MCP setup process.
            Last updated -
            129
            9
            JavaScript
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            A Model Context Protocol server that automatically reads the Claude Desktop configuration file and presents all available MCP services in an easy-to-copy format at the top of the tools list.
            Last updated -
            1
            8
            2
            JavaScript
            MIT License
            • Apple

          View all related MCP servers

          ID: st9mc7th67