get_device_info
Retrieve comprehensive Android device details including model, OS version, and hardware specifications for development, testing, and debugging workflows.
Instructions
Get comprehensive device information
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": "get_device_info"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_serial | No |
Implementation Reference
- src/adb_mcp_server/server.py:63-97 (handler)Handler function for 'get_device_info' tool. Fetches device properties (model, manufacturer, Android version, screen info, battery status) using ADB shell getprop, wm, and dumpsys battery commands. Returns a dictionary with the information.
@mcp.tool() def get_device_info(device_serial: str | None = None) -> dict: """Get comprehensive device information""" props = [ ("model", "ro.product.model"), ("manufacturer", "ro.product.manufacturer"), ("device", "ro.product.device"), ("android_version", "ro.build.version.release"), ("sdk_version", "ro.build.version.sdk"), ("build_id", "ro.build.id"), ("hardware", "ro.hardware"), ("serial", "ro.serialno"), ("locale", "persist.sys.locale"), ("timezone", "persist.sys.timezone"), ] info = {} for name, prop in props: info[name] = run_adb(["shell", "getprop", prop], device_serial).strip() # Add screen info info["screen_size"] = run_adb(["shell", "wm", "size"], device_serial).strip() info["screen_density"] = run_adb(["shell", "wm", "density"], device_serial).strip() # Battery info battery = run_adb(["shell", "dumpsys", "battery"], device_serial) for line in battery.split('\n'): if 'level:' in line: info["battery_level"] = line.split(':')[1].strip() + "%" if 'status:' in line: status_map = {'2': 'Charging', '3': 'Discharging', '4': 'Not charging', '5': 'Full'} status = line.split(':')[1].strip() info["battery_status"] = status_map.get(status, status) return info - src/adb_mcp_server/server.py:63-63 (registration)Registers the get_device_info function as an MCP tool using the FastMCP decorator.
@mcp.tool() - src/adb_mcp_server/server.py:24-40 (helper)Utility function used by get_device_info to execute ADB commands and handle output/errors.
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)}"