startDevice
Initiate a device with the specified device image, including name, source, and platform, for mobile automation testing using the AutoMobile MCP server.
Instructions
Start a device with the specified device image
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | ||
| timeoutMs | No | Maximum time to wait for device to be ready in milliseconds |
Implementation Reference
- src/server/deviceTools.ts:106-134 (handler)The MCP tool handler for 'startDevice' that orchestrates device startup using DeviceUtils.startDevice and waits for readiness, providing progress updates and returning 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.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/utils/deviceUtils.ts:81-92 (helper)Supporting utility method in DeviceUtils class that starts the device by delegating to platform-specific tools (AndroidEmulator or Simctl). Called by the main handler.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"); } }