블렌더 MCP 서버
Blender 스크립트를 관리하고 실행하기 위한 MCP(Model Context Protocol) 서버입니다.
특징
- Blender Python 스크립트 추가, 편집, 실행 및 제거
- 헤드리스 Blender 환경에서 스크립트 실행
- 실행 결과 및 오류 보기
- 스크립트 메타데이터 추적(생성 날짜, 마지막 수정 날짜, 실행 횟수)
요구 사항
- 파이썬 3.7 이상
- 블렌더 설치 및 접근 가능
- MCP 라이브러리(
pip install mcp
)
용법
- 서버를 시작합니다:지엑스피1
- MCP 클라이언트(Claude Desktop 등)를 사용하여 서버에 연결합니다.
- 제공된 도구를 사용하여 스크립트를 관리하세요.
add_script(name, content)
- 새 스크립트 추가edit_script(name, content)
- 기존 스크립트 편집execute_script(name, blend_file=None)
- Blender에서 스크립트를 실행하며, 선택적으로 .blend 파일을 지정합니다.remove_script(name)
- 스크립트 제거
- 정보를 얻을 수 있는 리소스에 접속하세요:
scripts://list
- 사용 가능한 스크립트 목록 가져오기script://{name}
- 특정 스크립트의 내용을 가져옵니다.result://{name}
- 스크립트 실행 결과 가져오기
예시
기본 예제
# Add a simple script
add_script("hello_cube", '''
import bpy
# Clear existing objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Create a cube
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))
print("Cube created!")
''')
# Execute the script
execute_script("hello_cube")
# Get the result
# Access using: result://hello_cube
블렌드 파일 작업
# Add a script that works with a blend file
add_script("analyze_scene", '''
import bpy
# Print information about the current scene
print(f"Current Blender version: {bpy.app.version_string}")
print(f"Current file: {bpy.data.filepath}")
# List all objects in the scene
print("\\nObjects in the scene:")
for obj in bpy.data.objects:
print(f" - {obj.name} ({obj.type})")
''')
# Execute with a specific blend file
execute_script("analyze_scene", blend_file="/path/to/your/project.blend")
# Get the result
# Access using: result://analyze_scene
작동 원리
- 스크립트가 추가되면
script_files/scripts
디렉토리에 저장됩니다. - 스크립트가 실행되면 헤드리스 Blender 인스턴스에서 실행됩니다.
- 블렌드 파일이 지정된 경우 Blender는 스크립트를 실행하기 전에 해당 파일을 엽니다.
- 그렇지 않으면 기본 빈 Blender 장면이 사용됩니다.
- 출력 및 오류는
script_files/results
디렉토리에 캡처되어 저장됩니다. - 스크립트에 대한 메타데이터는
script_files/metadata.json
에서 추적됩니다.
설치
- 이 저장소를 복제하세요
- MCP 라이브러리를 설치하세요:
pip install mcp
- Blender가 설치되어 PATH에서 접근 가능한지 확인하세요.
특허
MIT