list_devices
Discover connected Android devices and emulators to enable debugging, automation, and control through the Android MCP server.
Instructions
List connected Android devices and emulators
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:46-68 (handler)Tool registration and handler for "list_devices" in index.ts.
server.tool("list_devices", "List connected Android devices and emulators", {}, async () => { const devices = await adb.getDevices(); if (devices.length === 0) { return { content: [ { type: "text", text: "No devices connected. Use list_avds to see available emulators, then start_emulator to launch one.", }, ], }; } return { content: [ { type: "text", text: devices .map((d) => `${d.id} [${d.state}]${d.model ? ` model:${d.model}` : ""}`) .join("\n"), }, ], }; }); - src/adb.ts:183-193 (helper)The helper method getDevices that implements the logic of listing connected Android devices by calling `adb devices -l`.
async getDevices(): Promise<Array<{ id: string; state: string; model?: string }>> { const output = await this.exec(["devices", "-l"]); const lines = output.split("\n").filter((l) => l.trim() && !l.startsWith("List of")); return lines.map((line) => { const parts = line.trim().split(/\s+/); const id = parts[0]; const state = parts[1]; const modelMatch = line.match(/model:(\S+)/); return { id, state, model: modelMatch?.[1] }; }).filter((d) => d.id && d.state); }