shake
Simulate a shake gesture on iOS simulators and Android emulators for testing motion-sensitive app behavior.
Instructions
Simule un geste de shake sur le device. iOS : via raccourci Simulator (Ctrl+Cmd+Z). Android : swipes rapides.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:21-21 (registration)Import of registerShake from device-actions.ts
import { registerShake, registerRotate } from "./tools/device-actions.js"; - src/index.ts:58-58 (registration)Registration call: registerShake(server) invoked to register the shake tool with the MCP server
registerShake(server); - src/tools/device-actions.ts:11-48 (handler)Handler function registerShake: defines the 'shake' MCP tool. For iOS it simulates shake via AppleScript (Ctrl+Cmd+Z keystroke), for Android it calls androidShake() which does rapid swipes.
export function registerShake(server: McpServer): void { server.tool( "shake", "Simule un geste de shake sur le device. iOS : via raccourci Simulator (Ctrl+Cmd+Z). Android : swipes rapides.", {}, async () => { const result = await resolveDevice(); if ("error" in result) return { content: [{ type: "text", text: result.error }], isError: true }; const dev = result.device; try { if (dev.platform === "ios") { // Ctrl+Cmd+Z = Hardware > Shake Gesture in Simulator try { await execFileAsync("osascript", ["-e", 'tell application "Simulator" to activate', ]); await new Promise((r) => setTimeout(r, 300)); await execFileAsync("osascript", ["-e", 'tell application "System Events" to keystroke "z" using {control down, command down}', ]); } catch (err) { console.error(`[phantom] Shake AppleScript failed: ${err instanceof Error ? err.message : err}`); return { content: [{ type: "text", text: "Shake envoyé. Note : le Simulator doit être au premier plan et les permissions Accessibility activées." }] }; } } else { await androidShake(); } logAction("shake", "Shake effectué", false, dev.platform, dev.id, dev.name); return { content: [{ type: "text", text: "Shake effectué." }] }; } catch (err) { const msg = err instanceof Error ? err.message : String(err); return { content: [{ type: "text", text: `Erreur shake: ${msg}` }], isError: true }; } } ); } - src/tools/device-actions.ts:15-15 (schema)Empty schema (no input parameters) for the shake tool
{}, - src/platforms/android/adb.ts:426-435 (helper)androidShake helper: simulates a shake on Android by performing 3 rapid side-to-side swipes on the center of the screen
export async function androidShake(): Promise<void> { // Simulate sensor events for shake — rapid x-axis accelerometer changes // This uses `input swipe` as a workaround — real shake needs instrumentation const size = await androidGetScreenSize(); const cx = size.width / 2, cy = size.height / 2; // Rapid side-to-side swipes simulate a shake visually await androidSwipe(cx - 100, cy, cx + 100, cy, 50); await androidSwipe(cx + 100, cy, cx - 100, cy, 50); await androidSwipe(cx - 100, cy, cx + 100, cy, 50); }