Skip to main content
Glama
rahulkr
by rahulkr

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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets' data, implying a read-only operation, but doesn't specify if it requires device access, returns structured data, has rate limits, or handles errors. This leaves significant gaps in understanding how the tool behaves beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded with the core purpose in the first clause. The additional context about responsive design adds value without unnecessary elaboration. However, it could be slightly more structured by explicitly mentioning the parameter or output format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a tool that retrieves screen specifications, with no annotations, no output schema, and low parameter coverage, the description is incomplete. It lacks details on return values, error handling, dependencies, or how it integrates with other tools, making it insufficient for an agent to use effectively without additional context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, with one parameter ('device_serial') undocumented in the schema. The description adds no information about parameters, such as what 'device_serial' refers to, when it's required, or its format. This fails to compensate for the low schema coverage, leaving the parameter's meaning unclear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('detailed screen specifications'), and mentions a use case ('useful for responsive design'). However, it doesn't explicitly differentiate from sibling tools like 'get_device_info' or 'screenshot', which might also provide screen-related data, leaving room for ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'useful for responsive design' as a general context, but doesn't specify scenarios, prerequisites, or exclusions compared to other screen-related tools in the sibling list, such as 'get_device_info' or 'change_screen_size'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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