adb_list_devices
List all connected Android devices to identify available targets for debugging, automation, or management tasks.
Instructions
List all connected Android devices
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/device.ts:6-21 (handler)The handler function for 'adb_list_devices' tool. Calls AdbClient.getDevices() and formats the response with success status and message.async listDevices() { try { const devices = await this.adbClient.getDevices(); return { success: true, data: devices, message: `Found ${devices.length} device(s)` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to list devices' }; } }
- src/adb-client.ts:38-71 (helper)Core helper function that executes 'adb devices -l' command, parses the output, and returns structured list of AdbDevice objects.async getDevices(): Promise<AdbDevice[]> { const result = await this.executeCommand('devices -l'); if (!result.success) { throw new Error(`Failed to get devices: ${result.error}`); } const devices: AdbDevice[] = []; const lines = result.output.split('\n').slice(1); // Skip header line for (const line of lines) { if (line.trim()) { const parts = line.split(/\s+/); if (parts.length >= 2) { const device: AdbDevice = { id: parts[0], status: parts[1] as AdbDevice['status'] }; // Parse additional info if available for (let i = 2; i < parts.length; i++) { const [key, value] = parts[i].split(':'); if (key === 'model') device.model = value; if (key === 'product') device.product = value; if (key === 'transport') device.transport = value; } devices.push(device); } } } return devices; }
- src/index.ts:51-59 (schema)Tool schema definition including name, description, and empty input schema (no parameters required).{ name: 'adb_list_devices', description: 'List all connected Android devices', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:433-434 (registration)Registration in the tool call switch statement that dispatches execution to the handler.case 'adb_list_devices': return await this.handleToolCall(this.deviceTools.listDevices());