Skip to main content
Glama

ld-emulator-mcp

MCP server điều khiển máy ảo Android LDPlayer trên Windows, dùng để AI (Claude Code, Claude Desktop, VS Code…) tự động test app APK.

MCP server to drive LDPlayer Android emulator instances on Windows: launch/quit instances, screenshots returned as images, UI tree lookup, tap/swipe/type, app install from URL/file/Google Play, Google sign-in of an existing test account.

Đã chạy thử trên LDPlayer 14.0.36 (Android 14). Có hỗ trợ cả LDPlayer 9, nhưng chưa kiểm.

Tính năng

Nhóm

Tool

Máy ảo

instances_list, instance_launch, instance_quit, instance_reboot, instance_set_adb

Màn hình

screenshot (trả ảnh thẳng cho AI, có thể thu nhỏ hoặc nén JPEG)

Giao diện

ui_dump (cây giao diện rút gọn), ui_tap (chờ phần tử rồi chạm), ui_wait

Thao tác

tap, long_press, swipe, type_text, press_key, shell

App

app_install, app_list, app_launch, app_stop, app_clear_data, app_uninstall, app_current, logcat, file_push, file_pull

Google

google_accounts, google_login

Chọn máy ảo (target)

  • Số thứ tự: 0, 1…

  • Tên máy ảo: LDPlayer

  • Cổng ADB: 5555, hoặc serial: emulator-5554, 127.0.0.1:5555

  • Để trống: dùng máy ảo duy nhất đang chạy.

Quy ước của LDPlayer: máy số i có serial emulator-(5554 + 2i) và cổng ADB 5555 + 2i.

Cài app (app_install)

source nhận một trong các dạng sau (kind=auto tự đoán):

Dạng

Ví dụ

Cách cài

URL tới .apk / .xapk / .apks

https://f-droid.org/F-Droid.apk

Tải về PC rồi adb install (gói tách nhiều APK thì install-multiple, OBB được đẩy vào /sdcard/Android/obb)

Tệp trên PC

D:\build\app-debug.apk

adb install

Package ID hoặc link Google Play

com.whatsapp, https://play.google.com/store/apps/details?id=…

Mở trang app trên Google Play rồi bấm Cài đặt

Tên app

Google Calculator

Tìm trên Google Play, chọn kết quả khớp đầu tiên (có thể sai, nên chụp màn hình kiểm lại)

Cài qua Google Play cần máy ảo đã đăng nhập tài khoản Google.

Đăng nhập Google (google_login)

  • Chỉ đăng nhập tài khoản có sẵn. Không có tính năng tạo tài khoản: Google cấm tạo tài khoản tự động.

  • Mật khẩu không đi qua MCP. Server đọc mật khẩu từ tệp %USERPROFILE%\.ld-emulator-mcp\accounts.json (đổi đường dẫn bằng biến môi trường LDMCP_ACCOUNTS_FILE):

    {"tester1@gmail.com": "mat-khau-1", "tester2@gmail.com": "mat-khau-2"}
  • Khi Google đòi xác minh 2 bước, CAPTCHA, báo sai mật khẩu hoặc chặn đăng nhập, tool dừng và trả needs_attention kèm nội dung màn hình. Bạn tự làm tiếp bước đó, hoặc để AI dùng screenshot và ui_tap.

  • Nên dùng tài khoản test riêng, đã tắt xác minh 2 bước.

Related MCP server: android-emulator

Cài đặt

Yêu cầu: Windows, Python 3.10 trở lên, LDPlayer.

git clone https://github.com/anhyeuviolet/ld-emulator-mcp.git
cd ld-emulator-mcp
python -m venv .venv
.venv\Scripts\pip install -e .

Bật ADB cho máy ảo (bắt buộc)

LDPlayer mặc định tắt ADB debugging. Khi tắt, mọi tool thao tác máy ảo đều lỗi. Có hai cách bật:

  • Trong LDPlayer: Cài đặt → mục Khác → ADB debugging → Kết nối cục bộ. Sau đó khởi động lại máy ảo.

  • Qua MCP: tắt máy ảo, gọi instance_set_adb(target="0", enabled=true), rồi bật lại.

Khai báo với Claude Code

claude mcp add ld-emulator -- D:\duong-dan\ld-emulator-mcp\.venv\Scripts\python.exe -m ld_emulator_mcp

Hoặc thêm vào .mcp.json / claude_desktop_config.json:

{
  "mcpServers": {
    "ld-emulator": {
      "command": "D:\\duong-dan\\ld-emulator-mcp\\.venv\\Scripts\\python.exe",
      "args": ["-m", "ld_emulator_mcp"]
    }
  }
}

Server tự tìm LDPlayer theo thứ tự: biến môi trường LDPLAYER_PATH, registry Windows, rồi các thư mục quen thuộc. Có thể chỉ định thẳng bằng --ldplayer-path E:\LDPlayer\LDPlayer14.

Ví dụ yêu cầu cho AI

Bật máy ảo 0, cài D:\build\app-release.apk (cấp sẵn mọi quyền), mở app, chụp màn hình, rồi bấm nút "Đăng nhập".

Đăng nhập tester1@gmail.com vào máy ảo 1, sau đó cài com.example.app từ Google Play.

Đọc logcat của com.example.app, lọc dòng có "Exception".

Giới hạn đã biết

  • type_text chỉ gõ được ký tự ASCII. Muốn gõ tiếng Việt hoặc ký tự khác, cài app ADBKeyboard vào máy ảo; tool sẽ tự chuyển bàn phím khi gõ.

  • Một chuỗi %s nằm trong văn bản cần gõ sẽ bị lệnh input text của Android đổi thành dấu cách.

  • Cài theo tên trên Google Play dựa vào giao diện Play, nên có thể chọn nhầm app hoặc hỏng khi Google đổi giao diện.

  • Trên LDPlayer 14, lệnh pull / push của ldconsole không chạy được, và ảnh máy ảo không có lệnh monkey. Server dùng thẳng adb và cmd package resolve-activity thay cho hai lệnh đó.

Nhiều tài khoản, nhiều máy ảo

  • Ghi mọi tài khoản test vào cùng accounts.json. Mỗi lần gọi google_login chọn một email.

  • Mỗi máy ảo có thể đăng nhập một tài khoản khác nhau, ví dụ google_login(email="tester2@gmail.com", target=1).

  • Một máy ảo cũng có thể giữ nhiều tài khoản: gọi google_login thêm lần nữa. Xem danh sách bằng google_accounts.

  • Máy ảo có nhiều tài khoản thì Google Play cài app bằng tài khoản đang chọn trong Play. Muốn đổi tài khoản, chạm vào ảnh đại diện trong Play.

Phát triển

.venv\Scripts\pip install -e ".[dev]"
.venv\Scripts\python -m pytest

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

    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to interact with Android devices through UI manipulation, screen capture, touch gestures, text input, and app management via ADB. Provides comprehensive mobile automation capabilities including element detection, navigation, and application control for Android device testing and interaction.
      9
      45 PyPI
      2
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to fully control an Android emulator via MCP, including UI interaction, screenshots, APK installation, logging, and clipboard access, with optional live browser viewing for humans.
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to automate Android and iOS devices, including emulators and physical devices, by capturing screenshots, reading UI accessibility trees, performing touch and text input, and managing app lifecycle and logs.
      18
      4
      MIT