Skip to main content
Glama
mobile-next

Mobile Next MCP Server

Official
by mobile-next

Get Screen Size

mobile_get_screen_size
Read-only

Retrieve mobile device screen dimensions in pixels to enable accurate UI automation and coordinate-based interactions for mobile testing.

Instructions

Get the screen size of the mobile device in pixels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceYesThe device identifier to use. Use mobile_list_available_devices to find which devices are available to you.

Implementation Reference

  • src/server.ts:326-338 (registration)
    Registers the MCP tool 'mobile_get_screen_size' including input schema, description, and thin handler that delegates to the appropriate Robot instance's getScreenSize() method.
    tool(
    	"mobile_get_screen_size",
    	"Get Screen Size",
    	"Get the screen size of the mobile device in pixels",
    	{
    		device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.")
    	},
    	async ({ device }) => {
    		const robot = getRobotFromDevice(device);
    		const screenSize = await robot.getScreenSize();
    		return `Screen size is ${screenSize.width}x${screenSize.height} pixels`;
    	}
    );
  • AndroidRobot.getScreenSize(): Parses output from ADB 'wm size' command to get physical screen dimensions in pixels (scale=1).
    public async getScreenSize(): Promise<ScreenSize> {
    	const screenSize = this.adb("shell", "wm", "size")
    		.toString()
    		.split(" ")
    		.pop();
    
    	if (!screenSize) {
    		throw new Error("Failed to get screen size");
    	}
    
    	const scale = 1;
    	const [width, height] = screenSize.split("x").map(Number);
    	return { width, height, scale };
    }
  • MobileDevice.getScreenSize(): Queries screen size via mobilecli 'device info' command for iOS simulators.
    public async getScreenSize(): Promise<ScreenSize> {
    	const response = JSON.parse(this.runCommand(["device", "info"])) as DeviceInfoResponse;
    	if (response.data.device.screenSize) {
    		return response.data.device.screenSize;
    	}
    	return { width: 0, height: 0, scale: 1.0 };
    }
  • WebDriverAgent.getScreenSize(): Fetches screen size from iOS device's WebDriverAgent server via /wda/screen endpoint (used by IosRobot).
    public async getScreenSize(sessionUrl?: string): Promise<ScreenSize> {
    	if (sessionUrl) {
    		const url = `${sessionUrl}/wda/screen`;
    		const response = await fetch(url);
    		const json = await response.json();
    		return {
    			width: json.value.screenSize.width,
    			height: json.value.screenSize.height,
    			scale: json.value.scale || 1,
    		};
    	} else {
    		return this.withinSession(async sessionUrlInner => {
    			const url = `${sessionUrlInner}/wda/screen`;
    			const response = await fetch(url);
    			const json = await response.json();
    			return {
    				width: json.value.screenSize.width,
    				height: json.value.screenSize.height,
    				scale: json.value.scale || 1,
    			};
    		});
    	}
  • Type definition for ScreenSize returned by all Robot.getScreenSize() implementations.
    export interface ScreenSize extends Dimensions {
    	scale: number;
    }
Behavior3/5

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

The annotations declare readOnlyHint=true, indicating a safe read operation, which the description does not contradict. The description adds context by specifying that it retrieves screen size 'in pixels', which is useful behavioral detail not covered by annotations. However, it lacks information on potential errors, return format, or other behavioral traits like rate limits.

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?

The description is a single, clear sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and efficient, with every part contributing essential information, making it highly concise and well-structured.

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?

Given the tool's low complexity (one parameter, read-only operation) and the presence of annotations (readOnlyHint) and high schema coverage, the description is mostly complete. However, without an output schema, it does not explain return values (e.g., format of screen size data), leaving a minor gap in contextual information.

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?

The input schema has 100% description coverage, with the 'device' parameter fully documented in the schema. The description does not add any parameter-specific details beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the description does not compensate but also does not detract.

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?

The description clearly states the specific action ('Get') and resource ('screen size of the mobile device in pixels'), distinguishing it from siblings like mobile_get_orientation (which gets orientation) or mobile_list_available_devices (which lists devices). It precisely defines what the tool does without being vague or tautological.

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

Usage Guidelines4/5

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

The description implies usage for retrieving screen size information, but it does not explicitly state when to use this tool versus alternatives. However, the input schema's description for the 'device' parameter provides guidance by referencing mobile_list_available_devices to find available devices, offering some contextual usage help without full alternatives or exclusions.

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/mobile-next/mobile-mcp'

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