mcp-mobile-automation
v1.0.6
Published
Model Context Protocol server for mobile app automation using Appium
Maintainers
Readme
📱 Mobile MCP
Model Context Protocol Server for Mobile App Automation
A powerful Model Context Protocol server that enables AI assistants to automate iOS and Android mobile applications using Appium. Perfect for mobile testing, automation, and interaction workflows.
Installation • Quick Start • Documentation • Examples
✨ Features
- 🤖 Appium Integration: Full Appium 2.0 support for iOS and Android
- 📱 Cross-Platform: Automate both iOS and Android applications
- 🛠️ 56 Tools: Comprehensive set of mobile automation tools with platform-specific filtering
- 🔍 Element Finding: Multiple locator strategies (ID, XPath, Accessibility ID, etc.)
- 👆 Gestures: Tap, swipe, long press, drag & drop, and other touch interactions
- 📸 Screenshots: Capture device screenshots
- 🔧 App Management: Install, remove, launch, and close apps
- 🌳 Page Source: Get XML hierarchy of the current screen
- 💾 Session Management: Create and manage automation sessions
- 🎯 Platform Filtering: Tools automatically filtered based on iOS/Android
- 📦 Easy Installation: Available as npm package
📋 Table of Contents
- Prerequisites
- Installation
- Quick Start
- Configuration
- Available Tools
- Usage Examples
- Device Setup
- Troubleshooting
- Contributing
- License
🔧 Prerequisites
Before using this MCP server, ensure you have the following installed:
Required Software
Node.js (v18 or higher)
node --versionAppium (will be installed with npm install)
For Android Automation:
- Android Studio
- Android SDK Platform Tools
- Java JDK 8 or higher
- Set environment variables:
export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/platform-tools export PATH=$PATH:$ANDROID_HOME/tools
For iOS Automation (macOS only):
- Xcode (latest version)
- Xcode Command Line Tools
- Carthage:
brew install carthage - ios-deploy:
npm install -g ios-deploy
📦 Installation
Option 1: NPM (Recommended)
Install globally via npm:
npm install -g mcp-mobile-automationInstall Appium drivers:
# For Android
npx appium driver install uiautomator2
# For iOS (macOS only)
npx appium driver install xcuitestOption 2: From Source
Clone and install:
git clone https://github.com/infinityAutomation/mobile-mcp.git
cd mobile-mcp
npm install
# Install drivers
npx appium driver install uiautomator2
npx appium driver install xcuitest🚀 Quick Start
1. Configure Your MCP Client
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"mobile-automation": {
"command": "npx",
"args": ["mcp-mobile-automation"]
}
}
}VS Code (.vscode/mcp.json):
{
"servers": {
"mobile-automation": {
"type": "stdio",
"command": "npx",
"args": ["mcp-mobile-automation"]
}
}
}2. Basic Usage
1. Start Appium: "Start the Appium server"
2. Create Session: "Create a session for Android emulator Pixel_6"
3. Automate: "Find the login button and click it"
4. Clean Up: "Delete the session and stop Appium"⚙️ Configuration
Location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json
NPM Installation:
{
"mcpServers": {
"mobile-automation": {
"command": "npx",
"args": ["mcp-mobile-automation"]
}
}
}Source Installation:
{
"mcpServers": {
"mobile-automation": {
"command": "node",
"args": ["/path/to/mobile-mcp/src/index.js"]
}
}
}Location: .vscode/mcp.json in your workspace
NPM Installation:
{
"servers": {
"mobile-automation": {
"type": "stdio",
"command": "npx",
"args": ["mcp-mobile-automation"]
}
}
}Source Installation:
{
"servers": {
"mobile-automation": {
"type": "stdio",
"command": "node",
"args": ["/path/to/mobile-mcp/src/index.js"]
}
}
}📚 Available Tools
The server provides 56 comprehensive tools organized into the following categories:
start_appium
Start the Appium server.
port(optional): Port number (default: 4723)host(optional): Host address (default: localhost)
stop_appium
Stop the Appium server.
create_session
Create a new automation session.
platformName: "iOS" or "Android"deviceName: Device/emulator nameapp: Path to app file (optional)appPackage/appActivity: Android app details (optional)bundleId: iOS bundle identifier (optional)
delete_session
End the current automation session.
find_element- Find single element by ID, XPath, etc.find_elements- Find multiple elementsclick_element- Click an elementsend_keys- Send text to elementclear_element- Clear element textget_element_text- Get element textget_element_attribute- Get element attributesis_element_displayed- Check visibilityis_element_enabled- Check if enabledsubmit_element- Submit a form element
tap- Tap at coordinatesswipe- Swipe gesturescroll- Scroll in directionlong_press- Long press gesturedrag_and_drop- Drag element to targetpinch- Pinch gesturezoom- Zoom gesturehide_keyboard- Hide on-screen keyboardrotate_device- Rotate device orientation- And more...
install_app- Install app on deviceremove_app- Remove app from devicelaunch_app- Launch the appclose_app- Close the appget_app_state- Check app stateactivate_app- Activate app in backgroundterminate_app- Terminate app
take_screenshot- Capture screenshotget_page_source- Get XML hierarchyget_device_info- Device informationget_device_time- Device timeget_battery_info- Battery statusget_network_connection- Network statusget_clipboard- Get clipboard contentset_clipboard- Set clipboard content
start_activity- Start Android activitypress_keycode- Press hardware keycodetoggle_wifi- Toggle WiFitoggle_airplane_mode- Toggle airplane modeopen_notifications- Open notification drawerclear_app- Clear app data
touch_id- Simulate Touch IDface_id- Simulate Face IDpress_key- Press iOS button (home, volumeUp, volumeDown)
Note: Platform-specific tools are automatically filtered based on your active session (iOS or Android).
💡 Usage Examples
Example 1: Android App Login Flow
💡 Usage Examples
Example 1: Android App Login Flow
User: "Start Appium server on port 4723"
Assistant: [Calls start_appium tool]
User: "Create a session for Android emulator Pixel_6_API_33 with app at /path/to/app.apk"
Assistant: [Calls create_session with platformName: "Android", deviceName: "Pixel_6_API_33", app: "/path/to/app.apk"]
User: "Find the username field by ID 'username_input' and enter 'testuser'"
Assistant: [Calls find_element, then send_keys]
User: "Find password field by ID 'password_input' and enter 'password123'"
Assistant: [Calls find_element, then send_keys]
User: "Click the login button with ID 'login_btn'"
Assistant: [Calls find_element, then click_element]
User: "Take a screenshot"
Assistant: [Calls take_screenshot]
User: "Stop everything"
Assistant: [Calls delete_session, then stop_appium]Example 2: iOS App Testing
User: "Start Appium and create iOS session for iPhone 14 simulator"
Assistant: [Calls start_appium, then create_session]
User: "Swipe up from bottom"
Assistant: [Calls swipe with appropriate coordinates]
User: "Find all buttons on screen"
Assistant: [Calls find_elements with "class name" and "XCUIElementTypeButton"]
User: "Get the page source to see element hierarchy"
Assistant: [Calls get_page_source]Example 3: Gesture Automation
User: "Perform long press on element with ID 'menu_item'"
Assistant: [Calls find_element, then long_press]
User: "Drag element 'draggable' to element 'drop_zone'"
Assistant: [Calls find_element for both, then drag_and_drop]
User: "Scroll down on the page"
Assistant: [Calls scroll with direction: "down"]📱 Device Setup
Android Emulator
- Open Android Studio → AVD Manager
- Create virtual device (e.g., Pixel 6, API 33)
- Start emulator
- Verify:
adb devices
Android Real Device
- Enable Developer Options on device
- Settings → About Phone → Tap "Build Number" 7 times
- Enable USB Debugging
- Settings → Developer Options → USB Debugging
- Connect via USB and accept prompt
- Verify:
adb devices
iOS Simulator
- Open Xcode → Window → Devices and Simulators
- Create/start simulator (e.g., iPhone 14)
- Verify:
xcrun simctl list devices
iOS Real Device
- Connect device via USB
- Trust computer on device
- Register device in Xcode
- Get UDID:
idevice_id -lor Xcode → Window → Devices and Simulators
🔧 Troubleshooting
Server won't start:
# Check if port is in use
lsof -i :4723
# Kill process
kill -9 <PID>
# Try different port
# Use port parameter in start_appiumDriver not installed:
# List installed drivers
npx appium driver list
# Install missing driver
npx appium driver install uiautomator2
npx appium driver install xcuitestApp won't launch:
# Verify app package and activity
aapt dump badging app.apk | grep package
# Check device connection
adb devices
# View logs
adb logcat | grep -i errorDevice not detected:
# Restart ADB
adb kill-server && adb start-server
# Check USB debugging
adb devicesApp won't launch:
- Verify bundle ID matches installed app
- Ensure app is signed correctly
- Check Developer Certificate is trusted on device
Simulator not responding:
# Reset simulator
xcrun simctl erase all
# Restart Xcode
killall SimulatorReal device connection:
- Ensure device is unlocked
- Trust computer prompt accepted
- Latest Xcode installed
- Device registered in Apple Developer account
Element not found:
- Use
get_page_sourceto inspect hierarchy - Try different locator strategies:
id- Fastest, most reliableaccessibility id- Cross-platformxpath- Flexible but slowerclass name- For element types
- Add wait/delay for dynamic content
- Check if element is in different context (webview)
Wrong element selected:
- Use more specific XPath
- Combine multiple attributes
- Use index for multiple matches
🤝 Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
Development Setup
git clone https://github.com/infinityAutomation/mobile-mcp.git
cd mobile-mcp
npm installRunning Tests
# Start Appium
npx appium
# In another terminal, run your tests
node src/index.js📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
📚 Resources
- Appium Documentation
- Model Context Protocol
- Android Developer Docs
- iOS Developer Docs
- WebDriver Protocol
🙏 Acknowledgments
- Built with Model Context Protocol SDK
- Powered by Appium
- Inspired by the mobile automation community
Made with ❤️ by the Infinity Automation Team
