Logo MCP Android Agent

MCP Android Agent

Cộng đồng
nim444

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.

Nhà phát hànhnim444
Kho mãmcp-android-server-python
Ngôn ngữPython
Bản fork
12
Sao
59
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    MCP Android Agent cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    59 sao và 12 bản fork từ kho mã được liên kết.

Python 3.13 CI Pipeline Coverage: 90% Code style: ruff License: MIT

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.

Modular Architecture

The server has been refactored into a clean, modular architecture with tools organized by functionality:

mcp-android-server-python/
├── server.py                    # Main server (61 lines - clean & focused)
├── server_original_backup.py    # Backup of original monolithic version
└── tools/                       # 🆕 Modular tools package
    ├── __init__.py             # Central registration & imports
    ├── device_tools.py         # Device connection & status tools
    ├── app_tools.py            # Application management tools
    ├── screen_tools.py         # Screen control & unlock tools
    ├── input_tools.py          # User input simulation (click, swipe, text)
    ├── inspection_tools.py     # UI inspection & screenshots
    └── advanced_tools.py       # Advanced features (toast, activity wait)

Benefits of Modular Architecture

  • Maintainability: Easy to add/modify/remove tools without touching main server
  • Organization: Tools grouped logically by functionality
  • Testing: Individual tool modules can be unit tested separately
  • Reusability: Tool modules can be reused in other projects
  • Scalability: New tool categories can be added as separate modules
  • Clean Code: Main server reduced from 1321 lines to 61 lines

Quick Demo

Demo


Demo

Requirements

  • Python 3.13 or higher
  • Android Debug Bridge (adb) installed and in PATH
  • Connected Android device with USB debugging enabled
  • uiautomator2 compatible Android device

Features

Device Management

  • Smart Device Detection: Automatically finds and connects to available devices
  • Comprehensive Device Info: Get serial, resolution, battery, WiFi IP, Android version
  • ADB Diagnostics: Check ADB availability and connection status
  • Health Monitoring: Built-in server health checks

Application Management

  • App Discovery: List all installed applications (system + user apps)
  • App Lifecycle Control: Start, stop, force-stop apps by package name
  • App State Monitoring: Track current foreground app and activity
  • Data Management: Clear app data/cache for testing

Screen & Display Control

  • Screen Power Management: Turn screen on/off programmatically
  • Smart Unlock: Automatic screen unlocking with standard methods
  • Screen State Monitoring: Wait for screen activation (async support)

User Input Simulation

  • Precision Interactions: Click by text, resource ID, or content description
  • Advanced Gestures: Long click, swipe, drag operations
  • Text Input: Smart text entry with optional field clearing
  • Hardware Keys: Simulate home, back, menu, volume keys

UI Inspection & Debugging

  • Element Analysis: Get detailed UI element properties and bounds
  • Screen Capture: Take screenshots for debugging and documentation
  • UI Hierarchy: Export complete screen structure as XML
  • Smart Waiting: Wait for elements to appear with custom timeouts
  • Scroll Detection: Auto-scroll to find elements in long lists

Advanced Capabilities

  • Toast Detection: Capture system toast messages for verification
  • Activity Monitoring: Wait for specific Android activities
  • Background Operations: Async support for time-consuming operations

Use Cases

Perfect for:

  • AI agents that need to interact with real devices
  • Remote device control setups
  • Automated QA tools
  • Android bot frameworks
  • UI testing and automation
  • Device management and monitoring

Installation

1. Clone the repo

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

2. Create and activate virtual environment

bash
# Using uv (https://github.com/astral-sh/uv)
uv venv
source .venv/bin/activate  # On Windows: .venv\\Scripts\\activate

3. Install dependencies

bash
uv pip install

Running the Server

The server supports two different transport modes depending on your use case:

Option 1: MCP stdio (For AI Agent Integration)

This is the standard mode for integrating with AI agents like Claude Desktop, VS Code, or other MCP clients.

bash
# Edit server.py to use stdio mode (default commented out)
# Uncomment the stdio section and comment out http section

# Then run:
uv run python server.py

Option 2: Streamable HTTP (For Web/API Integration)

This mode runs the server as an HTTP API, useful for web applications, curl testing, or direct HTTP calls.

bash
# Current default configuration - runs as HTTP server
uv run python server.py

# Server will be available at: http://localhost:8080

Switching Between Modes

Edit server.py and modify the if __name__ == "__main__": section:

For stdio mode (AI agents):

python
if __name__ == "__main__":
    mcp.run(
        transport="stdio",
        show_banner=False,
    )

For HTTP mode (Web API):

python
if __name__ == "__main__":
    mcp.run(
        transport="streamable-http",
        host="0.0.0.0",
        port=8080,
    )

Usage

For AI Agent Integration (Claude Desktop, VS Code, etc.)

An MCP client is needed to use this server. The Claude Desktop app is an example of an MCP client.

Important: For AI agent integration, make sure to configure the server in stdio mode (see "Option 1" above).

To use this server with Claude Desktop:

Locate your Claude Desktop configuration file

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Add the Android MCP server configuration to the mcpServers section

json
{
  "mcpServers": {
    "mcp-android": {
      "type": "stdio",
      "command": "bash",
      "args": [
        "-c",
        "cd /path/to/mcp-adb && source .venv/bin/activate && uv run python server.py"
      ]
    }
  }
}

Replace /path/to/mcp-adb with the absolute path to where you cloned this repository. For example: /Users/username/Projects/mcp-adb

Using with VS Code

You can also use this MCP server with VS Code's agent mode (requires VS Code 1.99 or newer). To set up:

  1. Create a .vscode/mcp.json file in your workspace:
json
{
  "servers": {
    "mcp-android": {
      "type": "stdio",
      "command": "bash",
      "args": [
        "-c",
        "cd /path/to/mcp-adb && source .venv/bin/activate && uv run python server.py"
      ]
    }
  }
}

Replace /path/to/mcp-adb with the absolute path to where you cloned this repository.

After adding the configuration, you can manage the server using:

  • Command Palette → MCP: List Servers to view and manage configured servers
  • Command Palette → MCP: Start Server to start the server
  • The server's tools will be available in VS Code's agent mode chat

Vscode

For HTTP API Integration (Direct API Calls)

When running in HTTP mode (Option 2), you can interact with the server directly via HTTP requests:

bash
# Check if server is running
curl http://localhost:8080/

# List available tools (you'll need to implement proper tool discovery endpoints)
# This depends on your FastMCP version and configuration

Use Cases for HTTP Mode:

  • Web applications with Android automation
  • Testing tools that can't use stdio
  • Direct API integration with other services
  • Debugging and development with curl/Postman

UI Inspector

The project includes support for uiauto.dev, a powerful UI inspection tool for viewing and analyzing your device's interface structure.

  1. Install the UI inspector:
bash
uv pip install uiautodev
  1. Start the inspector:
bash
uiauto.dev
  1. Open your browser and navigate to https://uiauto.dev

Ui

Available MCP Tools

Device Management Tools

Tool NameDescription
mcp_healthCheck if the MCP server is running properly
get_device_statusGet complete device status and readiness information
connect_deviceConnect to an Android device and get basic info
get_device_infoGet detailed device info: serial, resolution, battery, etc.
check_adb_and_list_devicesCheck if ADB is installed and list connected devices

Application Management Tools

Tool NameDescription
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
clear_app_dataClear user data/cache of a specified app

Screen Control Tools

Tool NameDescription
screen_onTurn on the screen
screen_offTurn off the screen
unlock_screenUnlock the screen (turn on and swipe if necessary)
wait_for_screen_onWait asynchronously until the screen is turned on

User Input Tools

Tool NameDescription
press_keySimulate hardware key press (e.g. home, back, menu, etc.)
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)
swipeSwipe from one coordinate to another
dragDrag an element to a specific screen location

Inspection Tools

Tool NameDescription
get_element_infoGet info on UI elements (text, bounds, clickable, etc.)
wait_for_elementWait for an element to appear on screen
scroll_toScroll until a given element becomes visible
screenshotTake and save a screenshot from the device
dump_hierarchyDump the UI hierarchy of the current screen as XML

Advanced Tools

Tool NameDescription
get_toastGet the last toast message shown on screen
wait_activityWait until a specific activity appears

License

This project is licensed under the MIT License - see the LICENSE file for details.

Cài đặt

TypingMind
{
  "mcpServers": {
    "mcp-android-server-python": {
      "command": "uvicorn",
      "args": [
        "server:app",
        "--factory",
        "--host",
        "0.0.0.0",
        "--port",
        "8000"
      ]
    }
  }
}

Dùng MCP MCP Android Agent với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối MCP Android Agent, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm MCP Android Agent làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của MCP Android Agent.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "mcp-android-server-python": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của MCP Android Agent, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của MCP Android Agent.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng MCP Android Agent giúp tôi làm việc này không?
MCP Android Agent
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng MCP Android Agent.

Câu hỏi thường gặp

Máy chủ MCP MCP Android Agent dùng để làm gì?

MCP Android Agent là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP MCP Android Agent với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng MCP Android Agent với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP MCP Android Agent với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối MCP Android Agent, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP MCP Android Agent với TypingMind?

MCP Android Agent hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP MCP Android Agent cung cấp những công cụ nào trong TypingMind?

MCP Android Agent cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP MCP Android Agent không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu MCP Android Agent yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇