Skip to main content
Glama
rahulkr
by rahulkr

rotate_screen

Change Android device screen orientation for testing and development. Supports portrait, landscape, reverse orientations, and auto-rotation modes.

Instructions

Rotate screen orientation.
orientation: 'portrait', 'landscape', 'reverse_portrait', 'reverse_landscape', or 'auto'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orientationNoportrait
device_serialNo

Implementation Reference

  • The rotate_screen tool implementation. Decorated with @mcp.tool() for MCP registration. Handles screen rotation by setting ADB system settings for accelerometer_rotation and user_rotation based on the specified orientation.
    @mcp.tool()
    def rotate_screen(orientation: str = "portrait", device_serial: str | None = None) -> str:
        """
        Rotate screen orientation.
        orientation: 'portrait', 'landscape', 'reverse_portrait', 'reverse_landscape', or 'auto'
        """
        orientations = {
            'auto': ('0', 'user'),
            'portrait': ('1', '0'),
            'landscape': ('1', '1'),
            'reverse_portrait': ('1', '2'),
            'reverse_landscape': ('1', '3')
        }
        
        if orientation not in orientations:
            return f"Invalid orientation. Use: {list(orientations.keys())}"
        
        accel_rotation, user_rotation = orientations[orientation]
        
        if orientation == 'auto':
            run_adb(["shell", "settings", "put", "system", "accelerometer_rotation", "1"], device_serial)
        else:
            run_adb(["shell", "settings", "put", "system", "accelerometer_rotation", "0"], device_serial)
            run_adb(["shell", "settings", "put", "system", "user_rotation", user_rotation], device_serial)
        
        return f"Screen rotation set to {orientation}"

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/rahulkr/r_adb_mcp_server'

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