A production-ready Model Context Protocol (MCP) server for intelligent Android device automation via ADB. Built with Python, featuring semantic UI interaction, cross-app workflows, and minimal token usage for LLM agents.
- ADB Integration: Full device control via Android Debug Bridge
- UI Automation: Semantic element interaction using uiautomator2 (no raw coordinates)
- Multi-Device Support: Manage multiple connected Android devices
- Cross-App Workflows: Pre-built workflows for Instagram, WhatsApp, Telegram
- Context-Efficient: Minimal token usage with structured JSON responses
- Security: Device allowlist, PIN authentication, destructive action confirmation
- Performance: Element caching, decorative filtering, connection reuse
- Production-Ready: Type hints, comprehensive logging, clean architecture
- Python 3.10+
- ADB (Android Debug Bridge)
- Install via Android SDK Platform Tools
- Or use package manager:
apt install adb(Linux) orbrew install android-platform-tools(macOS)
- Android Device or Emulator
- Enable USB debugging in Developer Options
- Connect via USB or WiFi
# Clone repository
git clone <repository-url>
cd android-adb-mcp-server
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Install development dependencies (optional)
pip install -e ".[dev]"
# Install OCR support (optional)
pip install -e ".[ocr]"# Check ADB is installed
adb version
# List connected devices
adb devices
# Should show:
# List of devices attached
# <device_id> device./setup.sh
source venv/bin/activateCopy and edit config.example.yaml to config.yaml for custom settings. Default configuration works out of the box.
# Start with default config
python -m mcp_server.server
# Start with custom config
python -m mcp_server.server /path/to/config.yamlSee mcp_configs.json for configuration examples for various MCP clients (Claude Desktop, Kiro, Cline, Cursor, etc.).
Standard configuration format:
{
"mcpServers": {
"android-adb": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"cwd": "/path/to/android-adb-mcp-server",
"env": {
"PYTHONPATH": "/path/to/android-adb-mcp-server"
}
}
}
}The server exposes the following tools via MCP protocol:
list_devices()- List all connected devicesselect_device(device_id)- Set active device
open_app(app_name, package=None)- Launch applicationnavigate_back()- Press back buttonnavigate_home()- Go to home screen
tap(text=None, content_desc=None, resource_id=None)- Tap elementtype_text(text, element_identifier=None)- Type textfind_element(...)- Locate UI elementsget_current_screen_structure()- Get screen layout
send_message(app_name, contact_name, message)- Send message via appextract_otp()- Extract OTP from SMSread_screen_text()- Read all visible text
take_screenshot()- Capture screeninstall_app(apk_path)- Install APKuninstall_app(package, confirm=False)- Remove appget_notifications()- Retrieve notifications
MCP Server Layer (server.py)
↓
App Actions Layer (app_actions.py) - High-level workflows
↓
UI Controller Layer (ui_controller.py) - Semantic interaction
↓
ADB Controller Layer (adb_controller.py) - Low-level commands
↓
Device Manager Layer (device_manager.py) - Multi-device routing
mcp_server/
├── server.py # MCP server with 15+ tools
├── adb_controller.py # ADB command execution
├── ui_controller.py # UI automation with uiautomator2
├── device_manager.py # Multi-device management
├── app_actions.py # Cross-app workflows
├── config.py # Configuration management
└── utils/
├── logging.py # Logging utilities
└── text_processing.py # Text utilities
# Run all tests
pytest
# Run with coverage
pytest --cov=mcp_server --cov-report=html
# Run specific test file
pytest tests/unit/test_adb_controller.py
# Run property-based tests
pytest tests/unit/ -k "property"Follow PEP 8 guidelines. Use type hints throughout.
See examples/ directory for:
tool_calls.py- Example MCP tool invocationstest_scenario.py- End-to-end test scenarios
{
"tool": "send_message",
"parameters": {
"app_name": "whatsapp",
"contact_name": "John Doe",
"message": "Hello from MCP!"
}
}{
"tool": "extract_otp",
"parameters": {}
}- README.md - This file (overview and quick start)
- QUICKSTART.md - Detailed quick start guide
- mcp_configs.json - MCP client configuration examples
- config.example.yaml - Annotated configuration example
- Check Python version:
python --version(must be 3.10+) - Verify dependencies:
pip list | grep mcp - Check ADB:
adb devices - Review logs:
cat adb_mcp_server.log
- Run:
adb devices - Enable USB debugging on device
- Try:
adb kill-server && adb start-server
- Restart MCP client application
- Verify PYTHONPATH is set correctly
- Test server manually:
python -m mcp_server.server
MIT License
Contributions welcome! Please open an issue or pull request.