# simulator_find

> チームのシミュレータの画面上でセレクタに一致するすべての要素を、何にも触れずに一致度の高い順に一覧表示する MCP ツールです。

Source: https://air.build/ja/docs/mcp-tools/simulator_find/

`simulator_find` は、チームの動作中のシミュレータの画面上でセレクタに一致する使用可能なすべての要素を、一致度の高い順に返します。一致したものの除外された要素とその理由（非表示、画面外）も返します。何にも触れず、待ちもしません。まだ表示されていない要素の場合は空のリストになります。読み取り専用です。[simulator_tap](https://air.build/ja/docs/mcp-tools/simulator_tap/) で操作する前に、セレクタが何に当たるかを確認するのに使います。

| 読み取り専用 | 破壊的 | 冪等 |
| --- | --- | --- |
| はい | いいえ | はい |

## セレクタ

要素ツール（[simulator_tap](https://air.build/ja/docs/mcp-tools/simulator_tap/)、[simulator_find](https://air.build/ja/docs/mcp-tools/simulator_find/)、[simulator_wait](https://air.build/ja/docs/mcp-tools/simulator_wait/)、[simulator_slider](https://air.build/ja/docs/mcp-tools/simulator_slider/)、[simulator_adjust](https://air.build/ja/docs/mcp-tools/simulator_adjust/)、そして [simulator_batch](https://air.build/ja/docs/mcp-tools/simulator_batch/) のステップ）は、座標ではなくセレクタで要素を指定します。要素は [simulator_describe_ui](https://air.build/ja/docs/mcp-tools/simulator_describe_ui/) が示すアクセシビリティツリーの中から毎回新たに読み取って探すので、レイアウト上どこにあっても見つかります。アクセシビリティツリーにないものは選択できないので、座標を使ってください。

| フィールド | 型 | 一致する対象 |
| --- | --- | --- |
| `text` | string | 要素の表示テキスト：ラベル（またはタイトル）か値。大文字と小文字は区別せず、前後の空白は無視し、`exact` を設定しない限りテキストの一部だけで一致します |
| `id` | string | 要素の `accessibilityIdentifier`（完全一致） |
| `value` | string | 要素の値だけ（フィールドのテキストなど）。大文字と小文字は区別せず、`exact` を設定しない限り一部だけで一致します |
| `role` | string | アクセシビリティの役割（完全一致）。例：`AXButton`、`AXSlider`、`AXSwitch` |
| `nodeId` | string | [simulator_describe_ui](https://air.build/ja/docs/mcp-tools/simulator_describe_ui/) またはこのツールの `nodeId`：その要素だけに一致し、ほかには一致しません |
| `exact` | boolean | `text` と `value` が、要素のテキストに含まれるだけでなく、完全に等しい必要があります |
| `strict` | boolean | 使用可能な要素が複数一致した場合、最も一致するものを選ばずに失敗します |

`text`、`id`、`value`、`role`、`nodeId` のうち少なくとも 1 つを指定してください。空の文字列は指定していないものとみなされます。指定したすべてのフィールドが一致する必要があります。

**順位。** 複数の要素が一致すると、最も一致するものが先頭になります。クエリと等しいテキストはクエリを含むテキストより優先され、ラベルでの一致は値での一致より優先され、ボタン、リンク、フィールド、スイッチ、セルは同じ言葉の静的テキストより優先されます。次に小さい要素、次に上から下、左から右の順です。1 つの要素を操作するツールは先頭のものを使い、`matchCount` を報告します。1 より大きい場合は順位で決まったことを意味します。確実にするには `id`、`role`、`exact`、`strict` を加えてください。

**除外。** 一致しても使えない要素は、`excluded` の下に `reason` とともに一覧表示されます：`hidden`、`empty-frame`（サイズがない）、`off-screen`（中心が画面外）、タップの場合は `disabled`。

**nodeId。** `nodeId` は、現在実行中のアプリの 1 つの要素を指します。要素がなくなる、非表示になる、画面外に出る、またはアプリが再起動すると使えなくなるので、その場合はツリーを読み直してください。不透明な値として扱い、あとのために保存しないでください。

**セレクタのエラー**（すべての要素ツール）：

| メッセージ | 発生する状況 | 対処 |
| --- | --- | --- |
| Name the element: text, id, value, role or nodeId. | セレクタのフィールドが 1 つも指定されていない | 1 つ追加してください |
| invalid nodeId; use the opaque string returned by describe-ui | `nodeId` がツールの発行したものではない | [simulator_describe_ui](https://air.build/ja/docs/mcp-tools/simulator_describe_ui/) からそのままコピーしてください |
| node_id_device_mismatch: nodeId belongs to a different device | `nodeId` が別のシミュレータのもの | このデバイスのツリーを読み取ってください |
| stale_node: _nodeId_ is absent, hidden, disabled, off-screen, or no longer matches; describe UI again | 要素がなくなった、または変わった | もう一度 [simulator_describe_ui](https://air.build/ja/docs/mcp-tools/simulator_describe_ui/) を呼び出してください |
| ambiguous selector _selector_: _n_ usable matches; add an id, role, or value filter | `strict`（または `nodeId`）が指定されていて、複数の要素が一致する | セレクタを絞り込んでください |
| no usable element matching _selector_ within _n_s | 待機するツールが時間内に使える要素を見つけられなかった。一致したものの使えなかった要素がある場合は、`(matched but skipped: 1 hidden, …)` が続きます | `simulator_find` で確認するか、[simulator_scroll_to](https://air.build/ja/docs/mcp-tools/simulator_scroll_to/) でスクロールするか、もっと長く待ってください |

## 入力

| 入力 | 型 | 必須 | デフォルト | 内容 |
| --- | --- | --- | --- | --- |
| `teamId` | 文字列（UUID） | はい | — | チーム。[list_teams](https://air.build/ja/docs/mcp-tools/list_teams/) から取得 |
| `simulator` | string | いいえ | チームのデフォルトのデバイス | どのデバイスか。[list_simulators](https://air.build/ja/docs/mcp-tools/list_simulators/#result) の `id` で指定します |
| `text`, `id`, `value`, `role`, `nodeId`, `exact`, `strict` | [セレクタ](https://air.build/ja/docs/mcp-tools/simulator_find/#selector) を参照 | 最初の 5 つのうち少なくとも 1 つ | — | セレクタ |

## 結果

| フィールド | 内容 |
| --- | --- |
| `ok` | `true` |
| `matches` | 使用可能な要素（一致度の高い順）。なければ空 |
| `matches[].element` | 要素：`label`、`value`、`identifier`、`nodeId`、`role`、`frame`（`x`、`y`、`width`、`height`）、`enabled`、`interactive`（入力を受け付ける）、`hidden`、一部のコントロールでは `activationPoint`、`sliderTrack`、`adjustable`、`adjustmentActions` |
| `matches[].point` | `x`、`y`：要素をタップしたときにタップされる位置。[画面座標](https://air.build/ja/docs/mcp-tools/simulator_screen/#coordinates) で表します |
| `matches[].exact` | テキストがクエリと等しいかどうか（`id` では常に `true`） |
| `excluded` | 一致したものの使えない要素 |
| `excluded[].element` | 要素（上記と同じ） |
| `excluded[].reason` | `hidden`、`empty-frame`、`off-screen`、または `disabled` |

```json
{
  "ok": true,
  "matches": [
    { "element": { "label": "New note", "identifier": "new-note", "nodeId": "ax1:…", "role": "AXButton",
                   "frame": { "x": 16, "y": 120, "width": 370, "height": 52 }, "enabled": true, "interactive": true, "adjustable": false },
      "point": { "x": 201, "y": 146 }, "exact": true }
  ],
  "excluded": []
}
```

## エラー

上記の [セレクタのエラー](https://air.build/ja/docs/mcp-tools/simulator_find/#selector) と、すべてのシミュレータツールが返す可能性のあるエラー：[start_simulator](https://air.build/ja/docs/mcp-tools/start_simulator/#device-errors) を参照してください。

## 例

```json
{"name": "simulator_find", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "text": "New note"}}
```
