Skip to main content
Glama

get_screen_specs

Retrieve detailed screen specifications for Android devices to support responsive design and UI testing workflows.

Instructions

Get detailed screen specifications - useful for responsive design

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNo

Implementation Reference

  • Main handler function for the 'get_screen_specs' tool. Uses ADB to fetch screen size and density, parses outputs, calculates DP equivalents, aspect ratio, and density classification. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool() def get_screen_specs(device_serial: str | None = None) -> dict: """Get detailed screen specifications - useful for responsive design""" size_output = run_adb(["shell", "wm", "size"], device_serial) density_output = run_adb(["shell", "wm", "density"], device_serial) # Parse physical size size_match = re.search(r'Physical size: (\d+)x(\d+)', size_output) override_match = re.search(r'Override size: (\d+)x(\d+)', size_output) width, height = 0, 0 if override_match: width, height = int(override_match.group(1)), int(override_match.group(2)) elif size_match: width, height = int(size_match.group(1)), int(size_match.group(2)) # Parse density density = 0 density_match = re.search(r'Physical density: (\d+)', density_output) if density_match: density = int(density_match.group(1)) # Calculate useful metrics dp_width = (width / density) * 160 if density else 0 dp_height = (height / density) * 160 if density else 0 return { "width_px": width, "height_px": height, "density_dpi": density, "width_dp": round(dp_width, 1), "height_dp": round(dp_height, 1), "aspect_ratio": f"{width}:{height}", "density_bucket": get_density_bucket(density) }
  • Supporting helper function called by get_screen_specs to classify screen density into standard Android buckets (ldpi, mdpi, hdpi, etc.).
    def get_density_bucket(dpi: int) -> str: """Map DPI to Android density bucket""" if dpi <= 120: return "ldpi" if dpi <= 160: return "mdpi" if dpi <= 240: return "hdpi" if dpi <= 320: return "xhdpi" if dpi <= 480: return "xxhdpi" return "xxxhdpi"
  • The @mcp.tool() decorator registers the get_screen_specs function as an MCP tool with the name matching the function name.
    @mcp.tool()

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