Unity构建自动化MCP服务器
将“Unity Cloud Build”的REST API MCP(模型上下文协议) 以服务器的形式包装,可以直接从Claude Code中确认和操作构建状况。
建筑
Claude Code MCP Server (Node.js/TypeScript) Unity Build API
https://build-api.cloud.unity3d.com/api/v1/设置
先决条件
- Node.js(ES2022+)
- Unity Build Automation API密钥
安装
# npx で直接使う場合(インストール不要)
npx -y unity-build-automation-mcp
# グローバルインストール
npm install -g .
# ローカル開発
npm install环境变量
| 变量 | 必填 | 描述 |
|---|---|---|
UNITY_BUILD_API_KEY | 是 | Unity Build Automation API密钥 |
UNITY_BUILD_ORG_ID | 是 | 组织ID |
UNITY_BUILD_DEFAULT_PROJECT | 否 | 默认项目名称或ID |
克劳德代码MCP设置
在Claude Code CLI中添加:
claude mcp add unity-build -- npx -y unity-build-automation-mcp或 ~/.claude.json / .mcp.json 手动添加到:
{
"mcpServers": {
"unity-build": {
"command": "npx",
"args": ["-y", "unity-build-automation-mcp"],
"env": {
"UNITY_BUILD_API_KEY": "",
"UNITY_BUILD_ORG_ID": ""
}
}
}
}直接从本地存储库使用:
{
"mcpServers": {
"unity-build": {
"command": "node",
"args": ["
/dist/index.js"],
"env": {
"UNITY_BUILD_API_KEY": "",
"UNITY_BUILD_ORG_ID": ""
}
}
}
}工具
读取操作
| 工具 | 说明 |
|---|---|
list_projects 获取Organization中的项目列表 | |
list_build_targets 获取项目的构建目标列表 | |
list_builds 获取构建列表(可按状态过滤) | |
get_build 获取特定构建的详细信息 | |
get_build_log 获取构建日志的末尾N行 |
写入操作
| 工具 | 说明 |
|---|---|
start_build 开始新的构建 | |
cancel_build |取消正在运行的构建| |
在Claude Code侧运行Write operations之前,会显示确认提示。
用法示例
检查构建状态:
“让我看看最新的构建情况。”
调查失败构建:
“检查失败的构建日志”
开始构建:
“在Android的develop分支中启动构建”
确认构建目标:
“我的项目构建目标列表”
参数
大多数工具 project 参数是可选的。省略时使用默认项目。项目名称(例如: MyProject)或UUID。
构建状态值
| 状态 | 描述 |
|---|---|
queued 等待队列 | |
sentToBuilder 已发送到生成器 | |
started 正在构建 | |
restarted | 再开 |
success | 成功 |
failure | 失败 |
canceled 取消 | |
unknown | 不明 |
发展
npm run dev # TypeScript watch mode
npm run build # Build
npm start # Run server项目结构
src/
index.ts # Entry point, MCP server setup
api.ts # Unity Build API client
config.ts # Configuration / env var handling
types.ts # TypeScript type definitions
format.ts # Output formatting utilities
tools/
list-projects.ts
list-build-targets.ts
list-builds.ts
get-build.ts
get-build-log.ts
start-build.ts
cancel-build.ts许可证
私人
