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
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | The device identifier to use. Use mobile_list_available_devices to find which devices are available to you. | |
| orientation | Yes | The desired orientation |
Implementation Reference
- src/server.ts:457-461 (handler)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}`; }
- src/server.ts:455-455 (schema)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}`; } );
- src/android.ts:308-314 (helper)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}`); }
- src/webdriver-agent.ts:372-383 (helper)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() }) }); }); }