MCP 工具

这个 MCP 工具在团队模拟器的屏幕上某个点,或在选择器指定的元素上点按或长按。

simulator_tap 以以下两种方式之一点按团队正在运行的模拟器的屏幕。必须恰好提供一种:

  • 坐标:x 和 y,使用 屏幕坐标。点按会立即落在那里,无论下面是什么。
  • 元素:一个选择器,可以是 text、id、value、role 和来自 simulator_describe_ui 或 simulator_find 的 nodeId 中的任意几个(见 选择器)。工具最多等待 timeoutSeconds,直到出现已启用且静止的匹配元素,然后点按它(它的中心,或对于开关等控件由 iOS 给出的点)。它不会滚动:请先用 simulator_scroll_to 把元素带到屏幕上。

duration 会按住手指:即长按。工具不检查点按的效果;请用 simulator_describe_ui 查看,或用 simulator_wait 等待结果。

只读 破坏性 幂等
否 否 否

输入

输入 类型 必填 默认值 作用
teamId 字符串(UUID) 是 — 团队,来自 list_teams
simulator string 否 团队的默认设备 哪种设备,使用 list_simulators 中的 id
x 数字,-100000 到 100000 与 y 一起使用 — 点按的位置,横向
y 数字,-100000 到 100000 与 x 一起使用 — 点按的位置,纵向
text, id, value, role, nodeId, exact, strict 见 选择器 代替 x、y — 要点按的元素
duration 数字,0 到 60 否 普通点按 按住的秒数:长按
timeoutSeconds 数字,0 到 600 否 10 使用选择器时:等待元素的时长
display string 否 正在使用的显示屏 使用坐标且在折叠设备上时:来自 simulator_displays 的显示屏 screenId

结果

使用坐标时:

字段 说明
ok true

使用选择器时:

字段 说明
ok true
element 被点按的元素(字段与 simulator_find 中相同)
point x、y:点按落下的位置
exact 它的文本是否与查询相同
matchCount 有多少可用元素匹配;大于 1 表示由排序选择
excluded 匹配但被排除的元素,带有 reason
elapsedMs 等待超过一轮时:等待了多长时间,以毫秒计
{
  "ok": true,
  "element": { "label": "New note", "identifier": "new-note", "role": "AXButton",
               "frame": { "x": 16, "y": 120, "width": 370, "height": 52 }, "enabled": true, "interactive": true, "adjustable": false },
  "point": { "x": 201, "y": 146 },
  "exact": true,
  "matchCount": 1,
  "excluded": []
}

错误

消息 何时出现 怎么办
Give both x and y. 只有一个坐标 两个都发送
Give coordinates or a selector, not both. 同时提供了坐标和选择器字段 只发送其中一种
Name the element: text, id, value, role or nodeId. 既没有坐标也没有选择器 发送其中一个
no usable element matching selector within ns 在时限内没有匹配到可用的元素 见 选择器错误

另外还有其他 选择器错误,以及每个模拟器工具都可能返回的错误:见 start_simulator。

示例

{"name": "simulator_tap", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "id": "new-note"}}