Skip to main content
Glama

android_list_devices

List connected Android devices and emulators to manage mobile development environments, using ADB fallback for reliable detection.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that lists Android devices and emulators using ADB 'devices -l' command via fallback manager, parses detailed device information (serial, state, product, model, device, transport_id), counts total/online devices, and includes fallback information if used.
    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 within the createAndroidTools factory function, including name, description, input schema, 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 }, }; } });
  • Input schema definition for the tool, specifying an empty object (no required parameters).
    inputSchema: { type: 'object', properties: {}, required: [] },
  • Tool metadata and categorization in the registry, marking it as ESSENTIAL for Android platform requiring ADB, safe for testing.
    '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