Skip to main content
Glama
Android MCP

Android MCP

by Steph-ux

Android MCP

あらゆるAIエージェントからAndroidを完全に制御 — Claude、OpenCode、Windsurf、Cursorなど 7つのカテゴリ別MCPツール · 90fpsライブビューア · WiFi ADB · インストール不要


クイックデモ

android_screen(action="screenshot")                          # PNG capture
android_screen(action="ocr")                                 # visible text
android_interact(action="tap", params={"x": 540, "y": 960}) # tap
android_interact(action="find", params={"text": "Send"})     # find + tap
android_system(action="battery")                             # battery info
android_screen(action="viewer")                              # 90fps interactive window on PC

Related MCP server: phone-eye

アーキテクチャ

AI Agent (Claude / OpenCode / Windsurf / Cursor…)
        ↓  MCP Protocol (stdio)
    server.py          ← 7 categorical tools
        ↓
    device_manager.py  ← device selection, multi-device
        ↓
    backends/
        ├── adb_backend.py       ← PRIMARY  : uiautomator2 + direct ADB
        └── companion_backend.py ← FALLBACK : Flutter app WebSocket
        ↓
    N Android phones / emulators

ADBバックエンド(メイン) — 開発者モードが有効なあらゆるデバイスで動作します。 スマホへのインストールは不要です。uiautomator2 + ADBコマンドを使用します。

コンパニオンバックエンド(フォールバック) — ネットワーク上でADBが利用できない場合のオプションのFlutterアプリです。


要件

  • Python 3.10+

  • ADB (PATHに追加済みであること: winget install Google.PlatformTools)

  • Android: 開発者モード + USBデバッグ(またはWiFiデバッグ)


インストール

git clone https://github.com/Steph-ux/android-mcp
cd android-mcp
pip install -r requirements.txt

# Initialize uiautomator2 (once per device)
python -m uiautomator2 init

ライブビューア 90fps (オプション)

winget install Genymobile.scrcpy
python viewer.py

MCP設定

# Generate the correct JSON for your AI client
python mcp_config.py --client claude     # Claude Desktop
python mcp_config.py --client opencode  # OpenCode
python mcp_config.py --client windsurf  # Windsurf
python mcp_config.py --client cursor    # Cursor
python mcp_config.py --write            # write directly to config files

Claude Desktopの例 (claude_desktop_config.json):

{
  "mcpServers": {
    "android-mcp": {
      "command": "C:/Python312/python.exe",
      "args": ["D:/path/to/android-mcp/server.py"],
      "type": "stdio"
    }
  }
}

USBなしのWiFi接続 (Android 11以降)

# On the phone: Settings → Developer options → Wireless debugging → Pair device
adb pair 192.168.1.42:38765    # enter the code shown on the phone
adb connect 192.168.1.42:5555

完全ガイド → WIFI_PAIRING.md


7つのMCPツール

呼び出し規約: android_xxx(action="...", params={...}, device_id="serial") device_id は常にオプションです(現在選択されているデバイスを使用します)。


android_device — デバイス管理

アクション

パラメータ

説明

list

—

接続されているすべてのデバイス (USB, WiFi, エミュレータ)

select

serial

デフォルトデバイスの設定

connect

host, port

WiFi ADB接続

disconnect

—

現在のWiFiデバイスを切断

info

—

モデル、OS、解像度、密度

status

—

デバイスが接続され準備完了か?

setup

—

アニメーション、スリープ無効化、ATXエージェントの設定


android_screen — キャプチャ & ストリーム

アクション

パラメータ

説明

screenshot

—

PNGキャプチャ (FLAG_SECUREをバイパス) → 画像

region

x y width height

特定領域のキャプチャ → 画像

size

—

{width, height}

is_on

—

画面がオンか?

wake

—

画面をスリープ解除

start_stream

—

ADBストリーム開始 (~16fps)

stop_stream

—

ストリーム停止

live_frame

—

最新のストリームフレーム → 画像

ocr

lang

表示テキストの抽出 (Tesseract)

find_image

template_b64 threshold

テンプレートマッチング (OpenCV)

viewer

fps bitrate no_control

PC上でscrcpy 90fpsウィンドウを起動


android_interact — タッチ、キーボード、UI

アクション

パラメータ

説明

tap

x y

タップ

double_tap

x y

ダブルタップ

long_press

x y duration_ms

長押し

swipe

x1 y1 x2 y2 duration_ms

スワイプ

drag

x1 y1 x2 y2 duration_ms

ドラッグ&ドロップ

pinch

x y scale duration_ms

ピンチズーム

multi_touch

points

マルチフィンガージェスチャー

type

text

テキスト入力

clear

—

アクティブフィールドのクリア

submit

text

入力 + Enter

key

key

システムキー (HOME, BACK, ENTER, VOLUME_UP…)

combo

keys

キーの組み合わせ (キーコード)

hierarchy

—

完全なUI XMLツリー (uiautomator2)

find

text partial_match

要素を見つけてタップ

wait

text timeout partial_match

要素を待機

scroll

text direction max_swipes

要素までスクロール

assert

text partial_match

テキストが表示されているか確認


android_app — アプリケーション

アクション

パラメータ

説明

launch

package

アプリの起動

close

package

アプリの強制終了

list

include_system

インストール済みアプリの一覧

install

apk_path

PCからAPKをインストール

uninstall

package

アプリのアンインストール

current

—

フォアグラウンドアプリのパッケージ名

url

url

URLを開く

intent

action uri package extras

Androidインテントの送信

settings

section

システム設定を開く (main wifi bluetooth display…)


android_files — ファイル

アクション

パラメータ

説明

push

local_path remote_path

PC → スマホ

push_b64

remote_path data

Base64 → スマホ

pull

remote_path local_path

スマホ → PC

pull_b64

remote_path

スマホ → base64

list

directory

ディレクトリ内容の一覧


android_system — システム & ネットワーク

アクション

パラメータ

説明

shell

command

ADBシェルコマンド

logs

lines package

Logcat

battery

—

バッテリー残量と充電状態

clipboard_get

—

クリップボードの読み取り

clipboard_set

text

クリップボードへの書き込み

volume

level stream

音量設定

rotation

rotation

画面回転 (0-3)

wifi

enabled

WiFiのオン/オフ

bluetooth

enabled

Bluetoothのオン/オフ

mobile_data

enabled

モバイルデータのオン/オフ

notifications

—

アクティブな通知

gps

lat lng

GPS位置情報の偽装

sensors

sensor

加速度、ジャイロ、照度など

wifi_list

—

利用可能なWiFiネットワーク

wifi_connect

ssid password

WiFiに接続

contacts

search limit

連絡先の読み取り

sms

to message

SMS送信 (スマホ側での確認が必要)


android_automation — バッチ & マクロ

アクション

パラメータ

説明

batch

actions stop_on_error

1回の呼び出しでN個のアクションを実行

macro_start

name

マクロの記録開始

macro_record

action …params

マクロにアクションを追加

macro_stop

—

マクロの保存

macro_list

—

保存済みマクロの一覧

macro_replay

name delay_ms

マクロの再生

macro_delete

name

マクロの削除


ライブビューア — scrcpy 90fps

python viewer.py                  # auto-detect device, 90fps, interactive
python viewer.py --fps 60         # 60fps
python viewer.py --record         # record to .mp4
python viewer.py --record out.mp4 # named output file
python viewer.py --multi          # one viewer per connected device
python viewer.py --no-control     # read-only mode

操作

アクション

左クリック

タップ

ドラッグ

スワイプ

右クリック

BACK

スクロール

スクロール

Alt+H

HOME

Alt+S

スクリーンショット → PCクリップボード

Alt+F

フルスクリーン

Alt+R

回転


テスト

# Unit tests (no device required)
pytest tests/test_server_unit.py -v      # 94 tests

# Integration tests (ADB device required)
pytest tests/test_integration.py -v

プロジェクト構造

android-mcp/
├── server.py              # MCP server — 7 tools
├── viewer.py              # scrcpy 90fps interactive viewer
├── mcp_config.py          # JSON config generator
├── device_manager.py      # Multi-device management
├── relay.py               # ⚠️ LEGACY — companion fallback only
├── requirements.txt
├── pyproject.toml
├── WIFI_PAIRING.md
├── backends/
│   ├── adb_backend.py     # Primary backend (uiautomator2 + ADB)
│   └── companion_backend.py  # Fallback backend (Flutter app)
├── examples/
│   ├── agent_loop.py      # Autonomous automation loop
│   └── whatsapp_auto.py   # WhatsApp automation example
└── tests/
    ├── conftest.py
    ├── test_server_unit.py   # 94 unit tests
    └── test_integration.py   # Real device tests

例

# WhatsApp — send a message
await android_app("launch", {"package": "com.whatsapp"})
await android_interact("find", {"text": "Alice"})
await android_interact("type", {"text": "Hello!"})
await android_interact("key",  {"key": "ENTER"})

# Batch in a single call
await android_automation("batch", {"actions": [
    {"action": "key",  "key": "HOME"},
    {"action": "tap",  "x": 540, "y": 200},
    {"action": "type", "text": "search query"},
    {"action": "key",  "key": "ENTER"},
]})

# Macro: record + replay
await android_automation("macro_start",  {"name": "login"})
await android_automation("macro_record", {"action": "tap",  "x": 540, "y": 400})
await android_automation("macro_record", {"action": "type", "text": "password"})
await android_automation("macro_stop")
await android_automation("macro_replay", {"name": "login"})

完全な使用例については examples/whatsapp_auto.py および examples/agent_loop.py を参照してください。


ライセンス

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to remotely control a real Android phone over MCP with no ADB, root, or emulator, by connecting a broker server to a sideloaded APK. Exposes tools to list devices, capture screenshots, read the UI tree, open links and deep links, and perform taps, swipes, typing, and global navigation actions.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP-compatible AI agents to perceive and control an Android phone through tools for screenshots, visible text and coordinates, app/screen queries, taps, swipes, text input, key events, app launching, and interrupt/resume, closing the perception-action loop.
      6
      MIT