mcp-source

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Switch MCP for Unity Package Source

切换MCP for Unity包源

You are switching the
com.coplaydev.unity-mcp
package source in one or more Unity projects.
你正在为一个或多个Unity项目切换
com.coplaydev.unity-mcp
包源。

allowed-tools

允许使用的工具

Bash, Read, Edit, ReadMcpResourceTool, ListMcpResourcesTool
Bash、Read、Edit、ReadMcpResourceTool、ListMcpResourcesTool

Instructions

操作步骤

1. Parse arguments

1. 解析参数

The user's argument is:
$ARGUMENTS
Valid values:
main
,
beta
,
branch
,
local
, or empty.
If 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
有效值:
main
beta
branch
local
或空值。
如果参数为空或不属于上述四个有效值,请让用户选择:
  • 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_url
Convert SSH origins to HTTPS: if
origin_url
starts with
git@github.com:
, transform it to
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_url
git@github.com:
开头,将其转换为
https://github.com/{owner}/{repo}.git

3. Discover target Unity projects

3. 发现目标Unity项目

Try two approaches to find
Packages/manifest.json
files to update:
Approach A — MCP resources (preferred): Read
mcpforunity://project/info
for each connected Unity instance (use
ListMcpResourcesTool
to find available instances). Extract
projectRoot
and use
{projectRoot}/Packages/manifest.json
.
Approach B — filesystem fallback: If no MCP instances are connected, search upward from the current working directory for
Packages/manifest.json
files using Bash:
bash
find "$(pwd)" -maxdepth 3 -name "manifest.json" -path "*/Packages/manifest.json" 2>/dev/null
If multiple manifests are found, update all of them (confirming with the user first).
尝试两种方法查找需要更新的
Packages/manifest.json
文件:
方法A — MCP资源(优先使用): 为每个已连接的Unity实例读取
mcpforunity://project/info
(使用
ListMcpResourcesTool
查找可用实例)。提取
projectRoot
并使用
{projectRoot}/Packages/manifest.json
方法B — 文件系统回退方案: 如果没有已连接的MCP实例,使用Bash从当前工作目录向上搜索
Packages/manifest.json
文件:
bash
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:
SelectionURL
main
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main
beta
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta
branch
{origin_https}?path=/MCPForUnity#{branch_name}
local
file:{repo_root}/MCPForUnity
For
branch
: use the HTTPS-normalized origin URL and current git branch name. For
local
: use the absolute path to the repo root with
file:
prefix (no
//
), e.g.
file:/Users/davidsarno/unity-mcp/MCPForUnity
.
根据用户的选择,构造依赖项值:
选项URL
main
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main
beta
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta
branch
{origin_https}?path=/MCPForUnity#{branch_name}
local
file:{repo_root}/MCPForUnity
对于
branch
选项:使用转换为HTTPS格式的远程仓库地址和当前git分支名称。 对于
local
选项:使用仓库根目录的绝对路径并添加
file:
前缀(无需
//
),例如
file:/Users/davidsarno/unity-mcp/MCPForUnity

5. Update each manifest

5. 更新每个清单文件

For each discovered
manifest.json
:
  1. Read the file with the Read tool
  2. Find the
    "com.coplaydev.unity-mcp"
    dependency line
  3. Use the Edit tool to replace the old value with the new URL
  4. Report what was changed: old value → new value, file path
对于每个找到的
manifest.json
  1. 使用Read工具读取文件
  2. 找到
    "com.coplaydev.unity-mcp"
    依赖项行
  3. 使用Edit工具将旧值替换为新的URL
  4. 报告更改内容:旧值 → 新值,文件路径

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并点击刷新。”