mcp-source
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSwitch MCP for Unity Package Source
切换MCP for Unity包源
You are switching the package source in one or more Unity projects.
com.coplaydev.unity-mcp你正在为一个或多个Unity项目切换包源。
com.coplaydev.unity-mcpallowed-tools
允许使用的工具
Bash, Read, Edit, ReadMcpResourceTool, ListMcpResourcesTool
Bash、Read、Edit、ReadMcpResourceTool、ListMcpResourcesTool
Instructions
操作步骤
1. Parse arguments
1. 解析参数
The user's argument is:
$ARGUMENTSValid values: , , , , or empty.
mainbetabranchlocalIf empty or not one of the four valid values, ask the user to choose:
- main — upstream main branch (stable releases)
- beta — upstream beta branch (pre-release)
- branch — your current remote branch (for testing a PR)
- local — local file reference to your checkout (for live dev iteration)
用户的参数为:
$ARGUMENTS有效值:、、、或空值。
mainbetabranchlocal如果参数为空或不属于上述四个有效值,请让用户选择:
- main — 上游主分支(稳定发布版本)
- beta — 上游测试分支(预发布版本)
- branch — 当前远程分支(用于测试PR)
- local — 本地开发检出版本的文件引用(用于实时开发迭代)
2. Detect repo context
2. 检测仓库上下文
Run these git commands from the current working directory to find the unity-mcp repo:
bash
git rev-parse --show-toplevel # → repo_root
git rev-parse --abbrev-ref HEAD # → branch_name
git remote get-url origin # → origin_urlConvert SSH origins to HTTPS: if starts with , transform it to .
origin_urlgit@github.com:https://github.com/{owner}/{repo}.git从当前工作目录运行以下git命令,查找unity-mcp仓库:
bash
git rev-parse --show-toplevel # → 仓库根目录
git rev-parse --abbrev-ref HEAD # → 分支名称
git remote get-url origin # → 远程仓库地址将SSH格式的远程地址转换为HTTPS格式:如果以开头,将其转换为。
origin_urlgit@github.com:https://github.com/{owner}/{repo}.git3. Discover target Unity projects
3. 发现目标Unity项目
Try two approaches to find files to update:
Packages/manifest.jsonApproach A — MCP resources (preferred):
Read for each connected Unity instance (use to find available instances). Extract and use .
mcpforunity://project/infoListMcpResourcesToolprojectRoot{projectRoot}/Packages/manifest.jsonApproach B — filesystem fallback:
If no MCP instances are connected, search upward from the current working directory for files using Bash:
Packages/manifest.jsonbash
find "$(pwd)" -maxdepth 3 -name "manifest.json" -path "*/Packages/manifest.json" 2>/dev/nullIf multiple manifests are found, update all of them (confirming with the user first).
尝试两种方法查找需要更新的文件:
Packages/manifest.json方法A — MCP资源(优先使用):
为每个已连接的Unity实例读取(使用查找可用实例)。提取并使用。
mcpforunity://project/infoListMcpResourcesToolprojectRoot{projectRoot}/Packages/manifest.json方法B — 文件系统回退方案:
如果没有已连接的MCP实例,使用Bash从当前工作目录向上搜索文件:
Packages/manifest.jsonbash
find "$(pwd)" -maxdepth 3 -name "manifest.json" -path "*/Packages/manifest.json" 2>/dev/null如果找到多个清单文件,需先征得用户确认,再全部更新。
4. Build the package URL
4. 构建包URL
Based on the user's selection, construct the dependency value:
| Selection | URL |
|---|---|
| |
| |
| |
| |
For : use the HTTPS-normalized origin URL and current git branch name.
For : use the absolute path to the repo root with prefix (no ), e.g. .
branchlocalfile://file:/Users/davidsarno/unity-mcp/MCPForUnity根据用户的选择,构造依赖项值:
| 选项 | URL |
|---|---|
| |
| |
| |
| |
对于选项:使用转换为HTTPS格式的远程仓库地址和当前git分支名称。
对于选项:使用仓库根目录的绝对路径并添加前缀(无需),例如。
branchlocalfile://file:/Users/davidsarno/unity-mcp/MCPForUnity5. Update each manifest
5. 更新每个清单文件
For each discovered :
manifest.json- Read the file with the Read tool
- Find the dependency line
"com.coplaydev.unity-mcp" - Use the Edit tool to replace the old value with the new URL
- Report what was changed: old value → new value, file path
对于每个找到的:
manifest.json- 使用Read工具读取文件
- 找到依赖项行
"com.coplaydev.unity-mcp" - 使用Edit工具将旧值替换为新的URL
- 报告更改内容:旧值 → 新值,文件路径
6. Report results
6. 报告结果
After updating, tell the user:
- Which manifests were updated
- The old and new package source values
- Remind them: "Unity will re-resolve the package automatically. If it doesn't, open Package Manager and click Refresh."
更新完成后,告知用户:
- 哪些清单文件已更新
- 包源的旧值和新值
- 提醒用户:“Unity会自动重新解析包。如果未自动解析,请打开Package Manager并点击刷新。”