Skip to main content
Glama
bonninr
by bonninr

FreeCAD MCP(모델 제어 프로토콜)

개요

FreeCAD MCP(모델 제어 프로토콜)는 서버-클라이언트 아키텍처를 통해 FreeCAD와 상호 작용할 수 있는 간소화된 인터페이스를 제공합니다. 이를 통해 사용자는 명령을 실행하고 현재 FreeCAD 문서 및 장면에 대한 정보를 검색할 수 있습니다.

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

Related MCP server: mcp-freecad

구성

MCP 서버를 구성하려면 JSON 형식을 사용하여 서버 설정을 지정할 수 있습니다. 아래는 구성 예시입니다.

지엑스피1

구성 세부 정보

  • command : FreeCAD MCP 서버를 실행할 Python 실행 파일의 경로입니다. 운영 체제에 따라 다를 수 있습니다.

    • Windows : 일반적으로 C:\\ProgramData\\anaconda3\\python.exe 또는 C:\\Python39\\python.exe 와 같습니다.

    • Linux : /usr/bin/python3 또는 Python 설치 경로일 수 있습니다.

    • macOS : 일반적으로 /usr/local/bin/python3 또는 Python 설치 경로입니다.

  • args : Python 명령에 전달할 인수 배열입니다. 첫 번째 인수는 MCP 서버 로직을 처리하는 freecad_bridge.py 스크립트의 경로여야 합니다. 설치 환경에 맞게 경로를 조정해야 합니다.

다양한 운영 체제에 대한 예

윈도우

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

리눅스

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

맥OS

{
    "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 모듈 디렉토리에 freecad_mcp 디렉토리를 넣으세요:

    • 윈도우: %APPDATA%/FreeCAD/Mod/

    • 리눅스: ~/.FreeCAD/Mod/

    • macOS: ~/Library/Preferences/FreeCAD/Mod/

  3. FreeCAD를 다시 시작하고 워크벤치 선택기에서 "FreeCAD MCP" 워크벤치를 선택합니다.

기여하다

이슈 제출이나 풀 리퀘스트를 통해 자유롭게 기여해 주세요. 여러분의 피드백과 기여를 환영합니다!

특허

이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 라이선스 파일을 참조하세요.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    This project provides a robust integration between AI assistants and FreeCAD CAD software using the Model Context Protocol (MCP). It allows external applications to interact with FreeCAD through a standardized interface, offering multiple connection methods and specialized tools.
    24
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables automation of FreeCAD model creation, macro execution, and view management through a server-client architecture, supporting integration with external AI tools like Claude and Cursor.
    100
    MIT