listDevices
Retrieve a list of all connected physical and virtual devices on a specific platform (Android or iOS) for mobile automation and testing purposes.
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)The handler function for the 'listDevices' tool. It fetches booted devices using DeviceUtils, categorizes them as virtual or physical, counts them, and returns a structured 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, requiring a 'platform' field ("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 ToolRegistry, including name, description, schema, and handler function.ToolRegistry.register( "listDevices", "List all connected devices (both physical and virtual devices)", listDevicesSchema, listBootedDevicesHandler );