Skip to main content
Glama

detox_list_devices

List available iOS simulators and Android emulators for mobile testing. Manage device selection in React Native E2E testing with the Detox framework.

Instructions

List available iOS simulators and Android emulators.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformNoall
availableOnlyNo

Implementation Reference

  • Main handler function that executes the logic for listing iOS simulators and Android emulators, filtering by platform and availability.
    export const listDevicesTool: Tool = { name: "detox_list_devices", description: "List available iOS simulators and Android emulators.", inputSchema: zodToJsonSchema(ListDevicesArgsSchema), handler: async (args: z.infer<typeof ListDevicesArgsSchema>) => { const parsed = ListDevicesArgsSchema.parse(args); const devices: any[] = []; if (parsed.platform === "all" || parsed.platform === "ios") { const iosDevices = await listIOSSimulators(); devices.push(...iosDevices); } if (parsed.platform === "all" || parsed.platform === "android") { const androidDevices = await listAndroidEmulators(); devices.push(...androidDevices); } let filteredDevices = devices; if (parsed.availableOnly) { filteredDevices = devices.filter( (d) => d.state === "Booted" || d.state === "available" ); } return { success: true, devices: filteredDevices, total: filteredDevices.length, }; }, };
  • Zod schema defining the input parameters for the detox_list_devices tool: platform (ios/android/all) and availableOnly flag.
    export const ListDevicesArgsSchema = z.object({ platform: z.enum(["ios", "android", "all"]).optional().default("all"), availableOnly: z.boolean().optional().default(false), }); export type ListDevicesArgs = z.infer<typeof ListDevicesArgsSchema>;
  • Helper function to list available iOS simulators using xcrun simctl.
    export async function listIOSSimulators(): Promise<any[]> { const result = await executeCommand("xcrun simctl list devices --json"); if (!result.success) { return []; } try { const data = JSON.parse(result.stdout); const devices: any[] = []; for (const [runtime, deviceList] of Object.entries(data.devices || {})) { if (Array.isArray(deviceList)) { for (const device of deviceList) { devices.push({ id: device.udid, name: device.name, state: device.state, runtime: runtime.replace("com.apple.CoreSimulator.SimRuntime.", ""), platform: "ios", }); } } } return devices; } catch { return []; } }
  • Helper function to list available Android emulators/AVDs using emulator -list-avds.
    export async function listAndroidEmulators(): Promise<any[]> { const result = await executeCommand("emulator -list-avds"); if (!result.success) { return []; } const avdNames = result.stdout .split("\n") .map((line) => line.trim()) .filter((line) => line.length > 0); return avdNames.map((name) => ({ id: name, name, state: "available", platform: "android", })); }
  • The detox_list_devices tool (as listDevicesTool) is registered in the allTools array, which is imported and used by the MCP server to list and call tools.
    export const allTools: Tool[] = [ buildTool, testTool, initTool, readConfigTool, listConfigurationsTool, validateConfigTool, createConfigTool, listDevicesTool, generateTestTool, generateMatcherTool, generateActionTool, generateExpectationTool, ];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gayancliyanage/detox-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server