Android MCP Server について
Android MCP Server は、ADB(Android Debug Bridge)を通じて Android デバイスをプログラムから操作する MCP サーバーです。Claude Desktop や Cursor などの MCP クライアントからテスト用デバイスを扱いたい開発者向けです。接続されているデバイスが1台の場合は設定ファイルなしで自動選択されます。
主な機能
- 01ADB コマンドの実行
- 02デバイス画面のスクリーンショット取得
- 03UI レイアウトのクリック可能な要素の解析
- 04インストール済みパッケージの一覧取得
- 05Activity Resolver からのアクション情報の取得
活用シーン
- 01AI アシスタントによるテストデバイスの UI 構造の確認
- 02デバッグ中のデバイス画面の取得
- 03デバイス上のアプリのパッケージ名の一覧化
MCP 対応
本プロジェクトは MCP サーバーであり、get_packages、execute_adb_command、get_uilayout、get_screenshot、get_package_action_intents をツールとして MCP クライアントに公開します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Android MCP サーバー
ADB(Android Debug Bridge)を通じて Android デバイスをプログラムから制御するための MCP(Model Context Protocol)サーバーです。このサーバーは、Claude デスクトップやコードエディター(例:Cursor)などの MCP クライアントから利用できる、さまざまな Android デバイス管理機能を提供します。
機能
- 🔧 ADB コマンドの実行
- 📸 デバイスのスクリーンショット撮影
- 🎯 UI レイアウト分析
- 📱 デバイスのパッケージ管理
前提条件
- Python 3.x
- ADB(Android Debug Bridge)がインストールされ、設定されていること
- Android デバイスまたはエミュレーター(未テスト)
インストール
- リポジトリをクローンします。
git clone https://github.com/minhalvp/android-mcp-server.git
cd android-mcp-server
uv python install 3.11
uv sync
設定
このサーバーは、複数の利用シナリオに対応した柔軟なデバイス設定をサポートしています。
デバイス選択モード
1. 自動選択(単一デバイスの場合に推奨)
- 設定ファイルは不要です
- 接続されているデバイスが1台のみの場合、そのデバイスに自動的に接続します
- 単一のテストデバイスを使った開発に最適です
2. 手動デバイス選択
- 複数のデバイスを接続している場合に使用します
- 設定ファイルで特定のデバイスを指定します
設定ファイル(任意)
設定ファイル(config.yaml)は任意です。ファイルがない場合、接続されているデバイスが1台のみであれば、サーバーが自動的にデバイスを選択します。
自動選択の場合
デバイスを1台だけ接続してサーバーを実行するだけで、設定は不要です!
手動選択の場合
- 設定ファイルを作成します。
cp config.yaml.example config.yaml
config.yamlを編集し、デバイスを指定します。
device:
name: "your-device-serial-here" # Device identifier from 'adb devices'
自動選択の場合は、次のいずれかの方法を使用できます。
device:
name: null # Explicit null (recommended)
# name: "" # Empty string
# name: # Or leave empty/comment out
デバイスのシリアル番号の確認
デバイス識別子を確認するには、次を実行します。
adb devices
出力例:
List of devices attached
13b22d7f device
emulator-5554 device
最初の列の値(例:13b22d7fまたはemulator-5554)をデバイス名として使用します。
利用シナリオ
| シナリオ | 必要な設定 | 動作 |
|---|---|---|
| デバイスが1台接続されている | なし | ✅ デバイスに自動接続します |
| 複数のデバイスがあり、特定のデバイスを使用する | device.nameを含むconfig.yaml | ✅ 指定したデバイスに接続します |
| 複数のデバイスがあり、設定ファイルがない | なし | ❌ 利用可能なデバイスを示すエラーが表示されます |
| デバイスが接続されていない | 該当なし | ❌ 「デバイスなし」エラーが表示されます |
注:複数のデバイスが接続されていて、使用するデバイスを指定しない場合、サーバーは利用可能なデバイスをすべて列挙したエラーメッセージを表示します。
使用方法
このサーバーを使用するには MCP クライアントが必要です。Claude デスクトップアプリは MCP クライアントの一例です。Claude デスクトップでこのサーバーを使用するには:
-
Claude デスクトップの設定ファイルを探します。
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
-
mcpServersセクションに Android MCP サーバーの設定を追加します。
{
"mcpServers": {
"android": {
"command": "path/to/uv",
"args": ["--directory", "path/to/android-mcp-server", "run", "server.py"]
}
}
}
次の内容を置き換えます。
path/to/uvを、uv実行ファイルの実際のパスに置き換えますpath/to/android-mcp-serverを、このリポジトリをクローンした場所の絶対パスに置き換えます
https://github.com/user-attachments/assets/c45bbc17-f698-43e7-85b4-f1b39b8326a8
利用可能なツール
このサーバーは次のツールを提供します。
def get_packages() -> str:
"""
Get all installed packages on the device.
Returns:
str: A list of all installed packages on the device as a string
"""
def execute_adb_command(command: str) -> str:
"""
Executes an ADB command and returns the output.
Args:
command (str): The ADB command to execute
Returns:
str: The output of the ADB command
"""
def get_uilayout() -> str:
"""
Retrieves information about clickable elements in the current UI.
Returns a formatted string containing details about each clickable element,
including their text, content description, bounds, and center coordinates.
Returns:
str: A formatted list of clickable elements with their properties
"""
def get_screenshot() -> Image:
"""
Takes a screenshot of the device and returns it.
Returns:
Image: the screenshot
"""
def get_package_action_intents(package_name: str) -> list[str]:
"""
Get all non-data actions from Activity Resolver Table for a package
Args:
package_name (str): The name of the package to get actions for
Returns:
list[str]: A list of all non-data actions from the Activity Resolver
Table for the package
"""
コントリビューション
コントリビューションを歓迎します!
謝辞
- Model Context Protocol (MCP)を使用して構築
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。