mobile_list_available_devices
Retrieve a list of all available mobile devices and simulators for testing and automation. Select a device from the returned options to proceed with mobile application interactions.
Instructions
List all available devices. This includes both physical devices and simulators. If there is more than one device returned, you need to let the user select one of them.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noParams | Yes |
Implementation Reference
- src/server.ts:188-248 (handler)The handler function for mobile_list_available_devices tool. It ensures mobilecli is available, then collects devices from Android (emulators), iOS real devices (if available), and iOS simulators via mobilecli, formats them as MobilecliDevice objects, and returns JSON.async ({}) => { // from today onward, we must have mobilecli working ensureMobilecliAvailable(); const iosManager = new IosManager(); const androidManager = new AndroidDeviceManager(); const devices: MobilecliDevice[] = []; // Get Android devices with details const androidDevices = androidManager.getConnectedDevicesWithDetails(); for (const device of androidDevices) { devices.push({ id: device.deviceId, name: device.name, platform: "android", type: "emulator", version: device.version, state: "online", }); } // Get iOS physical devices with details try { const iosDevices = iosManager.listDevicesWithDetails(); for (const device of iosDevices) { devices.push({ id: device.deviceId, name: device.deviceName, platform: "ios", type: "real", version: device.version, state: "online", }); } } catch (error: any) { // If go-ios is not available, silently skip } // Get iOS simulators from mobilecli (excluding offline devices) const response = mobilecli.getDevices({ platform: "ios", type: "simulator", includeOffline: false, }); if (response.status === "ok" && response.data && response.data.devices) { for (const device of response.data.devices) { devices.push({ id: device.id, name: device.name, platform: device.platform, type: device.type, version: device.version, state: "online", }); } } const out: MobilecliDevicesResponse = { devices }; return JSON.stringify(out); }
- src/server.ts:181-249 (registration)The registration of the tool using the custom 'tool' helper function, which internally calls server.registerTool with name, title, description, empty inputSchema (noParams), and the handler callback.tool( "mobile_list_available_devices", "List Devices", "List all available devices. This includes both physical devices and simulators. If there is more than one device returned, you need to let the user select one of them.", { noParams }, async ({}) => { // from today onward, we must have mobilecli working ensureMobilecliAvailable(); const iosManager = new IosManager(); const androidManager = new AndroidDeviceManager(); const devices: MobilecliDevice[] = []; // Get Android devices with details const androidDevices = androidManager.getConnectedDevicesWithDetails(); for (const device of androidDevices) { devices.push({ id: device.deviceId, name: device.name, platform: "android", type: "emulator", version: device.version, state: "online", }); } // Get iOS physical devices with details try { const iosDevices = iosManager.listDevicesWithDetails(); for (const device of iosDevices) { devices.push({ id: device.deviceId, name: device.deviceName, platform: "ios", type: "real", version: device.version, state: "online", }); } } catch (error: any) { // If go-ios is not available, silently skip } // Get iOS simulators from mobilecli (excluding offline devices) const response = mobilecli.getDevices({ platform: "ios", type: "simulator", includeOffline: false, }); if (response.status === "ok" && response.data && response.data.devices) { for (const device of response.data.devices) { devices.push({ id: device.id, name: device.name, platform: device.platform, type: device.type, version: device.version, state: "online", }); } } const out: MobilecliDevicesResponse = { devices }; return JSON.stringify(out); } );
- src/server.ts:42-42 (schema)The empty Zod schema used as inputSchema for tools that take no parameters, including mobile_list_available_devices.const noParams = z.object({});
- src/server.ts:131-140 (helper)Helper function called by the handler to ensure mobilecli is available before listing devices.const ensureMobilecliAvailable = (): void => { try { const version = mobilecli.getVersion(); if (version.startsWith("failed")) { throw new Error("mobilecli version check failed"); } } catch (error: any) { throw new ActionableError(`mobilecli is not available or not working properly. Please review the documentation at https://github.com/mobile-next/mobile-mcp/wiki for installation instructions`); } };
- src/server.ts:16-23 (helper)Type definitions for devices and response used in the tool implementation.interface MobilecliDevice { id: string; name: string; platform: "android" | "ios"; type: "real" | "emulator" | "simulator"; version: string; state: "online" | "offline"; }