list_devices
Retrieve details of all connected Android devices for development, testing, and debugging workflows.
Instructions
List all connected Android devices with details
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_devices"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/adb_mcp_server/server.py:57-61 (handler)The handler function for the 'list_devices' tool. It is decorated with @mcp.tool() which registers it with the FastMCP server. The function executes `adb devices -l` via the run_adb helper to list connected Android devices with details.
@mcp.tool() def list_devices() -> str: """List all connected Android devices with details""" return run_adb(["devices", "-l"]) - src/adb_mcp_server/server.py:24-39 (helper)Helper function used by list_devices to execute ADB commands safely, handling errors, timeouts, and device selection.
def run_adb(args: list[str], device_serial: str | None = None, timeout: int = 30) -> str: """Run an ADB command and return output""" cmd = ["adb"] if device_serial: cmd.extend(["-s", device_serial]) cmd.extend(args) try: result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout) if result.returncode != 0 and result.stderr: return f"Error: {result.stderr}" return result.stdout except subprocess.TimeoutExpired: return "Error: Command timed out" except Exception as e: return f"Error: {str(e)}"