phone-mcp-server
Enables AI agents to control Android phones via MCP and HTTP. Supports screen capture, taps, swipes, text input, and app management.
README
phone-mcp-server
Standalone MCP + HTTP server for controlling Android phones from any AI agent.
Works with Claude Desktop, Claude Code, OpenAI Codex CLI, GPT agents (via OpenAI API), Gemini, LangChain, AutoGen, CrewAI, Open Interpreter, or any HTTP client.
How It Works
┌──────────────────────────────────────────────────┐
│ Any AI Agent │
│ │
│ Claude ──── MCP (stdio) ──┐ │
│ Codex ──── MCP (stdio) ───┤ │
│ ▼ │
│ ┌──────────────┐ │
│ │ MCP Server │ │
│ │ mcp_server │ │
│ └──────┬───────┘ │
│ │ │
│ GPT ──── HTTP ────┐ │ │
│ Gemini ── HTTP ───┤ │ │
│ Custom ── HTTP ───┤ │ │
│ ▼ ▼ │
│ ┌─────────────────┐ │
│ │ phone_control │ │
│ │ (core package) │ │
│ └────────┬────────┘ │
│ │ │
│ ADB ────┤──── Appium (optional) │
│ │ │
├───────────────────────┼──────────────────────────┤
│ Android Emulator │ │
└───────────────────────┴──────────────────────────┘
Requirements
- Python 3.10+
- Android SDK Platform Tools (
adbon PATH) - A running Android emulator or device
Optional (for Unicode text input and WebView support):
- Appium (
npm install -g appium) - Appium Python client (
pip install Appium-Python-Client)
Install
git clone https://github.com/Ctrl-Creeper/phone-mcp-server.git
cd phone-mcp-server
pip install .
# With Appium support
pip install ".[appium]"
Quick Start
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"phone-control": {
"command": "python",
"args": ["/path/to/phone-mcp-server/mcp_server.py"]
}
}
}
Claude Code
claude mcp add phone-control python /path/to/phone-mcp-server/mcp_server.py
OpenAI Codex CLI
codex --mcp-config codex-mcp.json
Create codex-mcp.json:
{
"mcpServers": {
"phone-control": {
"command": "python",
"args": ["/path/to/phone-mcp-server/mcp_server.py"]
}
}
}
OpenAI API / GPT Agents
Start the HTTP server, then fetch the tool schema:
python http_server.py
import requests, openai
tools = requests.get("http://localhost:8080/openai/tools").json()
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Open Settings on the phone"}],
tools=tools,
)
tool_call = response.choices[0].message.tool_calls[0]
result = requests.post("http://localhost:8080/openai/call", json={
"name": tool_call.function.name,
"arguments": tool_call.function.arguments,
}).json()
Google Gemini
import requests, google.generativeai as genai
tools_schema = requests.get("http://localhost:8080/openai/tools").json()
# Convert to Gemini format
gemini_tools = []
for t in tools_schema:
f = t["function"]
gemini_tools.append(genai.types.Tool(
function_declarations=[genai.types.FunctionDeclaration(
name=f["name"],
description=f["description"],
parameters=f["parameters"],
)]
))
model = genai.GenerativeModel("gemini-2.0-flash", tools=gemini_tools)
chat = model.start_chat()
response = chat.send_message("Open the camera app")
# Execute the function call
fc = response.candidates[0].content.parts[0].function_call
result = requests.post("http://localhost:8080/openai/call", json={
"name": fc.name,
"arguments": dict(fc.args),
}).json()
LangChain
import requests
from langchain_core.tools import StructuredTool
def phone_action(action: str, **kwargs):
return requests.post(f"http://localhost:8080/phone/{action}", json=kwargs).json()
# Or dynamically load from schema
tools_schema = requests.get("http://localhost:8080/openai/tools").json()
Any HTTP Client (curl)
# Capture UI hierarchy
curl -s localhost:8080/phone/capture -d '{"mode":"hierarchy"}' | jq .
# Tap element #3
curl -s localhost:8080/phone/tap -d '{"element":3}' | jq .
# Type text
curl -s localhost:8080/phone/type -d '{"text":"hello world"}' | jq .
# Get device info
curl -s -X POST localhost:8080/phone/device_info | jq .
# Fetch OpenAI tool schema
curl -s localhost:8080/openai/tools | jq .
Exposed Tools (15)
| Tool | Description |
|---|---|
phone_capture |
Capture screen (hierarchy / screenshot / both) |
phone_tap |
Tap by element index or coordinates |
phone_double_tap |
Double-tap |
phone_long_press |
Long-press (configurable duration) |
phone_swipe |
Swipe by direction or coordinates |
phone_type |
Type text (Unicode via Appium hybrid) |
phone_clear_text |
Clear text field |
phone_set_text |
Clear + type new text |
phone_keyevent |
Send key event (BACK, HOME, ENTER, etc.) |
phone_launch_app |
Launch app by package name |
phone_stop_app |
Force-stop app |
phone_list_apps |
List installed apps |
phone_current_app |
Get foreground app |
phone_device_info |
Device model, screen size, Android version |
phone_wait |
Wait N seconds |
Configuration
| Environment Variable | Description | Default |
|---|---|---|
HERMES_PHONE_BACKEND |
adb, hybrid, or noop |
adb |
ANDROID_SERIAL |
Device serial (auto-detected if one device) | — |
APPIUM_PORT |
Appium server port (hybrid backend) | 4723 |
PHONE_POLICY_PATH |
Path to phone-policy.yaml | auto-search |
MCP_SERVER_PORT |
MCP SSE server port | 8765 |
PHONE_HTTP_PORT |
HTTP server port | 8080 |
Policy Engine
The phone policy (phone-policy.yaml) controls what actions the agent can perform on which apps. Place it at ~/.hermes/phone-policy.yaml or set PHONE_POLICY_PATH.
See the virtual-phone-agent repo for the full policy reference and examples.
Security
- All ADB commands use argument-list subprocess (no shell injection)
install_apkandshellare blocked over HTTP API- Policy engine enforces per-app action restrictions
- Phone content is untrusted data — never treated as instructions
- Input sanitization: shell metachar rejection, keycode allowlist, coordinate bounds, text length limits
License
AGPL-3.0
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。