MCP 工具

這個 MCP 工具會向團隊的模擬器傳送一個原始輸入事件,用於其他輸入工具無法涵蓋的手勢。

simulator_input 會向團隊正在執行的模擬器傳送一個原始輸入事件。用它來做其他工具做不到的事:跨多次呼叫保持按下的觸控、雙指捏合,或從螢幕邊緣滑入。一個完整手勢由多個事件組成(按下、一次或多次移動、抬起),所以請依序傳送,或作為 simulator_batch 的 input 步驟一起傳送。點使用 螢幕座標,不會與元素進行核對。日常的點一下、滑動、輸入和按鈕,請優先使用為它們設計的工具。

唯讀 破壞性 冪等
否 否 否

事件

event 是一個物件,包含 type 以及該類型的欄位:

type 欄位 作用
touch1-down, touch1-move, touch1-up, touch1-cancel x、y;edge(選填) 單指:按下、移動、抬起或取消。edge(例如 left、bottom)會使它成為從螢幕該邊緣滑入
touch2-down, touch2-move, touch2-up, touch2-cancel x1, y1, x2, y2 同時兩根手指,用於捏合或雙指旋轉
tap x、y;duration(選填) 點一下,與使用座標的 simulator_tap 相同
swipe startX、startY、endX、endY;duration(選填) 與 simulator_swipe 相同
type text 與 simulator_type_text 相同
key code;modifiers、duration(選填) 與 simulator_key 相同
button button;duration(選填) 與 simulator_button 相同
orientation orientation 與 simulator_rotate 相同
fold degrees(0 到 180) 轉動摺疊裝置的鉸鏈,與 simulator_fold 相同

每個指標事件(touch1-*、touch2-*、tap、swipe)還接受選填的 width 和 height:傳送它們後,座標就以該尺寸的框架為準,而不是裝置的螢幕,並會依比例縮放以符合。任何事件都可以帶上 display,即來自 simulator_displays 的顯示器 screenId,以指定摺疊裝置的某一個顯示器。

輸入

輸入 類型 必填 預設值 作用
teamId 字串(UUID) 是 — 團隊,來自 list_teams
simulator string 否 團隊的預設裝置 哪種裝置,使用 list_simulators 中的 id
event 帶有 type 的物件 是 — 事件

結果

欄位 說明
ok true
{ "ok": true }

錯誤

訊息 何時出現 處理方式
event is an object with a “type”. 缺少 event、它不是物件,或沒有 type 傳送一個帶有 type 的物件
Failed to deserialize the JSON body into the target type: … 不明的 type、缺少欄位,或欄位類型錯誤 修正訊息中指出的欄位

另外還有每個模擬器工具都可能傳回的錯誤:請參閱 start_simulator。

範例

從左邊緣滑入(返回),分三次呼叫:

{"name": "simulator_input", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "event": {"type": "touch1-down", "x": 2, "y": 400, "edge": "left"}}}
{"name": "simulator_input", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "event": {"type": "touch1-move", "x": 200, "y": 400, "edge": "left"}}}
{"name": "simulator_input", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "event": {"type": "touch1-up", "x": 300, "y": 400, "edge": "left"}}}