mobile_get_orientation
Retrieve the current screen orientation of a mobile device for automation testing or UI adaptation, using the device identifier from available options.
Instructions
Get the current screen orientation of the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | The device identifier to use. Use mobile_list_available_devices to find which devices are available to you. |
Implementation Reference
- src/server.ts:464-475 (registration)Registration of the 'mobile_get_orientation' MCP tool. The inline handler requires an active device/robot and delegates to its getOrientation() method, formatting the result as a string.tool( "mobile_get_orientation", "Get the current screen orientation of the device", { noParams }, async () => { requireRobot(); const orientation = await robot!.getOrientation(); return `Current device orientation is ${orientation}`; } );
- src/android.ts:316-319 (helper)AndroidRobot implementation of getOrientation(): queries device settings via adb for user_rotation (0=portrait, else landscape).public async getOrientation(): Promise<Orientation> { const rotation = this.adb("shell", "settings", "get", "system", "user_rotation").toString().trim(); return rotation === "0" ? "portrait" : "landscape"; }
- src/webdriver-agent.ts:385-392 (helper)WebDriverAgent implementation of getOrientation() used by iOS devices and simulators: performs HTTP GET to /orientation endpoint within a WDA session and lowercases the result.public async getOrientation(): Promise<Orientation> { return this.withinSession(async sessionUrl => { const url = `${sessionUrl}/orientation`; const response = await fetch(url); const json = await response.json(); return json.value.toLowerCase() as Orientation; }); }