mobile_type_keys
Automate text input on mobile devices by typing into focused elements, with an option to simulate pressing the enter key for submission. Ideal for iOS and Android app interactions.
Instructions
Type text into the focused element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| submit | Yes | Whether to submit the text. If true, the text will be submitted as if the user pressed the enter key. | |
| text | Yes | The text to type |
Implementation Reference
- src/server.ts:476-485 (handler)Handler function that retrieves the appropriate Robot instance for the device and invokes sendKeys(text) to type the text, optionally pressing ENTER if submit is true.async ({ device, text, submit }) => { const robot = getRobotFromDevice(device); await robot.sendKeys(text); if (submit) { await robot.pressButton("ENTER"); } return `Typed text: ${text}`; }
- src/server.ts:471-475 (schema)Zod schema defining input parameters: device (string), text (string), submit (boolean).{ device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), text: z.string().describe("The text to type"), submit: z.boolean().describe("Whether to submit the text. If true, the text will be submitted as if the user pressed the enter key."), },
- src/server.ts:468-486 (registration)Registers the mobile_type_keys MCP tool with the server using the custom tool() wrapper, including description, input schema, and handler function.tool( "mobile_type_keys", "Type text into the focused element", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), text: z.string().describe("The text to type"), submit: z.boolean().describe("Whether to submit the text. If true, the text will be submitted as if the user pressed the enter key."), }, async ({ device, text, submit }) => { const robot = getRobotFromDevice(device); await robot.sendKeys(text); if (submit) { await robot.pressButton("ENTER"); } return `Typed text: ${text}`; } );
- src/server.ts:153-178 (helper)Helper function to get the appropriate Robot instance (AndroidRobot, IosRobot, or Simulator) based on the device identifier.const getRobotFromDevice = (device: string): Robot => { const iosManager = new IosManager(); const androidManager = new AndroidDeviceManager(); const simulators = simulatorManager.listBootedSimulators(); const androidDevices = androidManager.getConnectedDevices(); const iosDevices = iosManager.listDevices(); // Check if it's a simulator const simulator = simulators.find(s => s.name === device); if (simulator) { return simulatorManager.getSimulator(device); } // Check if it's an Android device const androidDevice = androidDevices.find(d => d.deviceId === device); if (androidDevice) { return new AndroidRobot(device); } // Check if it's an iOS device const iosDevice = iosDevices.find(d => d.deviceId === device); if (iosDevice) { return new IosRobot(device); } throw new ActionableError(`Device "${device}" not found. Use the mobile_list_available_devices tool to see available devices.`);