Freecad

Freecad

A FreeCAD addon that implements the Model Context Protocol (MCP) to enable communication between FreeCAD and Claude AI through Claude Desktop.

bonninr

Developer Tools
Visit Server

README

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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python