home / mcp / android mcp server
MCP Android agent - This project provides an *MCP (Model Context Protocol)* server for automating Android devices using uiautomator2. It's designed to be easily plugged into AI agents like GitHub Copilot Chat, Claude, or Open Interpreter to control Android devices through natural language.
Configuration
View docs{
"mcpServers": {
"nim444-mcp-android-server-python": {
"url": "http://localhost:8080"
}
}
}You can automate and control Android devices through MCP by running a local server that exposes a rich set of tools for device management, app control, screen interactions, UI inspection, and advanced capabilities. This server is designed to be easily integrated with AI agents and MCP clients to perform tasks on real devices via natural language commands.
You run the server in either stdio mode for direct integration with MCP clients or as a streamable HTTP API for web-based or curl-based interactions. In stdio mode, you connect to the local process from your MCP client; in HTTP mode, you send HTTP requests to control the device and query status.
Prerequisites you need before installation are Python 3.13 or higher and ADB (Android Debug Bridge) installed and available in your system PATH. Ensure your Android device is connected, USB debugging is enabled, and the device supports uiautomator2.
# 1) Clone the project
git clone https://github.com/nim444/mcp-android
cd mcp-android
# 2) Create and activate a virtual environment using uv
uv venv
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
# 3) Install dependencies
uv pip installThe server supports two transport modes. Use stdio mode for AI agent integrations and HTTP mode for web or API use. The default setup runs as an HTTP server, and you can switch modes by editing the main startup configuration.
# For stdio mode (AI agents)
if __name__ == "__main__":
mcp.run(
transport="stdio",
show_banner=False,
)# For HTTP mode (Web API)
if __name__ == "__main__":
mcp.run(
transport="streamable-http",
host="0.0.0.0",
port=8080,
)To integrate with an MCP client, configure the client to launch the local server in stdio mode. The following JSON snippet demonstrates adding the Android MCP server configuration to your MCP client settings.
{
"mcpServers": {
"mcp-android": {
"type": "stdio",
"command": "bash",
"args": [
"-c",
"cd /path/to/mcp-adb && source .venv/bin/activate && uv run python server.py"
]
}
}
}If you prefer an HTTP API, start the server in HTTP mode and then interact via HTTP calls. The server will be available at the base URL you configure (default localhost:8080). Example usage is to check the server root to confirm itβs running.
# Check that the HTTP API is responding
curl http://localhost:8080/Keep your MCP host reachable only to trusted clients. When exposing the HTTP API, consider network restrictions or authentication for sensitive device automation tasks.
If you run into connection or device discovery issues, verify that ADB is installed and that the device is connected and authorized for USB debugging. Ensure the virtual environment is active before starting the server and that the correct transport mode is selected for your client.
Check if the MCP server is running properly.
Retrieve complete device status and readiness information.
Connect to an Android device and obtain basic information.
Get detailed device information such as serial, resolution, battery, and network status.
Verify ADB availability and list connected devices.
List all installed apps with version and package information.
Identify the app currently in the foreground.
Launch an app by its package name.
Terminate an app by its package name.
Stop all currently running apps.
Clear user data and cache for a specified app.
Turn the device screen on.
Turn the device screen off.
Unlock the screen, performing swipe if necessary.
Asynchronously wait for the screen to turn on.
Simulate hardware key presses like home, back, and menu.
Tap on UI elements by text, resourceId, or description.
Perform a long press on a UI element.
Enter text into the currently focused field, with optional clearing.
Swipe from one coordinate to another.
Drag an element to a target location.
Obtain detailed information about UI elements.
Wait for a specific element to appear.
Scroll to bring a target element into view.
Capture a screenshot from the device.
Export the current UI hierarchy as XML.
Capture the last toast message shown on screen.
Wait for a specific Android activity to appear.