MCP for Unity 的 uv 配置与故障排查
解决的问题与适用场景
如果 uv 未安装或不在 PATH 中,Cursor、Windsurf、VS Code 无法启动服务器。
工具、版本与前置条件
- uv:版本:原文未说明;前置条件:需要 Python 3.10+ 和 uv 包管理器。
操作步骤与工作流衔接
1. 运行 python3 --version 和 uv --version 验证版本
- 输入:python3 --version uv --version
- 输出:原文未说明
- 后处理与接入:原文未说明
2. macOS 上可用 brew install python@3.12 安装 Python
- 输入:brew install python@3.12
- 输出:原文未说明
- 后处理与接入:原文未说明
3. macOS、Linux、WSL 上可用 curl -LsSf https://astral.sh/uv/install.sh | sh 安装 uv,或用 brew install uv
- 输入:curl -LsSf https://astral.sh/uv/install.sh | sh brew install uv
- 输出:原文未说明
- 后处理与接入:原文未说明
4. Windows PowerShell 上可用 powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" 安装 uv,或用 winget install --id=astral-sh.uv -e
- 输入:powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # or winget install --id=astral-sh.uv -e
- 输出:原文未说明
- 后处理与接入:原文未说明
5. 在 MCP 客户端配置中把 command 设为 uvx,参数使用 --from mcpforunityserver mcp-for-unity --transport stdio
- 输入:command: uvx with args like --from mcpforunityserver mcp-for-unity --transport stdio
- 输出:客户端直接调用 uvx 启动服务器
- 后处理与接入:原文未说明
6. 若未找到 uv,使用 "Choose UV Install Location" 定位 uv 二进制并保存路径
- 输入:"Choose UV Install Location"
- 输出:保存路径并自动重新配置
- 后处理与接入:选择器路径存储在 UnityMCP.UvPath 并跨会话保留
7. 点击 "Repair Python Env" 会删除服务器的 .venv 和 .python-version(若存在),并在 Unity MCP Server 的 src 目录运行 uv sync 重建干净环境
- 输入:Deletes the server's .venv and .python-version (if present) Runs uv sync in the Unity MCP Server src directory to rebuild a clean environment
- 输出:重建干净环境
- 后处理与接入:原文未说明
8. 手动修复或运行时,进入 UnityMcpServer/src 目录执行 uv sync 和 uv run server.py
- 输入:cd < UnityMcpServer/src > uv sync uv run server.py
- 输出:原文未说明
- 后处理与接入:原文未说明
原作者的结果与限制
- 结果:原文未说明
- 限制与踩坑:若只在 WSL 内安装 uv,Windows 原生 Unity 无法看到它;需在 Windows 安装 uv,或用 MCP 窗口指向 Windows 的 uv.exe。
原文与来源
- 作者:原文未说明
- 来源:MCP for Unity open-source implementation guides
- 原文日期:原文未说明
- 阅读原文
本文为基于原文整理的中文导读,效果与结论归属于原作者。