Skip to main content
Glama

get_screen_size

Retrieve the screen resolution in pixels from a connected Android device to determine display dimensions for UI automation and testing.

Instructions

Get the screen resolution (width x height in pixels) of the connected Android device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNoDevice serial number. If omitted, uses the only connected device.

Implementation Reference

  • The actual implementation of getScreenSize, which queries the device using 'wm size'.
    async getScreenSize(deviceId?: string): Promise<{ width: number; height: number }> {
      const resolvedId = await this.resolveDeviceId(deviceId);
    
      // Check cached session first
      const session = this.sessions.get(resolvedId);
      if (session && session.screenWidth > 0 && session.screenHeight > 0) {
        return { width: session.screenWidth, height: session.screenHeight };
      }
    
      const result = await adbShell(['wm', 'size'], resolvedId);
      const match = result.stdout.match(/(\d+)x(\d+)/);
    
      if (!match) {
        throw new Error(`Failed to parse screen size from: ${result.stdout}`);
      }
    
      const width = parseInt(match[1], 10);
  • Registration of the 'get_screen_size' MCP tool, including schema and tool handler.
    server.registerTool(
      'get_screen_size',
      {
        description: 'Get the screen resolution (width x height in pixels) of the connected Android device',
        inputSchema: {
          device_id: z.string().optional().describe('Device serial number. If omitted, uses the only connected device.'),
        },
      },
      async ({ device_id }) => {
        return await metrics.measure('get_screen_size', device_id || 'default', async () => {
          const size = await deviceManager.getScreenSize(device_id);
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({ success: true, screen: size }, null, 2),
            }],
          };
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It specifies the return format (width x height in pixels) and target (connected Android device), but omits error handling (no device connected, multiple devices), return schema structure, or whether this requires ADB shell permissions. Just meets minimum viable disclosure for a read-only getter.

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

Conciseness5/5

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

Single sentence with zero waste. Front-loaded with the action and resource, parenthetical clarification of format (width x height in pixels), and scope (connected Android device). Every clause earns its place.

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

Completeness4/5

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

For a simple single-purpose getter with 100% schema coverage and no output schema, the description is appropriately complete. It compensates for missing output schema by specifying the return format (width x height in pixels). Minor gap: does not specify primary vs. secondary display handling for multi-screen devices.

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

Parameters3/5

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

Input schema has 100% description coverage for the device_id parameter ('Device serial number. If omitted, uses the only connected device.'). The description adds no parameter-specific context, but per guidelines, the baseline is 3 when schema coverage is high (>80%).

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

Purpose5/5

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

Description provides specific verb ('Get'), clear resource ('screen resolution'), and precise scope ('width x height in pixels of the connected Android device'). This clearly distinguishes the tool from siblings like capture_screenshot (image), analyze_screen (content), and get_device_info (general hardware info).

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

Usage Guidelines3/5

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

While the purpose is clear enough to imply usage (whenever display dimensions are needed), the description lacks explicit guidance on when to use this versus get_device_info which may also return display metrics, or how it behaves when multiple devices are connected. No 'when-not-to-use' or alternative recommendations are provided.

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/divineDev-dotcom/android_mcp'

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