Appium MCP Server
Enables AI-powered mobile app testing and automation through Appium, using Azure OpenAI to intelligently navigate mobile applications and generate test cases.
README
Appium MCP Server
An MCP (Model Context Protocol) server powered by FastMCP that exposes the AppCrawler automation capabilities as callable tools. The crawler uses Appium to interact with mobile applications and Azure OpenAI to reason about navigation steps. The project also includes OpenAI Agents SDK integration for AI-powered agent workflows.
Project Structure
mobile-mcp/
├─ appcrawler/
│ ├─ __init__.py
│ ├─ config.py # Configuration models (Appium, Azure, CrawlerSettings)
│ ├─ crawler.py # AppCrawler implementation
│ ├─ docker_runner.py # Docker automation workflow
│ ├─ examples.py # Example test cases
│ ├─ prompts.py # LLM prompts for automation
│ └─ ui_dump.py # UI hierarchy extraction
├─ src/
│ ├─ server.py # MCP server with FastMCP
│ ├─ agent.py # OpenAI agent integration
│ └─ settings.py # MCP server configuration from environment
├─ pyproject.toml # Project dependencies and metadata
├─ requirements.txt # Alternative dependency list
└─ README.md
Features
- MCP Server: Expose AppCrawler tools via Model Context Protocol
- OpenAI Agent Integration: Connect MCP server to OpenAI Agents SDK
- Mobile Automation: Automated mobile app testing using Appium
- LLM-Guided Navigation: Use Azure OpenAI to reason about app navigation
- Configuration Management: Environment-based configuration with Pydantic
Getting Started
1. Install Dependencies
Using requirements.txt:
pip install -r requirements.txt
Or using pyproject.toml:
pip install -e .
Note: If using
uv, substituteuv pip installforpip install.
2. Configure Environment Variables
Create a .env file in the project root:
# MCP Server
MCP_PORT=8000
MCP_HOST=0.0.0.0
MCP_SERVER_URL=http://localhost:8000
# Azure OpenAI
AZURE_OPENAI_API_KEY=your-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=gpt-4o
3. Run the MCP Server
Standalone MCP Server (STDIO transport)
python src/server.py
This runs the server using STDIO transport, which is compatible with most MCP clients.
Note: For OpenAI Agents SDK integration, the server needs to be configured to use SSE (Server-Sent Events) transport. The current implementation uses STDIO by default. To enable SSE transport, modify
src/server.pyto use SSE transport when running.
4. Initialize the Crawler
Invoke the initialize_crawler tool with:
- Appium desired capabilities (JSON object)
- Output directory path
- Azure OpenAI credentials (API key and endpoint)
- Optional: platform, wait time, test example, and Appium server URL
5. Use Available Tools
Every public method of AppCrawler is available as an MCP tool:
initialize_crawler- Initialize the crawler with configurationget_screen_hash- Generate a unique hash for the current screen's XMLsave_screen_xml- Persist the current screen XML (and screenshot) to diskquery_llm_for_next_action- Query the LLM for the next action given a screen XMLget_mobile_by- Map a locator strategy string to Appium's MobileBy constantperform_click- Perform a click action on a UI elementperform_send_keys- Send keys to a UI elementsave_test_case- Generate and save the test case using the recorded stepsprocess_flow- Run the LLM-guided automation loop (uses bundled prompts if none supplied)get_example_test_case- Get the bundled calculator example test caseget_task_prompt- Get the default task automation promptget_generate_test_case_prompt- Get the default test case generation promptget_default_prompts- Get both default prompt templatesget_ui_dump- Retrieve the UiAutomator hierarchy from the connected devicerun_docker_automation- Build and execute the Dockerized automation workflowcleanup- Terminate the Appium session and release resources
OpenAI Agent Integration
The project includes OpenAI Agents SDK integration for AI-powered workflows:
from src.agent import AppiumAgent
# Create agent (connects to MCP server automatically)
agent = AppiumAgent()
# Query the agent
response = await agent.query("Initialize the crawler and start automation")
Run the agent example:
python src/agent.py
Note: The
openai-agentspackage may not be publicly available on PyPI yet. If you encounter import errors, you may need to install it from a different source or wait for official release. The agent integration is optional and the MCP server works independently without it.
Configuration
Settings (src/settings.py)
Configuration is managed via environment variables using Pydantic Settings:
MCP_PORT: MCP server port (default: 8000)MCP_HOST: MCP server host (default: 0.0.0.0)MCP_SERVER_URL: MCP server URL (default: http://localhost:8000)AZURE_OPENAI_API_KEY: Azure OpenAI API key (required for agent integration)AZURE_OPENAI_ENDPOINT: Azure OpenAI endpoint (required for agent integration)AZURE_OPENAI_DEPLOYMENT: Azure OpenAI deployment name (required for agent integration)
Settings are automatically loaded from the .env file in the project root.
Models (appcrawler/config.py)
Data models for crawler configuration (using dataclasses):
AzureConfig: Azure OpenAI client configuration with API key, endpoint, and versionAppiumConfig: Appium server configuration with desired capabilities and server URLCrawlerSettings: Top-level crawler configuration combining Appium and Azure settings
These models are part of the appcrawler domain and define the configuration structure for the AppCrawler service.
Notes
- Logging is configured through Python's standard logging module; adjust log levels as needed.
- The server holds a single crawler instance. Call
cleanupbefore re-initializing with new settings. initialize_crawlerseeds the crawler with the bundled calculator example test case. Request it explicitly viaget_example_test_caseif you need the raw content.- Default task and test-generation prompts are available through
get_task_prompt,get_generate_test_case_prompt, orget_default_prompts;process_flowautomatically falls back to them when prompts are omitted. - Use
get_ui_dumpto capture the current UiAutomator hierarchy from a connected Android device via Appium. run_docker_automationbuilds and executes the bundled Docker workflow; ensure Docker is available on the host machine.- Ensure the Appium server is running and reachable from the MCP server host.
- Configuration models (
AppiumConfig,AzureConfig,CrawlerSettings) are defined inappcrawler/config.pyand are part of the crawler domain. - The MCP server imports configuration models from
appcrawler.config, maintaining proper separation of concerns. - For OpenAI Agents SDK integration, the MCP server must be configured to use SSE transport (not currently implemented in the default server).
- The
openai-agentspackage may not be publicly available on PyPI yet; agent integration is optional.
Dependencies
Core Dependencies (requirements.txt)
fastmcp>=0.1.0- FastMCP framework for MCP serversappium-python-client==2.11.1- Appium client for Pythonselenium>=4.0.0- Selenium WebDriveropenai>=1.77.0- OpenAI Python clientloguru>=0.7.3- Advanced loggingpydantic>=2.0.0- Data validation and settingspydantic-settings>=2.11.0- Environment variables with Pydanticpython-dotenv>=1.0.0- Environment variable managementopenai-agents>=0.5.0- OpenAI Agents SDK (optional, may not be available on PyPI yet)
Additional Dependencies (pyproject.toml)
mcp[cli]>=1.21.0- MCP Framework with CLI tools (if using pyproject.toml installation)
License
[Add your license information here]
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。