listDevices
Retrieve all connected Android and iOS devices, including physical and virtual devices, for mobile automation testing and management.
Instructions
List all connected devices (both physical and virtual devices)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platform | Yes | Target platform |
Implementation Reference
- src/server/deviceTools.ts:52-85 (handler)Handler function that lists booted devices for the given platform, categorizes them as virtual or physical, and returns formatted JSON response.const listBootedDevicesHandler = async (args: ListDevicesArgs) => { try { const deviceUtils = new DeviceUtils(); const bootedDevices = await deviceUtils.getBootedDevices(args.platform); // Categorize devices by type const devices = bootedDevices.map(device => { // For Android: emulator devices have deviceId starting with "emulator-" // For iOS: simulator devices typically have deviceId as UUID format or contain "simulator" const isVirtual = args.platform === "android" ? device.deviceId.startsWith("emulator-") : device.deviceId.includes("-") && device.deviceId.length > 30; // iOS simulators typically have long UUID-like IDs return { ...device, isVirtual }; }); const virtualCount = devices.filter(d => d.isVirtual).length; const physicalCount = devices.filter(d => !d.isVirtual).length; return createJSONToolResponse({ message: `Found ${devices.length} connected ${args.platform} devices`, devices: devices, totalCount: devices.length, virtualCount: virtualCount, physicalCount: physicalCount, platform: args.platform }); } catch (error) { throw new ActionableError(`Failed to list ${args.platform} devices: ${error}`); } };
- src/server/deviceTools.ts:12-14 (schema)Zod schema defining the input parameters for the listDevices tool: requires 'platform' as 'android' or 'ios'.export const listDevicesSchema = z.object({ platform: z.enum(["android", "ios"]).describe("Target platform") });
- src/server/deviceTools.ts:152-157 (registration)Registration of the listDevices tool with the ToolRegistry, linking name, description, schema, and handler.ToolRegistry.register( "listDevices", "List all connected devices (both physical and virtual devices)", listDevicesSchema, listBootedDevicesHandler );