Skip to main content
Glama

android_list_devices

List connected Android devices and emulators to manage development environments, using ADB or native-run for detection.

Instructions

List connected Android devices and emulators (supports ADB fallback to native-run)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core execution logic for android_list_devices: runs 'adb devices -l' via fallback manager, parses output for device details (serial, state, product, model, device, transport_id), computes counts, and handles fallback information.
    handler: async () => { const fallbackResult = await fallbackManager.executeAdbWithFallback( ['devices', '-l'], { platform: 'android' } ); if (!fallbackResult.success) { throw new Error(fallbackResult.error || 'Failed to list devices'); } const result = fallbackResult.data; // Parse adb devices output const devices = []; const lines = result.stdout.split('\n').slice(1); // Skip header for (const line of lines) { const trimmed = line.trim(); if (trimmed && !trimmed.startsWith('*')) { const parts = trimmed.split(/\s+/); if (parts.length >= 2) { const device = { serial: parts[0], state: parts[1], product: '', model: '', device: '', transport_id: '', }; // Parse additional info for (let i = 2; i < parts.length; i++) { const part = parts[i]; if (part && part.startsWith('product:')) { device.product = part.split(':')[1] || ''; } else if (part && part.startsWith('model:')) { device.model = part.split(':')[1] || ''; } else if (part && part.startsWith('device:')) { device.device = part.split(':')[1] || ''; } else if (part && part.startsWith('transport_id:')) { device.transport_id = part.split(':')[1] || ''; } } devices.push(device); } } } return { success: true, data: { devices, totalCount: devices.length, onlineCount: devices.filter(d => d.state === 'device').length, fallbackInfo: fallbackResult.usedFallback ? { usedFallback: true, fallbackTool: fallbackResult.fallbackTool, message: fallbackResult.message } : undefined }, }; }
  • Registration of the android_list_devices tool in createAndroidTools(), including name, description, empty input schema (no args required), and handler reference.
    tools.set('android_list_devices', { name: 'android_list_devices', description: 'List connected Android devices and emulators (supports ADB fallback to native-run)', inputSchema: { type: 'object', properties: {}, required: [] }, handler: async () => { const fallbackResult = await fallbackManager.executeAdbWithFallback( ['devices', '-l'], { platform: 'android' } ); if (!fallbackResult.success) { throw new Error(fallbackResult.error || 'Failed to list devices'); } const result = fallbackResult.data; // Parse adb devices output const devices = []; const lines = result.stdout.split('\n').slice(1); // Skip header for (const line of lines) { const trimmed = line.trim(); if (trimmed && !trimmed.startsWith('*')) { const parts = trimmed.split(/\s+/); if (parts.length >= 2) { const device = { serial: parts[0], state: parts[1], product: '', model: '', device: '', transport_id: '', }; // Parse additional info for (let i = 2; i < parts.length; i++) { const part = parts[i]; if (part && part.startsWith('product:')) { device.product = part.split(':')[1] || ''; } else if (part && part.startsWith('model:')) { device.model = part.split(':')[1] || ''; } else if (part && part.startsWith('device:')) { device.device = part.split(':')[1] || ''; } else if (part && part.startsWith('transport_id:')) { device.transport_id = part.split(':')[1] || ''; } } devices.push(device); } } } return { success: true, data: { devices, totalCount: devices.length, onlineCount: devices.filter(d => d.state === 'device').length, fallbackInfo: fallbackResult.usedFallback ? { usedFallback: true, fallbackTool: fallbackResult.fallbackTool, message: fallbackResult.message } : undefined }, }; } });
  • Metadata in TOOL_REGISTRY defining category (ESSENTIAL), platform (android), required tools (ADB), safety, and performance expectations for validation and health checks.
    'android_list_devices': { name: 'android_list_devices', category: ToolCategory.ESSENTIAL, platform: 'android', requiredTools: [RequiredTool.ADB], description: 'List connected Android devices and emulators', safeForTesting: true, performance: { expectedDuration: 500, timeout: 10000 } },

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/cristianoaredes/mcp-mobile-server'

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