一个用于管理和执行Blender脚本的模型上下文协议(MCP)服务器。
pip install mcp)启动服务器:
python server.py
使用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_script("hello_cube", '''
import bpy
# 清除现有对象
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# 创建一个立方体
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))
print("立方体已创建!")
''')
# 执行脚本
execute_script("hello_cube")
# 获取结果
# 访问方式:result://hello_cube
# 添加一个处理blend文件的脚本
add_script("analyze_scene", '''
import bpy
# 打印当前场景的信息
print(f"当前Blender版本:{bpy.app.version_string}")
print(f"当前文件:{bpy.data.filepath}")
# 列出场景中的所有对象
print("\\n场景中的对象:")
for obj in bpy.data.objects:
print(f" - {obj.name} ({obj.type})")
''')
# 使用特定的blend文件执行
execute_script("analyze_scene", blend_file="/path/to/your/project.blend")
# 获取结果
# 访问方式:result://analyze_scene
script_files/scripts目录下script_files/results目录下script_files/metadata.json中pip install mcpMIT