list_devices
Retrieve a list of all available mobile devices including iOS simulators, Android emulators, and connected real devices, with their platform and status.
Instructions
Liste tous les devices disponibles — simulateurs iOS, émulateurs Android, et vrais devices connectés. Affiche la plateforme et l'état de chaque device.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_devices"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/devices.ts:4-20 (handler)Handler function that registers and implements the list_devices MCP tool. Calls getAllDevices(), getActiveDevice(), and formatDeviceList() to produce the output.
export function registerListDevices(server: McpServer): void { server.tool( "list_devices", "Liste tous les devices disponibles — simulateurs iOS, émulateurs Android, et vrais devices connectés. Affiche la plateforme et l'état de chaque device.", {}, async () => { const devices = await getAllDevices(); const active = await getActiveDevice(); let text = formatDeviceList(devices); if (active) { text += `\n\n**Device actif : ${active.name}** (${active.platform} ${active.type})`; } return { content: [{ type: "text", text }] }; } ); - src/utils/device-manager.ts:40-53 (helper)Helper that gathers all devices from iOS simulators, iOS real devices, and Android (ADB) with 3-second caching.
export async function getAllDevices(): Promise<DeviceInfo[]> { if (deviceListCache && Date.now() - deviceListCacheTime < CACHE_TTL_MS) { return deviceListCache; } const [iosSims, iosReal, android] = await Promise.all([ listIosDevices(), listIosRealDevices(), listAndroidDevices(), ]); deviceListCache = [...iosReal, ...android, ...iosSims]; deviceListCacheTime = Date.now(); return deviceListCache; } - src/utils/device-manager.ts:69-85 (helper)Helper that determines which device is currently active (manually selected or single booted device).
export async function getActiveDevice(): Promise<DeviceInfo | null> { const booted = await getBootedDevices(); // If a device was manually selected, find it if (selectedDeviceId) { const found = booted.find((d) => d.id === selectedDeviceId); if (found) return found; // Selected device no longer available — clear selection selectedDeviceId = null; } // Only one device booted — use it if (booted.length === 1) return booted[0]; // Multiple or none — return null to trigger device selection return null; } - src/utils/device-manager.ts:100-128 (helper)Helper that formats the device list into a human-readable string grouped by platform (iOS/Android) with status icons.
export function formatDeviceList(devices: DeviceInfo[]): string { if (devices.length === 0) return "Aucun device disponible."; const lines: string[] = []; // Group by platform const ios = devices.filter((d) => d.platform === "ios"); const android = devices.filter((d) => d.platform === "android"); if (ios.length > 0) { lines.push("\n## iOS"); for (const d of ios) { const icon = d.state === "booted" ? "🟢" : "⚪"; const typeLabel = d.type === "device" ? " [real device]" : ""; lines.push(`${icon} ${d.name}${typeLabel} — ${d.state} (${d.id})`); } } if (android.length > 0) { lines.push("\n## Android"); for (const d of android) { const icon = "🟢"; // Android devices from ADB are always connected const typeLabel = d.type === "device" ? " [real device]" : " [emulator]"; lines.push(`${icon} ${d.name}${typeLabel} (${d.id})`); } } return lines.join("\n"); } - src/platforms/types.ts:1-7 (schema)DeviceInfo type definition used across all device-related tools including list_devices.
export interface DeviceInfo { id: string; name: string; platform: "ios" | "android"; type: "simulator" | "emulator" | "device"; state: "booted" | "shutdown"; }