# simulator_services

> 这个 MCP 工具按类别列出团队模拟器的后台服务，并开启或关闭它们。

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

`simulator_services` 显示团队正在运行的模拟器上运行着哪些 iOS 后台服务，按类别和需要它们的功能分组。使用 `enable` 或 `disable` 可以开启或关闭它们。模拟器启动时，会关闭 App 很少需要的服务。当 App 需要其中某项服务（例如推送通知、iCloud 或 Siri）时，在这里开启它。没有 `enable` 或 `disable` 时，工具只读取。设备是共享的，所以更改对所有使用它的人生效。它不是破坏性的，但关闭服务可能导致某些功能无法使用。

开启的服务可能要等设备重启或 SpringBoard 重启后才会启动：这时它会列在 `pending` 下，并且 `restartRequired` 为 `true`。工具从不自行重启任何内容，因为两种重启都会结束正在运行的 App。要完成更改，请用 [shutdown_simulator](https://air.build/cn/docs/mcp-tools/shutdown_simulator/) 和 [start_simulator](https://air.build/cn/docs/mcp-tools/start_simulator/) 重启模拟器。

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

## 条目

`enable` 和 `disable` 的每一项是以下之一：

- `all`：列表中的每项服务（用于 `disable` 时，为每项可以关闭的服务）；
- `slim`：新模拟器会关闭的那组服务；
- 类别 ID：`widgets`、`siri`、`search`、`icloud`、`store`、`pim`、`web`、`family`、`health`、`photos`、`apps`、`messaging`、`connectivity`、`telemetry`、`other`、`management`；
- 功能 ID：`push`、`storekit`、`app-store`、`universal-links`、`spotlight`、`siri`、`icloud`、`keychain-sync`、`contacts`、`calendar`、`reminders`、`mail`、`photos`、`health`、`homekit`、`imessage`、`widgets`、`wallet`、`maps`、`weather`、`news`、`game-center`、`find-my`、`screen-time`；
- 某一项服务的 launchd 标签，即类别的 `disabled` 中列出的标签。

先读取列表：报告会给出每个 ID 及其名称，以及关闭后哪些功能会无法使用。

## 输入

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字符串（UUID） | 是 | — | 团队，来自 [list_teams](https://air.build/cn/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 团队的默认设备 | 哪种设备，使用 [list_simulators](https://air.build/cn/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `enable` | 字符串列表 | 否 | — | 要开启的 [条目](https://air.build/cn/docs/mcp-tools/simulator_services/#items)。每一项由字母、数字、`.`、`_` 和 `-` 组成，并以字母或数字开头 |
| `disable` | 字符串列表 | 否 | — | 要关闭的 [条目](https://air.build/cn/docs/mcp-tools/simulator_services/#items)，格式相同 |

## 结果

读取（没有 `enable` 或 `disable`）：

| 字段 | 说明 |
| --- | --- |
| `ok` | `true` |
| `id` | 设备在模拟器上的 ID |
| `booted` | 设备是否正在运行 |
| `source` | 从正在运行的设备读取时为 `launchd`；从设备下次启动所用的设置读取时为 `store` |
| `slim` | 有任何列出的服务处于关闭状态时为 `true` |
| `disabledCount`, `managedCount` | 列出的服务中有多少项关闭，共多少项 |
| `categories` | 每个都带有 `id`、`name`、`description`、`downside`（关闭后哪些功能无法使用）、`state`（`enabled`、`disabled` 或 `partial`）和 `disabled`（其中已关闭的服务） |
| `features` | 每个都带有 `id`、`name`、`enabled`（它需要的所有服务都已开启）和 `disabled` |
| `persistent` | 更改在设备重启后是否保留（iOS 18.5 及更高版本） |
| `defaultKeep` | 新模拟器保持开启的条目 |

```json
{
  "ok": true, "id": "…", "booted": true, "source": "launchd", "slim": true,
  "disabledCount": 120, "managedCount": 160,
  "categories": [ { "id": "siri", "name": "Siri & Intelligence", "description": "…", "downside": "…", "state": "disabled", "disabled": ["…"] } ],
  "features": [ { "id": "push", "name": "Push notifications", "enabled": false, "disabled": ["…"] } ],
  "persistent": true, "defaultKeep": ["…"]
}
```

更改：

| 字段 | 说明 |
| --- | --- |
| `ok` | `true`；有些服务无法更改时为 `false`（其他服务仍保持更改） |
| `id` | 设备在模拟器上的 ID |
| `appliedAt` | `now`（设备正在运行）或 `next-boot` |
| `enabled` | 已开启的服务 |
| `disabled` | 已关闭并停止的服务 |
| `pending` | 已开启但尚未运行的服务，每个都带有 `label` 和 `reason` |
| `failed` | 无法更改的服务，每个都带有 `label` 和 `error` |
| `restartRequired` | `pending` 中有内容在等待重启时为 `true` |

只列出状态发生变化的服务，所以请求当前状态会得到空列表。

```json
{ "ok": true, "id": "…", "appliedAt": "now", "enabled": ["…"], "disabled": [], "pending": [], "failed": [], "restartRequired": false }
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| enable lists service items such as siri or icloud. | `enable` 不是条目名称的列表（`disable` 同理） | 发送 [条目](https://air.build/cn/docs/mcp-tools/simulator_services/#items) 的列表 |
| unknown service _"item"_: expected all, slim, a category id, a feature id, or a cataloged launchd label _…_ | 某一项没有对应列表中的任何内容 | 读取列表并使用其中的 ID |
| _label_ stays enabled: _reason_ | 该服务无法关闭 | 保持开启 |
| asked to both enable and disable _labels_ | 同一项服务同时出现在两个列表中 | 从其中一个列表中移除 |

另外还有每个模拟器工具都可能返回的错误：见 [start_simulator](https://air.build/cn/docs/mcp-tools/start_simulator/#device-errors)。

## 示例

```json
{"name": "simulator_services", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "enable": ["push", "icloud"]}}
```
