Skip to main content
Glama

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNo

Implementation Reference

  • 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
  • Registers the get_device_info function as an MCP tool using the FastMCP decorator.
    @mcp.tool()
  • 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)}"

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/rahulkr/r_adb_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server