使用说明
Maya MCP服务器
通过模型上下文协议将Claude AI连接到Autodesk Maya
英语 | 简体中文 | 繁体中文 | 日本语 | 韩语 | 西班牙语 | 法语 | 德语 | 俄语
概述
Maya MCP Server使Claude AI能够通过模型上下文协议直接控制Autodesk Maya,从而启用:
- 🎨 人工智能辅助3D建模
- 🤖 自然语言Maya控件
- 📸 实时场景预览
- 🔧 工作流程自动化
快速开始
1.安装依赖项
pip install "mcp[cli]>=1.3.0"
2.加载Maya插件
负载 plug-ins/maya_mcp.py 在玛雅的 插件管理器:
-
复制
plug-ins/maya_mcp.py致:- 窗户:
C:\Users\<username>\Documents\maya\<version>\plug-ins\ - macOS:
~/maya/<version>/plug-ins/
- 窗户:
-
打开Maya→ Windows>设置/首选项>插件管理器
-
找到
maya_mcp.py,检查 已加载 和 自动加载 -
在脚本编辑器中验证:
MayaMCP: Plugin loaded successfully MayaMCP: Server started at localhost:9877
3.配置克劳德桌面
编辑配置文件(设置>开发人员>编辑配置):
选项A:使用npx(推荐)
标准配置:
{
"mcpServers": {
"maya-mcp": {
"command": "npx",
"args": [
"--yes",
"maya-mcp-server"
],
"env": {
"MAYA_HOST": "localhost",
"MAYA_PORT": "9877"
},
"alwaysAllow": [
"get_scene_info",
"get_object_info",
"create_primitive",
"delete_object",
"set_material",
"transform_object",
"smart_select",
"get_scene_summary",
"get_console_output",
"execute_maya_code"
]
}
}
}
强制更新配置(始终提取最新包):
{
"mcpServers": {
"maya-mcp": {
"command": "npx",
"args": [
"--yes",
"--no-cache",
"maya-mcp-server"
],
"env": {
"MAYA_HOST": "localhost",
"MAYA_PORT": "9877"
},
"alwaysAllow": [
"get_scene_info",
"get_object_info",
"create_primitive",
"delete_object",
"set_material",
"transform_object",
"smart_select",
"get_scene_summary",
"get_console_output",
"execute_maya_code"
]
}
}
}
选项B:使用Python
{
"mcpServers": {
"maya-mcp": {
"command": "python",
"args": ["-m", "maya_mcp.server"],
"env": {
"PYTHONPATH": "YOUR_PROJECT_PATH/src",
"MAYA_HOST": "localhost",
"MAYA_PORT": "9877"
},
"alwaysAllow": [
"get_scene_info",
"create_primitive",
"delete_object",
"set_material",
"transform_object",
"smart_select",
"get_scene_summary",
"get_console_output",
"execute_maya_code"
]
}
}
}
💡 更多配置选项
examples/
4.测试连接
重新启动Claude Desktop,然后问:
Get current Maya scene information
如果你看到返回的场景信息,它正在工作! ✅
特性
🛠️ 核心工具
| 工具 | 功能 |
|---|---|
get_scene_info |
获取场景信息(对象、相机、灯光) |
get_object_info |
获取对象详细信息(位置、旋转、材质) |
create_primitive |
创建几何体(立方体/球体/圆柱体/平面/圆环体) |
delete_object |
删除对象 |
transform_object |
变换对象(移动/旋转/缩放) |
set_material |
设置材质和颜色 |
execute_maya_code |
执行Python代码 |
smart_select |
使用正则表达式和过滤器进行智能对象选择 |
get_scene_summary |
获取全面的场景摘要 |
get_console_output |
获取Maya控制台/脚本编辑器输出🆕 |
💬 对话示例
User: Create a red cube at position (0, 5, 0)
Claude:
1. Created cube
2. Moved to specified position
3. Applied red material
✅ Done
User: Create a simple table and chair scene
Claude:
1. Created table top (scaled cube)
2. Created 4 table legs (cylinders)
3. Created chair
4. Set materials
✅ Scene created successfully
使用示例
基本操作
# Scene queries
"Show all objects in the current scene"
"Get detailed info for pCube1"
"Get console output to see recent Maya logs"
# Create objects
"Create a sphere named mySphere"
"Create 10 cubes in a row"
# Modify objects
"Move pCube1 to (5, 0, 0)"
"Set pSphere1 to blue"
"Rotate pCylinder1 45 degrees on Y axis"
# Smart selection
"Select all objects with 'character' in their name"
"Find all meshes with more than 5000 faces"
高级操作
# Procedural modeling
"Execute code to create a 5x5 cube grid"
# Vertex/Face editing
"Create a plane and edit vertices to make a terrain"
"Extrude faces to create details"
# UV editing
"Apply automatic UV projection to selected objects"
"Create spherical UV mapping for the sphere"
# Animation
"Create keyframe animation for bouncing ball"
"Set up 3-point lighting system"
# Rigging
"Create a spine bone chain with 5 joints"
"Set up parent constraints"
# Dynamics
"Create particle system with gravity"
"Apply bend deformer to plane"
# Boolean operations
"Subtract cube2 from cube1"
"Union two overlapping spheres"
# Batch operations
"Set all spheres to random colors"
# Complex scenes
"Create a simple interior scene with floor, walls, and furniture"
配置选项
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
MAYA_HOST |
localhost |
Maya服务器地址 |
MAYA_PORT |
9877 |
Maya服务器端口 |
PYTHONPATH |
- | Python模块搜索路径(仅限Python直接模式) |
自定义端口
在Maya插件中:
start_maya_mcp_server(host='localhost', port=9878)
在配置文件中:
"env": {
"MAYA_PORT": "9878"
}
故障排除
连接失败
问题: “无法连接到Maya”
解决:
- ✅ 验证Maya是否正在运行
- ✅ 确认插件已加载(检查插件管理器)
- ✅ 检查脚本编辑器中的启动消息
- ✅ 确保端口9877未被使用
未找到模块
问题: “ModuleNotFoundError:没有名为'maya_mcp'的模块”
解决:
- 安装依赖项:
pip install "mcp[cli]>=1.3.0" - 检查PYTHONPATH设置(如果使用Python直接模式)
- 尝试改用npx方法
NPX配置问题
问题: npx无法启动服务器或找不到文件
解决:
- 在配置中使用绝对路径(而不是相对路径)
- 使用正斜杠
/在Windows路径中 - 验证项目结构是否完好
- 请参阅详细指南: NPX_故障排除.md
插件加载失败
问题: Maya报告“没有初始化插件()函数”
解决:
- 确保使用最新版本的
maya_mcp.py - 插件文件包含
initializePlugin()和uninitializePlugin()函数
安全须知
⚠️ 重要提示:
execute_maya_code该工具允许执行任意Python代码- 总是 保存Maya场景 执行前
- 在生产环境中谨慎使用
- 首先在测试场景中进行测试操作
日志
服务器日志保存在:
- 窗户:
%TEMP%\maya-mcp\maya-mcp.log - macOS/Linux:
/tmp/maya-mcp/maya-mcp.log
检查日志以调试连接问题或命令执行错误。
发展
添加新工具
- 在中添加命令处理程序
plug-ins/maya_mcp.py - 在中添加MCP工具定义
src/maya_mcp/server.py - 测试新工具
运行开发服务器
# Set environment
export PYTHONPATH=/path/to/maya-mcp-server/src
# Run server
python -m maya_mcp.server
贡献
欢迎投稿!看 CONTRIBUTING.md
致谢
灵感来源:
- 搅拌机MCP -架构参考
许可证
免责声明
这是一个第三方项目,不是Autodesk的官方产品。
由...制作❤️ 面向玛雅艺术家和人工智能爱好者
