startDevice
Start a mobile device with a specified image for automated testing. Use this tool to launch Android or iOS devices by providing device details and target platform.
Instructions
Start a device with the specified device image
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| localDevice | Yes | ||
| platform | Yes | Target platform |
Implementation Reference
- src/server/deviceTools.ts:106-134 (handler)Main handler function that executes the startDevice tool logic: creates DeviceUtils instance, starts the device process, waits for readiness, reports progress, and returns device info.const startDeviceHandler = async (args: startDeviceArgs, progress?: ProgressCallback) => { try { const deviceUtils = new DeviceUtils(); const childProcess = await deviceUtils.startDevice(args.device); if (progress) { await progress(60, 100, "Device started, waiting for readiness..."); } // Wait for device to be ready const readyDevice = await deviceUtils.waitForDeviceReady(args.device, args.timeoutMs); if (progress) { await progress(100, 100, "Device is ready for use"); } return createJSONToolResponse({ message: `${args.device.platform} '${args.device.name}' started and is ready`, name: readyDevice.name, processId: childProcess.pid, isReady: true, deviceId: readyDevice.deviceId, source: args.device.source, platform: args.device.platform }); } catch (error) { throw new ActionableError(`Failed to start ${args.device.platform} device: ${error}`); } };
- src/server/deviceTools.ts:16-22 (schema)Zod schema defining the input parameters for the startDevice tool, including device details and platform.export const startDeviceSchema = z.object({ localDevice: z.object({ name: z.string().describe("The device name to start"), deviceId: z.string().optional().describe("The device ID") }), platform: z.enum(["android", "ios"]).describe("Target platform") });
- src/server/deviceTools.ts:166-172 (registration)Registration of the startDevice tool with ToolRegistry, including name, description, schema, handler, and progress support flag.ToolRegistry.register( "startDevice", "Start a device with the specified device image", startDeviceSchema, startDeviceHandler, true // Supports progress notifications );
- src/server/deviceTools.ts:33-36 (schema)TypeScript interface defining the arguments for the startDevice handler.export interface startDeviceArgs { device: DeviceInfo; timeoutMs?: number; }
- src/utils/deviceUtils.ts:81-92 (helper)Helper method in DeviceUtils class that spawns the actual device process (emulator or simulator) based on platform.async startDevice( device: DeviceInfo ): Promise<ChildProcess> { switch (device.platform) { case "android": return this.emulator.startEmulator(device.name); case "ios": return this.simctl.startSimulator(device.name); default: throw new ActionableError("Unknown platform"); } }