home / mcp / android mcp server
A Python-based MCP server that controls Android devices via uiautomator2, enabling device interaction, UI inspection, and app automation.
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.
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.
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\activateStep 2: Install the required Python dependencies.
pip install -r requirements.txtStep 3: Run the MCP server.
python main.pyEnsure your device is visible via adb devices before attempting a connection.
Connect to a device using its serial number or identifier.
Retrieve current device status, including connection state and basic specs.
Dump the current UI hierarchy to XML for inspection.
Tap a UI element identified by text, resource_id, or description.
Wait for a specific UI element to appear within a timeout period.
Tap on screen coordinates (x, y).
Perform a swipe gesture from a start point to an end point.
Type text into a focused input field, with an option to clear first.
Simulate pressing a physical key such as home or back.
Launch an application by its package name.
Terminate a running application by its package name.
Install an APK from a URL or local path.
Uninstall an application by its package name.
Execute an ADB shell command on the connected device.
Capture and retrieve the current device screen image.