unity mcp 配置指南


配置的unity mcp 的github地址:
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity

以下内容适配于windows系统

一、环境依赖

  1. python:3.10以上
    这里:如果Python版本不够,需要更新版本
    直接使用这个指令,更新Python即可:

    winget search python
    winget install --id Python.Python.3.12 -e

  2. uv:需要安装uv,指令:

    winget install --id=astral-sh.uv -e --accept-source-agreements --accept-package-agreements

二、路径配置

以上,安装完所需依赖之后,需要将Python和uv的路径配置在系统变量中path的字段

把下面这些路径同时放到 用户 Path系统 Path 里。

  • C:\Users\Administrator\AppData\Local\Programs\Python\Python312
  • C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts
  • C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Links
  • C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Packages\astral-sh.uv_Microsoft.Winget.Source_8wekyb3d8bbwe

以上:一二两个步骤,是解决本机环境的配置问题。基本上按照上面的操作,环境配置即成功了。

下面:三四两个步骤,是关于下载unity mcp的另一方面操作。


三、unity mcp下载

在 Unity 中:Window > Package Manager > + > Add package from git URL...
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity

网络不通 ,先从 GitHub 下载项目压缩包解压,再点击 + → Add package from disk → 选中 MCPForUnity/package.json 导入。

导入后 Unity 会自动弹出环境检测窗口

为什么:这个包是 Unity 端的"耳朵"和"手",没有它 Unity 无法接收和执行来自 AI 的任何指令,后续所有操作都建立在它之上

四、启动 MCP 服务器

Unity 菜单栏 → Window → MCP For Unity → 先点 Local Setup Window 确认环境全部绿灯*(这个就是步骤一和二在做的配置)*

→ 再点 Toggle MCP Window → Client Type 下拉选择你的 AI 客户端(Trae / Cursor / Claude Desktop)→ 确认 URL 为 http://localhost:8080 → 点击 Start Server → 首次启动会弹窗确认,点击确认后会自动打开一个终端窗口,终端必须保持运行,可最小化但绝不能关闭,每次重启 Unity 都需重新点击 Start Server

服务器是 AI 与 Unity 之间的中转站,AI 的指令经服务器转发给 Unity 执行。关闭终端等于关闭服务器,AI 立即失去与 Unity 的连接

五、配置 AI 客户端连接

做什么:在 AI 工具中注册 MCP 服务器地址,让 AI 知道往哪里发指令

怎么做:

  • Trae:设置 → MCP → 手动添加 → 输入 {"mcpServers": {"unityMCP": {"url": "http://localhost:8080/mcp"}}} → 保存。然后在智能体页面创建智能体,勾选 unityMCP 服务器,或直接使用内置的"Build with MCP"智能体

  • Cursor:设置 → 搜索 MCP → 添加服务器,Name: unityMCP,Type: sse,URL: http://localhost:8080/mcp,保存后重启 Cursor

    我用的是这个,所以,看下参考文献1

  • Claude Desktop:编辑配置文件 claude_desktop_config.json(路径:~/Library/Application Support/Claude/ 或 %APPDATA%\Claude\),添加 {"mcpServers": {"unityMCP": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-sse", "--port", "8080"]}}},保存后重启


参考文档:

  1. https://cursor.com/cn/help/customization/mcp
  2. https://blog.csdn.net/qq_42603590/article/details/159014205
  3. https://juejin.cn/post/7611814182954631168
相关推荐
垂葛酒肝汤7 小时前
Unity的可视化网格和文字标签
unity·游戏引擎
魔士于安7 小时前
Unity UI图片 复活节UI,卡通风格
游戏·ui·unity·游戏引擎·材质·贴图
weixin_423995007 小时前
unity 团结开发小游戏,加载AssetBundles(第二种方法)
unity·游戏引擎
魔士于安8 小时前
unity 卡通风整套资源 小鸟N套带动作+一套卡通风村落 和 相关道具+落叶粒子效果 buildin
游戏·unity·游戏引擎·贴图·模型
伽蓝_游戏9 小时前
第一章:解构游戏资源
游戏·unity·性能优化·c#·游戏引擎·游戏程序·assetbundle
星辰徐哥10 小时前
Unity C#入门:Visual Studio与Unity的关联配置
unity·c#·visual studio
Sparkle Star11 小时前
Unity VRTK4包导入和依赖关系
unity·游戏引擎
WiChP12 小时前
【V0.1B7】从零开始的2D游戏引擎开发之路
游戏引擎
Sparkle Star14 小时前
Unity VRTK4+SteamVR传送组件使用和层级关系
unity·游戏引擎