home / mcp / android mcp server

Android MCP Server

A Python-based MCP server that controls Android devices via uiautomator2, enabling device interaction, UI inspection, and app automation.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "itest4u-android-mcp": {
      "command": "d:\\src\\android-mcp\\venv\\Scripts\\python.exe",
      "args": [
        "d:\\src\\android-mcp\\main.py"
      ]
    }
  }
}

You can manage Android devices programmatically through a Model Context Protocol (MCP) server that leverages uiautomator2. This server lets you connect to devices, inspect and interact with the user interface, automate actions, and run apps or shell commands, all via MCP clients. It is especially useful for scripted testing, automated device control, and UI exploration on Android devices.

How to use

To work with an MCP client, you’ll start the local MCP server and then issue commands through the client that map to the server’s available functions. You can connect to a device, query its status, inspect the UI hierarchy, perform taps and gestures, input text, launch or stop apps, install or uninstall APKs, and capture screenshots. Use a client’s high-level actions to automate end-to-end flows on connected Android devices.

How to install

Prerequisites include Python 3.10+ and ADB installed and available on your PATH. You also need an Android device connected via USB or WiFi with ADB debugging enabled.

Step 1: Create and activate a virtual environment.

python -m venv venv
.\venv\Scripts\activate

Step 2: Install the required Python dependencies.

pip install -r requirements.txt

Step 3: Run the MCP server.

python main.py

Additional setup notes

Ensure your device is visible via adb devices before attempting a connection.

Available tools

connect_device

Connect to a device using its serial number or identifier.

device_info

Retrieve current device status, including connection state and basic specs.

dump_hierarchy

Dump the current UI hierarchy to XML for inspection.

click_element

Tap a UI element identified by text, resource_id, or description.

wait_for_element

Wait for a specific UI element to appear within a timeout period.

click_point

Tap on screen coordinates (x, y).

swipe

Perform a swipe gesture from a start point to an end point.

input_text

Type text into a focused input field, with an option to clear first.

press_key

Simulate pressing a physical key such as home or back.

open_app

Launch an application by its package name.

stop_app

Terminate a running application by its package name.

install_app

Install an APK from a URL or local path.

uninstall_app

Uninstall an application by its package name.

shell_command

Execute an ADB shell command on the connected device.

take_screenshot

Capture and retrieve the current device screen image.