Skip to main content
Glama
mobile-next

Mobile Next MCP Server

Official
by mobile-next

mobile_get_screen_size

Retrieve the screen size of a mobile device in pixels using the Mobile Next MCP Server to ensure accurate display and interaction measurements for automation tasks on iOS and Android.

Instructions

Get the screen size of the mobile device in pixels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
noParamsYes

Implementation Reference

  • src/server.ts:319-330 (registration)
    Registers the mobile_get_screen_size tool with MCP server, defines input schema (device string) and inline handler that delegates to Robot.getScreenSize()
    tool( "mobile_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(): Retrieves screen dimensions using ADB 'wm size' command, hardcodes scale to 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 }; }
  • IosRobot.getScreenSize(): Delegates to WebDriverAgent.getScreenSize()
    public async getScreenSize(): Promise<ScreenSize> { const wda = await this.wda(); return await wda.getScreenSize(); }
  • Simctl.getScreenSize(): Delegates to WebDriverAgent.getScreenSize()
    public async getScreenSize(): Promise<ScreenSize> { const wda = await this.wda(); return wda.getScreenSize(); }
  • WebDriverAgent.getScreenSize(): Fetches screen size from WDA /wda/screen endpoint via HTTP, handles session management.
    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, }; }); } }
  • getRobotFromDevice(): Factory function that returns the appropriate Robot instance (AndroidRobot, IosRobot, or Simctl) based on device ID.
    const getRobotFromDevice = (device: string): Robot => { const iosManager = new IosManager(); const androidManager = new AndroidDeviceManager(); const simulators = simulatorManager.listBootedSimulators(); const androidDevices = androidManager.getConnectedDevices(); const iosDevices = iosManager.listDevices(); // Check if it's a simulator const simulator = simulators.find(s => s.name === device); if (simulator) { return simulatorManager.getSimulator(device); } // Check if it's an Android device const androidDevice = androidDevices.find(d => d.deviceId === device); if (androidDevice) { return new AndroidRobot(device); } // Check if it's an iOS device const iosDevice = iosDevices.find(d => d.deviceId === device); if (iosDevice) { return new IosRobot(device); } throw new ActionableError(`Device "${device}" not found. Use the mobile_list_available_devices tool to see available devices.`); };

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