mobile_get_orientation
Retrieve the current screen orientation of a mobile device to enable accurate automation and interaction with applications through the Mobile Next MCP Server.
Instructions
Get the current screen orientation of the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noParams | Yes |
Implementation Reference
- src/server.ts:576-587 (registration)Registration of the 'mobile_get_orientation' MCP tool, including input schema and inline handler function. The handler retrieves the Robot for the specified device and returns the result of robot.getOrientation().tool( "mobile_get_orientation", "Get the current screen orientation of the device", { 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 orientation = await robot.getOrientation(); return `Current device orientation is ${orientation}`; } );
- src/server.ts:582-586 (handler)Inline handler function for the mobile_get_orientation tool that executes the core logic: obtains the device-specific Robot instance and calls its getOrientation() method.async ({ device }) => { const robot = getRobotFromDevice(device); const orientation = await robot.getOrientation(); return `Current device orientation is ${orientation}`; }
- src/server.ts:579-581 (schema)Zod schema for the tool's input parameters: device identifier.{ device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.") },
- src/server.ts:153-179 (helper)getRobotFromDevice helper function used by the handler to resolve the device string to a concrete Robot implementation (AndroidRobot, IosRobot, or simulator).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.`); };