# simulator_describe_ui

> 這個 MCP 工具會傳回團隊模擬器螢幕上內容的輔助使用樹：每個元素的角色、文字、位置和 nodeId。

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

`simulator_describe_ui` 會傳回團隊正在執行的模擬器所顯示內容的輔助使用樹：每個元素及其角色、標籤、值、識別碼、框架、是否啟用，以及一個用於精確操作該元素的 `nodeId`。提供 `x` 和 `y` 時，只會傳回該點的元素。它是唯讀的。

尋找要點一下的目標時，請優先使用它而不是截圖：把元素的 `nodeId`（或它的文字或識別碼）傳給 [simulator_tap](https://air.build/tw/docs/mcp-tools/simulator_tap/) 和其他元素工具，詳見 [simulator_find](https://air.build/tw/docs/mcp-tools/simulator_find/#selector)。沒有輔助使用資訊的繪製內容（遊戲畫布、沒有標籤的圖片）不在樹中。當前景 App 忙碌且不提供輔助使用資料時，工具會在幾秒內反覆請求，然後才放棄。

| 唯讀 | 破壞性 | 冪等 |
| --- | --- | --- |
| 是 | 否 | 是 |

## 輸入

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

| 輸入 | 類型 | 必填 | 預設值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字串（UUID） | 是 | — | 團隊，來自 [list_teams](https://air.build/tw/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 團隊的預設裝置 | 哪種裝置，使用 [list_simulators](https://air.build/tw/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `x` | 數字，-100000 到 100000 | 否 | — | 與 `y` 一起使用：只傳回該點的元素，使用 [螢幕座標](https://air.build/tw/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/tw/docs/mcp-tools/simulator_screen/#coordinates) |
| `enabled` | 是否啟用（當 iOS 提供時） |
| `hidden` | iOS 是否回報它為隱藏 |
| `adjustable`, `adjustmentActions` | 在步進器、選取器或滾輪上：[simulator_adjust](https://air.build/tw/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/tw/docs/mcp-tools/start_simulator/#device-errors)。

## 範例

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