This Android MCP Server provides comprehensive Android device control and automation through 22 powerful tools for UI interaction, screen capture, and device management.
Key Capabilities:
Screen Capture & Streaming: Standard screenshots (1-2s), ultra-fast Scrcpy single frame capture (100-300ms), and real-time H.264 video streaming with frame polling (<50ms)
Touch & Gesture Control: Simulate taps, long presses, and swipe gestures at specific screen coordinates
Text Input & Key Events: Direct text input into focused fields and inject key events (HOME, BACK, ENTER, etc.)
App Management: Launch applications by package name and list installed packages with optional filtering
UI Automation (UIAutomator): Inspect UI hierarchy (XML dump), find elements by resource ID or text, and perform targeted interactions (click, double-click, long-click, set/clear text, toggle checkboxes, wait, and scroll)
Generic ADB Commands: Execute any custom ADB command for complete device control including logcat, shell commands, package management, and file operations
Multi-Device Support: Target specific devices using
deviceSerialfor parallel automation
Use Cases: Automated UI testing, remote device monitoring, form filling workflows, app QA, device farm automation, and documentation.
Provides Android device control capabilities via ADB, including capturing screenshots, simulating touch events at specific coordinates, and performing swipe gestures on connected Android devices or emulators.
Android MCP Server
A Model Context Protocol (MCP) server providing comprehensive Android device control with 22 powerful tools for UI automation, screen capture, and ultra-fast H.264 streaming via Scrcpy.
Features
📸 Screenshots: Capture screenshots from Android devices
👆 Touch & Gestures: Simulate touch, long press, swipe, and multi-point interactions
⌨️ Text Input & Key Events: Direct text input and key event simulation (2 tools)
Send key events (HOME, BACK, ENTER, etc.)
Input text directly into focused fields
🔧 Generic ADB Commands: Execute any ADB command with custom parameters (1 tool)
Full flexibility for agents to run custom ADB operations
Access to all ADB functionality (logcat, shell commands, package manager, etc.)
🎯 UIAutomator: Full UI hierarchy inspection and element interaction (10 tools)
Dump complete XML UI hierarchy
Find elements by resource ID or text
Click, double-click, long-click on elements
Set/clear text in input fields
Toggle checkboxes
Wait for elements to appear
Scroll within specific elements
⚡ Scrcpy Streaming: Ultra-fast H.264 video streaming (4 tools)
Start/stop H.264 video streams (~2s setup, <50ms frame polling)
Capture single frames (100-300ms) or latest stream frames (<50ms)
Dramatically faster than screenshot capture
🚀 App Management: Launch apps and list installed packages
🔌 ADB Integration: Direct integration with Android Debug Bridge
⚡ Auto-Download: Automatically downloads ADB and Scrcpy from official sources
Prerequisites
Node.js 18 or higher
Android device connected via USB with USB debugging enabled, or emulator running
Note: ADB (Android Debug Bridge) and Scrcpy are optional - the server automatically downloads them from official sources on first use if needed.
Quick Start
Clone and Build
git clone https://github.com/jduartedj/android-mcp-server.git cd android-mcp-server npm install npm run buildTest the Server
node dist/index.jsThe server will start and automatically download ADB/Scrcpy if needed.
Add to VS Code (see VS Code Integration below)
Installation
Usage
Running the Server Standalone
Configuration
The server supports the following environment variables:
ADB_PATH: Custom path to ADB executable (default: uses system PATH or auto-downloads)DEVICE_SERIAL: Specific device serial number to target (default: first available device)
VS Code Integration
Adding to VS Code GitHub Copilot
To use this MCP server with GitHub Copilot in VS Code:
Open VS Code Settings (Ctrl+, or Cmd+,)
Search for MCP or navigate to:
GitHub Copilot > Chat > MCP ServersEdit the MCP configuration by clicking "Edit in settings.json"
Add the Android MCP Server to your configuration:
Note: Replace F:\\android-mcp-server\\dist\\index.js with the actual absolute path to your dist/index.js file. Use double backslashes on Windows.
Alternative: Using npx (if published to npm):
Reload VS Code or restart the GitHub Copilot extension
Verifying the Integration
After adding the server:
Open GitHub Copilot Chat in VS Code
Type
@workspaceand you should see the Android MCP tools availableTry asking: "Take a screenshot of my Android device"
Copilot will use the appropriate tool to capture the screen
Example Prompts for Copilot
Once integrated, you can ask GitHub Copilot:
"Take a screenshot of my Android device"
"Start streaming my device screen for real-time monitoring"
"Get the latest frame from the stream"
"Tap at coordinates 500, 1000 on my phone"
"Swipe up on my Android screen"
"Press the back button on my device"
"Send the home key event"
"Type 'hello world' into the current field"
"Press enter to submit the form"
"Get the device battery status using ADB"
"Read the logcat output for debugging"
"Clear the app data for com.example.app"
"List all installed packages"
"Launch the Chrome app"
"Find the login button and click it"
"Fill in the email field with user@example.com"
"Dump the UI hierarchy of the current screen"
"Long press on the menu button"
"Scroll down in the settings list"
"Toggle the enable notifications checkbox"
"Wait for the loading indicator to disappear"
All 22 MCP Tools
Basic Tools (5)
1. android_screenshot
Capture a screenshot from the Android device.
Parameters:
outputPath(optional): Local path to save the screenshot. If not provided, returns base64 encoded image.deviceSerial(optional): Target specific device by serial number
Performance: ~1-2 seconds per capture
Example:
2. android_touch
Simulate a touch event at specific screen coordinates. Supports both quick taps and long presses.
Parameters:
x(required): X coordinatey(required): Y coordinateduration(optional): Touch duration in milliseconds (default: 100ms for tap, >100ms for long press)deviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example - Quick Tap:
Example - Long Press:
3. android_swipe
Perform a swipe gesture between two coordinates.
Parameters:
startX(required): Starting X coordinatestartY(required): Starting Y coordinateendX(required): Ending X coordinateendY(required): Ending Y coordinateduration(optional): Swipe duration in milliseconds (default: 300)deviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
4. android_launch_app
Launch an Android app by package name.
Parameters:
packageName(required): Package name of the app (e.g., com.example.app, com.google.android.apps.maps)deviceSerial(optional): Target specific device by serial number
Performance: ~1-2 seconds
Example:
5. android_list_packages
List installed packages on the Android device with optional filtering.
Parameters:
filter(optional): Search filter for package names (case-insensitive)deviceSerial(optional): Target specific device by serial number
Performance: Medium (retrieves full package list)
Example - List All Packages:
Example - Filter Packages:
Text Input & Key Event Tools (2)
6. android_input_text
Input text into the currently focused field on the Android device via ADB.
Parameters:
text(required): Text to input. Spaces are automatically handled.deviceSerial(optional): Target specific device by serial number
Performance: Immediate
Use Cases:
Quick text input without UIAutomator
Inputting text when element resource ID is unknown
Simple form filling
Command-line style text entry
Example:
7. android_send_key_event
Send a key event to the Android device (e.g., HOME, BACK, ENTER).
Parameters:
keyCode(required): Key event code. Can be key name (e.g., KEYEVENT_HOME, KEYEVENT_BACK) or numeric code (e.g., 3 for HOME, 4 for BACK)deviceSerial(optional): Target specific device by serial number
Performance: Immediate
Common Key Codes:
KEYEVENT_HOMEor3- Home buttonKEYEVENT_BACKor4- Back buttonKEYEVENT_ENTERor66- Enter/Return keyKEYEVENT_DELor67- Delete keyKEYEVENT_MENUor82- Menu buttonKEYEVENT_VOLUME_UPor24- Volume upKEYEVENT_VOLUME_DOWNor25- Volume downKEYEVENT_POWERor26- Power button
Use Cases:
Navigation (HOME, BACK)
Submitting forms (ENTER)
Controlling device functions (VOLUME, POWER)
Keyboard shortcuts
Example:
Generic ADB Command Tool (1)
8. android_execute_command
Execute a generic ADB command with custom arguments. This powerful tool gives agents full flexibility to run any ADB command with their own parameters.
Parameters:
args(required): Array of ADB command arguments (e.g., ["shell", "pm", "list", "packages"])deviceSerial(optional): Target specific device by serial number
Performance: Varies by command
Returns: Both stdout and stderr from the command execution
Use Cases:
Execute custom shell commands
Access logcat for debugging
Manage packages (install, uninstall, clear data)
Query device properties
File operations (push, pull)
Network operations (port forwarding)
Any ADB functionality not covered by specific tools
Common Examples:
List all packages:
Get device properties:
Read logcat:
Clear app data:
Get battery info:
Push file to device:
Install APK:
Port forwarding:
UIAutomator Tools (10)
9. android_uiautomator_dump
Dump the complete UI hierarchy of the current screen as XML for inspection and element identification.
Parameters:
deviceSerial(optional): Target specific device by serial number
Returns: Complete XML UI hierarchy that can be parsed to find element resource IDs and attributes.
Performance: ~500-800ms
Use Cases:
Inspecting app UI structure
Finding element resource IDs for automation
Understanding view hierarchies
Example:
10. android_uiautomator_find
Find UI elements by resource ID or text content using UIAutomator.
Parameters:
resourceId(optional): Resource ID to search for (e.g., com.example.app:id/button_submit)text(optional): Text content to search fordeviceSerial(optional): Target specific device by serial number
Performance: Fast
Example - Find by Resource ID:
Example - Find by Text:
11. android_uiautomator_click
Click on a UI element by resource ID.
Parameters:
resourceId(required): Resource ID of the element to clickdeviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
12. android_uiautomator_double_click
Perform a double-click on a UI element by resource ID.
Parameters:
resourceId(required): Resource ID of the elementdeviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
13. android_uiautomator_long_click
Perform a long-click on a UI element by resource ID.
Parameters:
resourceId(required): Resource ID of the elementdeviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
14. android_uiautomator_set_text
Set text on a UI element by resource ID. Automatically clears existing text first.
Parameters:
resourceId(required): Resource ID of the elementtext(required): Text to setdeviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
15. android_uiautomator_clear_text
Clear text from a UI element by resource ID.
Parameters:
resourceId(required): Resource ID of the elementdeviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
16. android_uiautomator_toggle_checkbox
Toggle a checkbox element by resource ID.
Parameters:
resourceId(required): Resource ID of the checkboxdeviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
17. android_uiautomator_wait
Wait for a UI element to appear by resource ID with timeout support.
Parameters:
resourceId(required): Resource ID to wait fortimeoutMs(optional): Maximum wait time in milliseconds (default: 5000)deviceSerial(optional): Target specific device by serial number
Performance: Configurable (up to timeout)
Example:
18. android_uiautomator_scroll_in_element
Scroll within a specific scrollable UI element.
Parameters:
resourceId(required): Resource ID of the scrollable elementdirection(required): Direction to scroll (up, down, left, right)distance(optional): Distance to scroll in pixels (default: 500)deviceSerial(optional): Target specific device by serial number
Performance: Immediate
Example:
Scrcpy Streaming Tools (4)
Scrcpy streaming provides ultra-fast frame capture using H.264 video encoding, perfect for real-time monitoring, rapid screenshot sequences, or continuous frame polling.
19. android_start_scrcpy_stream
Initialize an H.264 video stream from the Android device using Scrcpy.
Parameters:
deviceSerial(optional): Target specific device by serial numberbitrate(optional): Video bitrate in Mbps (default: 4)fps(optional): Frames per second (default: 60)
Performance: ~2 seconds setup, <50ms per frame polling afterward
Advantages:
Ultra-fast frame capture (<50ms vs 1-2s for screenshot)
Continuous streaming with pre-buffered frames
Ideal for real-time monitoring
H.264 compression reduces bandwidth
Example:
20. android_get_latest_frame
Poll the latest frame from an active Scrcpy stream.
Parameters:
deviceSerial(optional): Target specific device by serial numberoutputPath(optional): Save frame to file, otherwise returns base64
Performance: <50ms per frame (due to pre-buffered streaming)
Use Cases:
Real-time monitoring
Rapid screenshot sequences
Continuous frame polling
Streaming visualization
Example:
21. android_stop_scrcpy_stream
Stop an active Scrcpy H.264 stream.
Parameters:
deviceSerial(optional): Target specific device by serial number
Example:
22. android_capture_frame_scrcpy
Capture a single frame using Scrcpy without starting a persistent stream.
Parameters:
deviceSerial(optional): Target specific device by serial numberoutputPath(optional): Save frame to file, otherwise returns base64bitrate(optional): Video bitrate in Mbps (default: 4)
Performance: 100-300ms (faster than screenshot, slower than streaming)
Use Cases:
One-off frame captures
When streaming overhead isn't justified
Single frame comparison
Lightweight capture operations
Example:
Performance Comparison
Tool | Purpose | Speed | Best For |
| Basic capture | 1-2s | Simple screenshots, initial inspection |
| Single Scrcpy frame | 100-300ms | Faster one-off captures than screenshot |
| Initialize stream | ~2s setup | Real-time monitoring workflows |
| Poll stream | <50ms | Rapid frame sequences, real-time apps |
| Tap/long press | Immediate | UI interaction |
| Swipe gesture | Immediate | Navigation, scrolling |
| Direct text input | Immediate | Quick text entry via ADB |
| Key events | Immediate | Navigation (HOME, BACK, ENTER) |
| Generic ADB | Varies | Custom ADB operations, full flexibility |
| UI inspection | 500-800ms | Element discovery |
| Element search | Fast | Located specific elements |
| Element interaction | Immediate | Form filling, UI automation |
Common Use Cases
1. Automated Testing
2. Real-Time Monitoring
3. Rapid Frame Capture Sequence
4. Form Filling (WebView or Native)
5. Multi-Device Automation
Use deviceSerial parameter to target specific devices:
6. App Discovery
ADB & Scrcpy Setup
Automatic Installation
The server automatically downloads and installs from official sources:
ADB: From Android Platform Tools
Scrcpy: From official releases
Downloaded tools stored in ~/.android-mcp-server/platform-tools/
Manual Installation (Optional)
Windows:
macOS:
Linux (Ubuntu/Debian):
Enabling USB Debugging on Android
Go to Settings → About Phone
Tap Build Number 7 times to enable Developer Options
Go to Settings → Developer Options
Enable USB Debugging
Connect device via USB and accept the debugging prompt
Verify Connection
You should see your device listed.
Troubleshooting
Issue | Solution |
"No Android devices found" | Ensure device is connected via USB and USB debugging is enabled. Run
to verify. |
UIAutomator element not found | Use
to inspect the XML and verify the resource ID exists. |
Scrcpy stream won't start | Ensure Scrcpy is installed or allow auto-download to complete. Check device is connected. |
"ADB not found" error | Run the server once to auto-download ADB, or manually install platform-tools. |
Touch coordinates not working | Verify coordinates are within screen bounds. Use screenshots to determine correct coordinates. |
App launch fails | Verify package name is correct using
. Try filtering if unsure. |
Streaming frames are slow | Reduce bitrate/fps or use single
for one-off captures. |
Advanced Patterns
Real-Time Visual Monitoring
Stress Testing with Rapid Frames
Multi-Step Form Automation
Device Farm Parallel Testing
Architecture
The server uses the Model Context Protocol to expose Android device control:
ADB Wrapper (
src/adb-wrapper.ts): Device communication, auto-downloads ADBScrcpy Integration (
src/adb-wrapper.ts): H.264 streaming, frame pollingUIAutomator Methods (
src/adb-wrapper.ts): Full XML dumping, element interactionTool Handlers (
src/handlers.ts): All 19 tool operationsMCP Server (
src/index.ts): Exposes all tools via Model Context Protocol
Supported Android Versions
Android 5.0+ (API Level 21+)
Scrcpy streaming: Android 5.0+ via ADB, optimal on 7.0+
Development
Adding New Tools
To add a new tool:
Implement method in
src/adb-wrapper.tsImplement handler in
src/handlers.tsRegister tool in
src/index.tswith name, description, and schemaBuild and test with the server running
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.