Skip to main content
Glama

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
NameRequiredDescriptionDefault
platformYesTarget platform

Implementation Reference

  • 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}`); } };
  • 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") });
  • 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 );

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/zillow/auto-mobile'

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