Submit

Mcp Android Agent Python

@nim444

This project provides an **MCP (Model Context Protocol)** server for automating Android devices using [uiautomator2](https://github.com/openatx/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.
Overview

🛠️ Setup

1. Clone the repo

git clone https://github.com/nim444/mcp-android.git
cd mcp-android

2. Create and activate virtual environment

# Using uv (https://github.com/astral-sh/uv)
uv venv
source .venv/bin/activate

3. Install dependencies (from pyproject.toml)

uv pip install
uvicorn server:app --factory --host 0.0.0.0 --port 8000

Alternatively, run with MCP stdio (for AI agent integration):

python server.py

🤖 Available MCP Tools

Tool NameDescription
mcp_healthCheck if the MCP server is running properly
connect_deviceConnect to an Android device and get basic info
get_installed_appsList all installed apps with version and package info
get_current_appGet info about the app currently in the foreground
start_appStart an app by its package name
stop_appStop an app by its package name
stop_all_appsStop all currently running apps
screen_onTurn on the screen
screen_offTurn off the screen
get_device_infoGet detailed device info: serial, resolution, battery, etc.
press_keySimulate hardware key press (e.g. home, back, menu, etc.)
unlock_screenUnlock the screen (turn on and swipe if necessary)
check_adbCheck if ADB is installed and list connected devices
wait_for_screen_onWait asynchronously until the screen is turned on
clickTap on an element by text, resourceId, or description
long_clickPerform a long click on an element
send_textInput text into currently focused field (optionally clearing before)
get_element_infoGet info on UI elements (text, bounds, clickable, etc.)
swipeSwipe from one coordinate to another
wait_for_elementWait for an element to appear on screen
screenshotTake and save a screenshot from the device
scroll_toScroll until a given element becomes visible
dragDrag an element to a specific screen location
get_toastGet the last toast message shown on screen
clear_app_dataClear user data/cache of a specified app
wait_activityWait until a specific activity appears

Server Config

{
  "mcpServers": {
    "mcp-android": {
      "type": "stdio",
      "command": "bash",
      "args": [
        "-c",
        "cd <DIRECTORY> && source .venv/bin/activate && python -m server"
      ]
    }
  }
}
© 2025 MCP.so. All rights reserved.

Build with ShipAny.