# simulator_describe_ui

> 这个 MCP 工具返回团队模拟器屏幕上内容的辅助功能树：每个元素的角色、文本、位置和 nodeId。

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

`simulator_describe_ui` 返回团队正在运行的模拟器所显示内容的辅助功能树：每个元素及其角色、标签、值、标识符、框架、是否启用，以及一个用于精确操作该元素的 `nodeId`。提供 `x` 和 `y` 时，只返回该点处的元素。它是只读的。

查找要点按的目标时，优先使用它而不是截屏：把元素的 `nodeId`（或它的文本或标识符）传给 [simulator_tap](https://air.build/cn/docs/mcp-tools/simulator_tap/) 和其他元素工具，具体见 [simulator_find](https://air.build/cn/docs/mcp-tools/simulator_find/#selector)。没有辅助功能信息的绘制内容（游戏画布、没有标签的图片）不在树中。当前台 App 正忙且不提供辅助功能数据时，工具会在几秒内反复请求，然后才放弃。

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

## 输入

`x` 和 `y` 要么都提供，要么都不提供。

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `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` |
| `x` | 数字，-100000 到 100000 | 否 | — | 与 `y` 一起使用：只返回该点处的元素，使用 [屏幕坐标](https://air.build/cn/docs/mcp-tools/simulator_screen/#coordinates) |
| `y` | 数字，-100000 到 100000 | 否 | — | 与 `x` 一起使用 |

## 结果

| 字段 | 说明 |
| --- | --- |
| `ok` | `true` |
| `ui.format` | `json` |
| `ui.tree` | 树，从前台 App（`AXApplication`）开始。每个元素都有下面的字段及其 `children` |
| `ui.raw` | 以一个 JSON 字符串表示的同一棵树 |

`ui.tree` 的每个元素：

| 字段 | 说明 |
| --- | --- |
| `role` | 辅助功能角色，例如 `AXButton`、`AXStaticText`、`AXTextField`、`AXSlider` |
| `label` | 它的可见文本或辅助功能标签，或 `null` |
| `title` | 标题，当它有标题而不是标签时 |
| `value` | 它的值：输入框的文本、开关的状态、滑块的位置 |
| `identifier` | App 设置的 `accessibilityIdentifier`（如果有） |
| `nodeId` | 指向这个元素的不透明引用，作为 `nodeId` 传入。元素消失或 App 重启后失效 |
| `frame` | `x`、`y`、`width`、`height`，使用 [屏幕坐标](https://air.build/cn/docs/mcp-tools/simulator_screen/#coordinates) |
| `enabled` | 是否启用（当 iOS 给出时） |
| `hidden` | iOS 是否报告它为隐藏 |
| `adjustable`, `adjustmentActions` | 在步进器、选择器或滚轮上：[simulator_adjust](https://air.build/cn/docs/mcp-tools/simulator_adjust/) 可以发送的操作（`AXIncrement`、`AXDecrement`） |
| `activationPoint`, `sliderTrack` | 在某些控件上：点按落下的位置，以及滑块轨道的两端 |
| `children` | 它包含的元素 |

```json
{
  "ok": true,
  "ui": {
    "format": "json",
    "tree": {
      "role": "AXApplication", "label": "Notes", "enabled": true, "hidden": false,
      "frame": { "x": 0, "y": 0, "width": 402, "height": 874 },
      "children": [
        { "role": "AXButton", "label": "New note", "identifier": "new-note", "nodeId": "ax1:…",
          "enabled": true, "hidden": false,
          "frame": { "x": 16, "y": 120, "width": 370, "height": 52 }, "children": [] }
      ]
    },
    "raw": "{…}"
  }
}
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| Give both x and y, or neither. | 只提供了其中一个 | 两个都发送，或都不发送 |
| no accessibility data _…_ The app in front is busy; try again in a few seconds. | 重试后 App 仍未提供树 | 等几秒后再调用 |

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

## 示例

```json
{"name": "simulator_describe_ui", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000"}}
```
