listDeviceImages
Retrieve available device images for Android or iOS platforms to support mobile automation testing and development.
Instructions
List all available device images for the specified platform
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platform | Yes | Target platform |
Implementation Reference
- src/server/deviceTools.ts:88-103 (handler)Main execution handler for the 'listDeviceImages' MCP tool. Instantiates DeviceUtils and calls listDeviceImages(platform), then formats response.
const listDeviceImagesHandler = async (args: listDeviceImagesArgs) => { try { const deviceUtils = new DeviceUtils(); const imageList = await deviceUtils.listDeviceImages(args.platform); return createJSONToolResponse({ message: `Found ${imageList.length} available ${args.platform} AVDs`, images: imageList, count: imageList.length, platform: args.platform }); } catch (error) { throw new ActionableError(`Failed to list ${args.platform} AVDs: ${error}`); } }; - src/server/deviceTools.ts:8-10 (schema)Zod input schema validation for listDeviceImages tool: requires 'platform' as 'android' or 'ios'.
export const listDeviceImagesSchema = z.object({ platform: z.enum(["android", "ios"]).describe("Target platform") }); - src/server/deviceTools.ts:159-164 (registration)ToolRegistry registration of 'listDeviceImages' with name, description, schema, and handler.
ToolRegistry.register( "listDeviceImages", "List all available device images for the specified platform", listDeviceImagesSchema, listDeviceImagesHandler ); - src/utils/deviceUtils.ts:32-43 (helper)Core helper method DeviceUtils.listDeviceImages that routes to AndroidEmulator.listAvds() or Simctl.listSimulatorImages() based on platform.
async listDeviceImages(platform: SomePlatform): Promise<DeviceInfo[]> { switch (platform) { case "android": return this.emulator.listAvds(); case "ios": return this.simctl.listSimulatorImages(); case "either": const emulators = await this.emulator.listAvds(); const simulators = await this.simctl.listSimulatorImages(); return [...emulators, ...simulators]; } } - Android-specific helper: executes 'avdmanager list avd', parses output to list available AVD images (used by AndroidEmulator.listAvds()).
export async function listDeviceImages(dependencies = createDefaultDependencies()): Promise<AvdInfo[]> { try { const location = await ensureToolsAvailable(dependencies); const avdmanagerPath = getAvdManagerPath(location, dependencies); const result = await spawnCommand(avdmanagerPath, ["list", "avd"], {}, dependencies); if (result.exitCode !== 0) { throw new Error(`Failed to list AVDs: ${result.stderr}`); } return parseAvdList(result.stdout); } catch (error) { dependencies.logger.error(`Failed to list AVDs: ${(error as Error).message}`); throw error; } }