
Android MCP
Provides powerful inspection and interaction tools for connected android devices or emulators.
README
Android MCP Server
A Model Context Protocol (MCP) server that provides powerful inspection and interaction tools for connected android devices or emulators.
Features
- Device Management: List and manage connected Android devices via ADB with automatic fallback paths
- Enhanced UI Hierarchy Inspection: Extract complete UI hierarchy using Layout Inspector features with enhanced attributes
- Debug View Attributes: Access detailed view attributes and layout parameters
- Element Search: Find UI elements by resource ID, text content, or class name with exact matching options
- User Interaction: Click, swipe, and input text on Android devices with coordinate precision
- Activity Information: Get current foreground activity details with window state information
- Performance Optimized: Uses coroutines and caching for improved response times
Requirements
- Java 17+ (required for Kotlin)
- Android SDK Platform Tools (for ADB) - automatically detects from:
- System PATH
~/Library/Android/sdk/platform-tools/adb
(macOS)~/Android/Sdk/platform-tools/adb
(Windows/Linux)/usr/local/bin/adb
(Homebrew)/opt/android-sdk/platform-tools/adb
(Linux)
- Connected Android device (physical device or emulator)
- Developer options and USB debugging enabled on the Android device
Installation & Setup
Option 1: Download from GitHub Releases (Recommended)
- Download the latest release from GitHub Releases
- Download
android-mcp.jar
from the latest release - Verify integrity (optional but recommended):
sha256sum android-mcp.jar # Compare with the .sha256 file from the release
Option 2: Build from Source
# Clone the repository
git clone https://github.com/ulcica/android-mcp.git
cd android-mcp
# Build the Kotlin JAR file
./gradlew build
Configure Claude Desktop
Add this configuration to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"android-mcp": {
"command": "java",
"args": ["-jar", "/path/to/android-mcp/build/libs/android-mcp.jar"]
}
}
}
Usage
Development Commands
# Build and run the Kotlin server
./gradlew run
# Build only
./gradlew build
# Run tests
./gradlew test
# Run the JAR directly
java -jar build/libs/android-mcp.jar
# Check version
java -jar build/libs/android-mcp.jar --version
# Show help
java -jar build/libs/android-mcp.jar --help
Available Tools
The Kotlin MCP server provides 11 comprehensive tools:
1. get_device_list
Lists all connected Android devices.
Input: None Output: Array of connected devices with their IDs, states, and models
2. get_app_list
Gets list of installed applications on the Android device.
Input:
deviceId
(optional): Android device IDincludeSystemApps
(optional): Include system applications in the list (default: false, shows only user-installed apps)
Output: Array of installed applications with package names, sorted alphabetically
3. get_current_activity
Gets enhanced information about the current foreground activity.
Input:
deviceId
(optional): Android device ID
Output: Current package name, activity name, PID, and window state information
3. get_view_attributes
Gets UI hierarchy with enhanced view attributes by temporarily enabling debug mode.
Input:
deviceId
(optional): Android device ID
Output: UI hierarchy with detailed view attributes, layout parameters, and debug information
4. find_elements
Searches for UI elements using various criteria.
Input:
deviceId
(optional): Android device IDresourceId
(optional): Resource ID to search fortext
(optional): Text content to search forclassName
(optional): Class name to search forexactMatch
(optional): Whether to use exact text matching (default: false)
Output: Array of matching UI elements
5. view_hierarchy
Gets the UI view hierarchy from uiautomator dump with rotation information.
Input:
deviceId
(optional): Android device ID
Output: Structured view hierarchy with device info, timestamp, rotation, and UI element tree
6. click_coordinate
Clicks at specific (x,y) coordinates on the Android device screen.
Input:
x
(required): X coordinate to clicky
(required): Y coordinate to clickdeviceId
(optional): Android device ID
Output: Success confirmation with device info, coordinates, and timestamp
7. swipe_coordinate
Swipe from start (x,y) coordinates to end (x,y) coordinates on the Android device screen.
Input:
deviceId
(optional): Android device IDstartX
(required): Starting X coordinatestartY
(required): Starting Y coordinateendX
(required): Ending X coordinateendY
(required): Ending Y coordinateduration
(optional): Swipe duration in milliseconds (default: 300)
Output: Success confirmation with device info, coordinates, duration, and timestamp
8. input_text
Input text on the Android device (types text into focused field).
Input:
deviceId
(optional): Android device IDtext
(required): Text to input on the device
Output: Success confirmation with device info, text, and timestamp
9. key_event
Send key event to Android device (e.g., Enter=66, Back=4, Home=3).
Input:
deviceId
(optional): Android device IDkeyCode
(required): Android key code (e.g., 66 for Enter, 4 for Back)
Output: Success confirmation with device info, key code, and timestamp
10. start_intent
Start an Android intent/activity with specified parameters (launch apps, open URLs, etc.).
Input:
deviceId
(optional): Android device IDaction
(optional): Intent action (e.g., 'android.intent.action.MAIN', 'android.settings.SETTINGS')category
(optional): Intent category (e.g., 'android.intent.category.LAUNCHER')dataUri
(optional): Data URI for the intent (e.g., 'https://example.com', 'tel:+1234567890')packageName
(optional): Target package name (e.g., 'com.android.settings')className
(optional): Target class name (e.g., 'com.android.settings.Settings')extras
(optional): String extras to pass with the intent as key-value pairs
Output: Success confirmation with device info, intent parameters, and timestamp
Architecture
Kotlin-Specific Improvements
- Coroutines: All ADB operations use Kotlin coroutines for non-blocking execution
- Type Safety: Leverages Kotlin's null safety and type system
- Data Classes: Clean, immutable data structures with built-in serialization
- Sealed Classes: Type-safe error handling with sealed error classes
- Concurrency: Better thread safety with concurrent data structures
- Clean Architecture: SOLID principles with separated concerns and focused classes
- Parameter Optimization: SwipeParams data class reduces parameter count from 7+ to 2
- Specific Exception Handling: Enhanced error types for better debugging and handling
Key Components
Main (Main.kt
)
- Entry point that starts the MCP server using coroutines
MCP Server (McpServer.kt
)
- Handles JSON-RPC communication over stdio
- Implements all MCP tool endpoints
- Manages device caching and connection pooling
ADB Manager (AdbManager.kt
)
- Refactored facade coordinating specialized components following SOLID principles
- Delegates to focused classes: DeviceManager, UIInspector, DeviceInputController
- Maintains backward compatibility while providing cleaner architecture
- Provides both legacy parameter methods and new SwipeParams-based methods
Specialized ADB Components:
- AdbPathResolver: Auto-discovery of ADB path with caching and fallback strategies
- DeviceManager: Device listing and management operations with connection pooling
- UIInspector: UI hierarchy inspection with debug mode and XML extraction
- DeviceInputController: All input operations (tap, swipe, text, key events)
- ShellCommandExecutor: Persistent ADB shell connections with command batching
UI Hierarchy Parser (UIHierarchyParser.kt
)
- Custom XML parser for Android UI hierarchies
- Element search utilities with functional programming patterns
- Support for enhanced Layout Inspector attributes
- XmlExtractionUtils: Dedicated utility for XML content extraction with multiple fallback strategies
Type System (model/
package)
- Comprehensive Kotlin data classes with serialization support
- Enhanced sealed class hierarchy for type-safe error handling
- SwipeParams data class for parameter optimization
- AndroidMcpConstants for centralized configuration
- Enum classes for device states and comprehensive error codes
Performance Optimizations
The Kotlin version includes several performance improvements:
- Coroutine-based Execution: Non-blocking ADB operations
- Advanced Caching: Device list and ADB path caching with TTL
- Connection Pooling: Persistent device connections with cleanup
- Parallel Processing: Concurrent execution of independent ADB commands
- Reduced Latency: Optimized debug mode timing (200ms vs 500ms)
UI Element Properties
Each UI element in the hierarchy contains the following properties:
class
: Android class name (e.g., "android.widget.TextView")package
: App package nametext
: Visible text content (if any)resource-id
: Android resource identifiercontent-desc
: Content description for accessibilitybounds
: Element bounds{left, top, right, bottom}
- Boolean properties:
checkable
,checked
,clickable
,enabled
,focusable
,focused
,scrollable
,long-clickable
,password
,selected
,visible
children
: Array of child UI elements
Error Handling
The Kotlin version uses sealed classes for type-safe error handling with enhanced specific exception types:
sealed class LayoutInspectorError {
class AdbNotFound(message: String)
class DeviceNotFound(message: String, deviceId: String?)
class UiDumpFailed(message: String, deviceId: String?)
class ParseError(message: String, deviceId: String?)
class ConnectionClosed(message: String, deviceId: String?)
class CommandTimeout(message: String, deviceId: String?)
class ShellCommandFailed(message: String, deviceId: String?)
class McpProtocolError(message: String, deviceId: String?)
class UnknownError(message: String, deviceId: String?)
}
The server includes comprehensive error handling with specific error codes:
ADB_NOT_FOUND
: ADB command not found in PATHDEVICE_NOT_FOUND
: Specified Android device not foundUI_DUMP_FAILED
: Failed to dump UI hierarchyPARSE_ERROR
: Failed to parse XML hierarchyCONNECTION_CLOSED
: ADB connection closed unexpectedlyCOMMAND_TIMEOUT
: Command execution timeoutSHELL_COMMAND_FAILED
: Shell command execution failedMCP_PROTOCOL_ERROR
: MCP protocol violationsUNKNOWN_ERROR
: Generic error
Development
See Development.md for detailed development information including:
- Project structure and architecture
- Building from source
- Version management
- Testing procedures
- Code quality guidelines
- Release process
- Contributing guidelines
MCP Integration
This server implements the Model Context Protocol and can be used with any MCP-compatible client:
- Claude Desktop: Add to your MCP configuration
- Claude CLI: Add to your CLI configuration
- Custom Applications: Connect via stdio transport
- Development Tools: Use for Android app testing and analysis
Claude Desktop Configuration
{
"mcpServers": {
"android-mcp": {
"command": "java",
"args": ["-jar", "/path/to/android-mcp/build/libs/android-mcp.jar"]
}
}
}
Claude CLI Setup
Manual Setup:
claude mcp add android-mcp java -jar /path/to/android-mcp/build/libs/android-mcp.jar
Usage Examples:
claude "List my connected Android devices"
claude "Show me the installed apps on my Android device"
claude "Get all apps including system apps from my Android device"
claude "Show me the UI hierarchy of my Android screen"
claude "Get the view hierarchy with rotation info from my Android device"
claude "Find elements with text Settings on my Android device"
claude "Click at coordinates 200,300 on my Android device"
claude "Swipe from 100,500 to 100,200 on my Android device"
claude "Input text 'hello world' on my Android device"
claude "Send Enter key (code 66) to my Android device"
claude "Start intent with action android.intent.action.MAIN and category android.intent.category.LAUNCHER"
claude "Open Settings app using start intent"
Use Cases
- UI Testing: Automated testing of Android applications
- App Discovery: Discover and analyze installed applications on Android devices
- Accessibility Analysis: Analyze app accessibility properties
- Layout Debugging: Debug layout issues and element positioning
- App Analysis: Reverse engineer app UI structures and discover available packages
- Quality Assurance: Validate UI consistency across screens
- Automated Interaction: Programmatically interact with Android apps through touch events, swipes, and text input
- Performance Testing: Measure UI response times and interaction latencies
- User Journey Automation: Automate complex user workflows and scenarios
Troubleshooting
Common Issues
- Java Version: Ensure Java 17+ is installed
- ADB Path: Make sure Android SDK platform-tools are in PATH
- Device Connection: Verify device is connected and authorized
- JAR Location: Update paths in Claude config if JAR location changes
ADB Issues
- The server automatically searches for ADB in common locations
- If ADB is not found, install Android SDK platform-tools
- Verify USB debugging is enabled on your Android device
- Check device authorization status with
adb devices
(or use full path if needed)
Permission Issues
- Ensure your Android device is authorized for debugging
- Check that the connected device appears in
adb devices
UI Dump Failures
- Some apps may block UI inspection for security reasons
- Ensure the target app is in the foreground
- Try refreshing the device connection
Debug Mode
Add logging to see detailed ADB command execution:
// In AdbManager.kt, uncomment debug statements
System.err.println("Executing: ${command.joinToString(" ")}")
Releases
This project uses automated GitHub releases. New versions are automatically built and published when tags are created.
Release Process
- Update version in
build.gradle.kts
- Commit changes and create a git tag:
git tag v1.2.0 git push origin v1.2.0
- GitHub Actions automatically:
- Builds the JAR file
- Runs tests on Java 17 and 21
- Creates a GitHub release
- Uploads
android-mcp.jar
with checksums - Generates changelog from commit messages
Download Latest Release
Always download the latest version from GitHub Releases for the most stable experience.
License
MIT License.
推荐服务器

Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。