# appstore_distribute_build

> 把构建版本发给 TestFlight 群组：等待处理完成、回答出口合规、设置测试内容、加入群组，并在需要时提交 Beta 版 App 审核。

Source: https://air.build/cn/docs/mcp-tools/appstore_distribute_build/

让一个或多个 TestFlight 群组可以使用某个构建版本。它依次：

1. 找到构建版本：`buildId`，否则取 `buildNumber` 对应的最新未过期构建版本，否则取最新的未过期构建版本；
2. Apple 仍在处理时等待，最多 10 分钟；
3. 构建版本还没有回答时，用 `usesNonExemptEncryption` 回答出口合规；
4. 发送了 `whatToTest` 时，用 App 的主要语言设置测试内容；
5. 把构建版本加入群组（会获得每个构建版本的内部群组已经有它）；
6. 其中有外部群组且 Apple 表示构建版本已就绪时，把构建版本提交 Beta 版 App 审核。

Apple 会给测试员发电子邮件。这个工具不上传构建版本，也不邀请测试员：见 [appstore_invite_testers](https://air.build/cn/docs/mcp-tools/appstore_invite_testers/)。如果 10 分钟后 Apple 仍在处理，结果为 `done: false`：几分钟后再调用一次。

这个工具可能需要几分钟。客户端接受流式响应时，它会以带进度的流返回（见 [服务器与登录](https://air.build/cn/docs/mcp-tools/server/#transport)）。

| 只读 | 破坏性 | 幂等 |
| --- | --- | --- |
| 否 | 否 | 是 |

## 输入

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字符串（UUID） | yes | — | 团队，来自 [list_teams](https://air.build/cn/docs/mcp-tools/list_teams/)。 |
| `projectId` | 字符串（UUID） | 与 `appId` 二选一 | — | 这个 App 所属的项目，来自 [list_projects](https://air.build/cn/docs/mcp-tools/list_projects/)：这是指定 App 的常用方式。App 是 App Store Connect 上 bundle ID 与该项目构建的 bundle ID 相同的那个。两者都发送时，使用 `projectId`。 |
| `appId` | string | 与 `projectId` 二选一 | — | 来自 [appstore_list_apps](https://air.build/cn/docs/mcp-tools/appstore_list_apps/) 的 App Store Connect App ID，用于没有项目构建的 App。 |
| `appleTeamId` | 字符串（UUID） | no | 所有已连接的 Apple 团队 | 团队的某个 Apple 团队，来自 [appstore_list_apple_teams](https://air.build/cn/docs/mcp-tools/appstore_list_apple_teams/)。配合 `appId` 时，只在这个 Apple 团队中查找该 App。配合 `projectId` 时不需要：由项目的 App 决定。 |
| `buildId` | string | no | 最新的构建版本 | 来自 [appstore_list_builds](https://air.build/cn/docs/mcp-tools/appstore_list_builds/) 的构建版本 ID。 |
| `buildNumber` | string | no | 最新的构建版本 | 构建号（`CFBundleVersion`），例如 `42`，代替 `buildId`。 |
| `groups` | 字符串数组，至少 1 个 | yes | — | TestFlight 群组，每个用名称（不区分大小写）或来自 [appstore_list_beta_groups](https://air.build/cn/docs/mcp-tools/appstore_list_beta_groups/) 的 `groupId` 指定。 |
| `whatToTest` | 字符串，最多 4,000 个字符 | no | — | 测试员应在这个构建版本中尝试的内容。 |
| `usesNonExemptEncryption` | boolean | 构建版本没有回答时 | — | 出口合规：只使用豁免加密（HTTPS 之类）的 App 填 false，大多数 App 都是这样。仅在构建版本自身没有回答时使用。 |

每个工具对输入所做的检查见 [服务器与登录](https://air.build/cn/docs/mcp-tools/server/#errors)。

## 结果

一个 JSON 对象，同时以文本和 `structuredContent` 返回。

| 字段 | 说明 |
| --- | --- |
| `build` | 更改之后的构建版本（字段同 [appstore_list_builds](https://air.build/cn/docs/mcp-tools/appstore_list_builds/#result)） |
| `groups` | 群组（字段同 [appstore_list_beta_groups](https://air.build/cn/docs/mcp-tools/appstore_list_beta_groups/#result)） |
| `betaReview` | 有外部群组时：Beta 版 App 审核状态，例如这次调用提交了它时为 `WAITING_FOR_REVIEW`，否则为构建版本当前的外部状态。只有内部群组时为 null |
| `done` | 全部完成时为 true；Apple 仍在处理构建版本时为 false |
| `note` | 仅在 `done: false` 时出现：“Apple is still processing the build. Call again in a few minutes.” |

```json
{
  "build": {
    "buildId": "00000000-0000-0000-0000-000000000000",
    "version": "1.2.0",
    "buildNumber": "42",
    "platform": "IOS",
    "uploadedAt": "2026-11-18T09:00:00Z",
    "processing": "VALID",
    "expired": false,
    "expiresAt": "2027-02-16T09:00:00Z",
    "usesNonExemptEncryption": false,
    "internalTesting": "IN_BETA_TESTING",
    "externalTesting": "READY_FOR_BETA_SUBMISSION"
  },
  "groups": [
    {
      "groupId": "00000000-0000-0000-0000-000000000000",
      "name": "Friends",
      "kind": "external",
      "allBuilds": false,
      "publicLink": "https://testflight.apple.com/join/XXXXXXXX",
      "publicLinkLimit": 100,
      "feedback": true
    }
  ],
  "betaReview": "WAITING_FOR_REVIEW",
  "done": true
}
```

## 错误

每个错误都以工具错误（`isError: true`）返回。_斜体_ 文字代表句中的具体值。所有工具都可能返回的错误见 [服务器与登录](https://air.build/cn/docs/mcp-tools/server/#errors)。

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| No TestFlight group "_group_". The app's groups: _names_. | App 没有群组的名称（不区分大小写）或 `groupId` 与之匹配。没有任何群组时，列表显示为 “none — create one with appstore_create_beta_group” | 使用句中或 [appstore_list_beta_groups](https://air.build/cn/docs/mcp-tools/appstore_list_beta_groups/) 中的名称 |
| No such build. | `buildId` 没有对应的构建版本 | 从 [appstore_list_builds](https://air.build/cn/docs/mcp-tools/appstore_list_builds/) 获取 `buildId` |
| No build _number_ on App Store Connect. See appstore_list_builds. | 没有未过期的构建版本使用该 `buildNumber` | 用 [appstore_list_builds](https://air.build/cn/docs/mcp-tools/appstore_list_builds/) 查看 |
| No build of this app has reached App Store Connect yet. Uploading one is the Team's Agents' work: ask in the Project's channel (send_message) for a TestFlight build. | App 完全没有未过期的构建版本 | 用 [send_message](https://air.build/cn/docs/mcp-tools/send_message/) 请项目的智能体构建一个 TestFlight 版本 |
| Apple could not process build _number_: it is _state_. | Apple 处理的结果为 `INVALID` 或 `FAILED` | 该构建版本无法使用；请项目的智能体重新构建一个 |
| Apple needs this build's export compliance answer first: pass usesNonExemptEncryption (false when the app uses only exempt encryption such as HTTPS). | 构建版本没有出口合规回答，且没有发送 `usesNonExemptEncryption` | 先问对方，然后带上 `usesNonExemptEncryption` 再调用 |
| Pass projectId, or appId from appstore_list_apps. | `projectId` 和 `appId` 都没有发送 | 发送其中一个 |
| This Project has not been built for iOS yet, so it has no bundle id to find its app by. Ask the Team's Agent to build it, or pass appId. | 该项目从未构建过 iOS 版本 | 请项目的智能体构建一个 iOS 版本（[send_message](https://air.build/cn/docs/mcp-tools/send_message/)），或用 `appId` 指定 App |
| This Project has no app on App Store Connect yet. Create one with appstore_create_app (its bundle id is the Project's), or pass appId. | 团队已连接的 Apple 团队中没有 App 的 bundle ID 与项目相同，或没有连接任何 Apple 团队 | 用 [appstore_create_app](https://air.build/cn/docs/mcp-tools/appstore_create_app/) 创建 App，或用 `appId` 指定另一个 App |
| No connected Apple team of this Team has that app. See appstore_list_apps. | `appId` 不是任何已连接 Apple 团队（或 `appleTeamId`）中的 App | 从 [appstore_list_apps](https://air.build/cn/docs/mcp-tools/appstore_list_apps/) 获取 ID |
| App Store Connect: _Apple's sentence_ | Apple 拒绝了请求。后面最多附上 Apple 自己的五句话，Apple 指明相关字段时会在括号中注明。App Store Connect 中有待接受的 Apple 协议时，也会这样被拒绝 | 按 Apple 的说明处理。协议由 Apple Developer 账户的账户持有人在 App Store Connect 中接受（商务 › 协议） |
| App Store Connect answered _status_. Try again in a moment. | Apple 拒绝了，但没有说明原因 | 稍后再试 |

## 示例

```json
{
  "name": "appstore_distribute_build",
  "arguments": {
    "teamId": "00000000-0000-0000-0000-000000000000",
    "projectId": "00000000-0000-0000-0000-000000000000",
    "groups": [
      "Friends"
    ],
    "whatToTest": "The new sharing sheet.",
    "usesNonExemptEncryption": false
  }
}
```
