Skip to main content
Glama

mobile_set_orientation

Change mobile device screen orientation between portrait and landscape modes for automated testing or accessibility adjustments.

Instructions

Change the screen orientation of the device

Input Schema

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

Implementation Reference

  • Handler function for the mobile_set_orientation tool. Ensures a device is selected via requireRobot() and delegates to the Robot instance's setOrientation method.
    async ({ orientation }) => { requireRobot(); await robot!.setOrientation(orientation); return `Changed device orientation to ${orientation}`; }
  • Zod input schema for the tool, defining 'orientation' as enum ['portrait', 'landscape'].
    orientation: z.enum(["portrait", "landscape"]).describe("The desired orientation"),
  • src/server.ts:451-462 (registration)
    Registration of the mobile_set_orientation tool on the MCP server using the 'tool' helper.
    tool( "mobile_set_orientation", "Change the screen orientation of the device", { orientation: z.enum(["portrait", "landscape"]).describe("The desired orientation"), }, async ({ orientation }) => { requireRobot(); await robot!.setOrientation(orientation); return `Changed device orientation to ${orientation}`; } );
  • Android-specific helper: AndroidRobot.setOrientation sets accelerometer_rotation to 0 and user_rotation to 0 (portrait) or 1 (landscape) via adb.
    public async setOrientation(orientation: Orientation): Promise<void> { const orientationValue = orientation === "portrait" ? 0 : 1; // disable auto-rotation prior to setting the orientation this.adb("shell", "settings", "put", "system", "accelerometer_rotation", "0"); this.adb("shell", "content", "insert", "--uri", "content://settings/system", "--bind", "name:s:user_rotation", "--bind", `value:i:${orientationValue}`); }
  • iOS-specific helper: WebDriverAgent.setOrientation sends POST to /orientation endpoint with orientation in uppercase within a session.
    public async setOrientation(orientation: Orientation): Promise<void> { await this.withinSession(async sessionUrl => { const url = `${sessionUrl}/orientation`; await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ orientation: orientation.toUpperCase() }) }); }); }

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/EmpathySlainLovers/MCP'

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