MCP 工具

這個 MCP 工具會把團隊模擬器上的標準滑桿設定為某個百分比,並讀回值。

simulator_slider 會把團隊正在執行的模擬器上的滑桿移動到其軌道的 percent 處,然後再次讀取滑桿的值,確認它到達了目標。值最終必須在 3 個百分點以內;為此它最多移動滑桿四次。滑桿以 選擇器 指定,從不以座標指定。工具一律尋找角色為 AXSlider 的元素,而且一律是嚴格的,所以選擇器必須剛好符合一個滑桿。它最多等待 10 秒。它只適用於標準的由左到右的 iOS 滑桿,其輔助使用值為 0 到 1 的小數或百分比。自訂範圍和垂直滑桿會被拒絕。對於這些滑桿,請使用 simulator_adjust 或 simulator_drag。再次設定相同的百分比不會有影響。檢查失敗時,滑桿可能已經移動過。

唯讀 破壞性 冪等
否 否 是

輸入

輸入 類型 必填 預設值 作用
teamId 字串(UUID) 是 — 團隊,來自 list_teams
simulator string 否 團隊的預設裝置 哪種裝置,使用 list_simulators 中的 id
text, id, value, role, nodeId, exact, strict 請參閱 選擇器 前五個中至少一個 — 滑桿。role 只能是 AXSlider;strict 一律開啟
percent 數字,0 到 100 是 — 把滑桿放在哪裡:0 為左端,100 為右端

結果

欄位 說明
element 移動後讀取的滑桿。它的 value 是現在的值。其他欄位與 simulator_find 中相同
point x、y:滑桿的點一下位置
exact 它的文字是否與查詢相同
matchCount 1
excluded 符合但被排除的滑桿,帶有 reason
{
  "element": { "label": "Volume", "value": "0.75", "identifier": "volume", "role": "AXSlider",
               "frame": { "x": 16, "y": 400, "width": 370, "height": 44 }, "enabled": true, "interactive": true, "adjustable": true },
  "point": { "x": 201, "y": 422 },
  "exact": true,
  "matchCount": 1,
  "excluded": []
}

錯誤

訊息 何時出現 處理方式
percent is required. 缺少 percent 傳送 0 到 100
percent must be a number from 0 to 100. percent 超出範圍 傳送 0 到 100
slider selector role must be AXSlider role 指定了其他角色 省略 role 或傳送 AXSlider
slider is disabled 滑桿呈灰色 先在 App 中啟用它
slider has no accessible percentage value 滑桿不回報值 使用 simulator_drag
slider value is not normalized 0..1; custom ranges are unsupported 滑桿以它自己的刻度回報值 使用 simulator_adjust
no supported horizontal slider track 該滑桿不是標準的水平滑桿 使用 simulator_drag
slider track is off-screen 軌道的一部分在螢幕外 用 simulator_scroll_to 把它捲動到畫面中
slider verification failed: requested p%, observed q% 移動四次後,值仍相差超過 3 個百分點 用 simulator_find 讀取它;重試或使用 simulator_adjust
ambiguous selector selector: n usable matches; add an id, role, or value filter 符合多個滑桿 以 id 或 nodeId 指定
no usable element matching selector within 10s 10 秒內沒有符合的滑桿 用 simulator_find 檢查

另外還有其他 選擇器錯誤,以及每個模擬器工具都可能傳回的錯誤:請參閱 start_simulator。

範例

{"name": "simulator_slider", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "id": "volume", "percent": 75}}