phone-agent-mcp
This MCP server controls a connected Android phone through an AI agent, enabling natural language task automation, device interaction, and persistent memory management.
Task Automation: Execute multi‑step tasks from natural language goals (e.g., "Open WeChat and send hello to John"). Supports asynchronous execution via the MCP Tasks extension, with real‑time progress updates over SSE. Manage tasks with
abort_task,get_task_result(per‑step details optional), andget_latest_task.Device Interaction: Capture PNG screenshots (
take_screenshot) and retrieve device status (get_device_status) including model, brand, and OS version.Memory Management: Search the agent’s persistent memory by keywords (
search_memory), save semantic memories with optional tags (save_memory), and delete entries by ID (delete_memory).Integration: Accessible via Streamable HTTP (SSE) or stdio, compatible with MCP clients like Qoder and OpenClaw.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@phone-agent-mcp open WeChat and send a message to John saying I'm running late"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
phone-agent-mcp
Local MCP Server — Exposes the AI Agent capabilities from the WebADB browser page as MCP Tools, allowing external AI clients such as OpenClaw / Qoder to invoke them via the standard MCP protocol.
Architecture Overview
External AI Client (Qoder / OpenClaw / Browser-side MCP Client)
│
│ Streamable HTTP (SSE stream, preferred) or stdio (JSON-RPC 2.0)
▼
┌───────────────────┐ WebSocket ┌──────────────────────────────┐
│ phone-agent-mcp │ ◄──────────────────► │ Mobile AI Agent Browser Page│
│ (Node.js Process)│ ws://localhost │ (https://mobile-ai-use.xyz) │
│ │ :7788 │ │
│ ┌──────────────┐ │ │ ┌─────────────────┐ │
│ │ McpServer │ │ callBrowser() │ │ MCP Relay │ │
│ │ (HTTP+stdio) │ │ ──── tool/args ────► │ │ (WS Client) │ │
│ │ │ │ ◄─── result ──────── │ │ │ │
│ │ 9 Tools │ │ │ │ Agent Scheduler │ │
│ │ │ │ progress ◄───────── │ │ Tool Executor │ │
│ └──────────────┘ │ │ └─────────────────┘ │
└───────────────────┘ └──────────────────────────────┘MCP Layer: Built on
@modelcontextprotocol/sdk'sMcpServer, providing two transport channels:Streamable HTTP (default port
7789,/mcpendpoint): SSE streaming output for results and intermediate progress, supports multiple sessions — the preferred channelstdio: Traditional transport compatible with local CLI clients such as Qoder / OpenClaw
Relay Layer: Embedded
wsWebSocket Server (default port7788), forwarding tool call requests to the MCP Relay in the browser pageProgress Reporting: Supports the MCP
notifications/progressprotocol, pushing Agent thinking/execution progress to clients in real timeTasks Extension: Supports the MCP Tasks extension (
io.modelcontextprotocol/tasks), making long-running tasks asynchronous — clients can poll status, receive progress, and recover after disconnection
Related MCP server: scrcpy-mcp
Prerequisites
Node.js ≥ 18
pnpm (recommended, the project's unified package manager)
Mobile AI Use browser page open and running (
https://mobile-ai-use.xyz), with the MCP Relay status indicator in the top bar showing green (connected)
Quick Start
# 1. Enter the mcp-server directory
cd mcp-server
# 2. Install dependencies
pnpm install
# 3. Build (generates dist/server.js)
pnpm run build
# 4. Start the server
pnpm startDevelopment mode (runs TypeScript directly without building):
pnpm run devAfter successful startup, the console outputs:
[phone-agent-mcp] WebSocket relay on ws://localhost:7788
[phone-agent-mcp] MCP server ready (stdio transport)
[phone-agent-mcp] Streamable HTTP on http://localhost:7789/mcpEnvironment Variables
Variable | Default | Description |
|
| WebSocket relay port |
|
| Streamable HTTP port (also serves the |
|
| ADB over WebSocket binary bridge port |
|
| Local adb server host (control plane |
|
| Local adb server port (control plane |
|
| Bridge/control-plane bind address; a token is required when non-loopback |
| (empty) | Shared token enforced on non-loopback binds (used by both bridge and control plane) |
ADB over WebSocket Bridge
Besides direct WebUSB, the web page can also treat a remote/networked phone as a first-class device: the host running phone-agent-mcp connects directly to the phone's adbd (ip:port, i.e. adb tcpip mode) and bridges the raw ADB stream to the browser over a WebSocket. The browser reuses AdbDaemonWebSocketDevice to produce a standard Adb instance, so screen mirroring / AI Agent / workflows all work with zero downstream changes.
Remote phone adbd (adb tcpip 5555)
▲ direct TCP to <ip:port>, raw ADB bytes relayed both ways
│
phone-agent-mcp ── binary bridge WS (:7790) ──► Browser AdbDaemonWebSocketDeviceControl-plane endpoints (reuse the 7789 httpServer)
Endpoint | Method | Body | Success response | Description |
| GET | — |
| List devices currently known to the local adb server |
| POST |
|
| Make the host |
| POST |
|
|
|
Error conventions: unauthorized 401; missing param / malformed JSON 400; wrong method 405 (with Allow header); unknown path 404; no local adb (not on PATH) 503; any other failure 500.
Bridge endpoint (7790)
The browser connects via ws://<host>:7790/?serial=<serial>[&token=<token>]; the bridge parses serial as ip:port, opens a direct TCP connection to the phone's adbd and relays bytes bidirectionally (the browser performs the CNXN/AUTH handshake itself). serial must be ip:port; USB serials are not supported (use WebUSB instead). Only one active bridge per serial is allowed; duplicate connections are rejected. Close codes: 4401 invalid token / 4400 missing serial or serial is not ip:port / 4409 device busy / 4502 failed to connect to adbd (refused / timeout / unreachable) / 4503 adbd connection errored or closed.
Prerequisites
adb is on the host
PATH(adb versionworks).The remote phone has been switched with
adb tcpip 5555and is reachable at itsip:port. The random TLS port of Android 11+ "Wireless debugging" is not supported by the bridge yet.The browser uses its own ADB key, so the phone shows an "Allow USB debugging" prompt on the first bridge; confirm it on the phone.
Security
localhost needs no token: when
PHONE_AGENT_BIND_HOSTis loopback (default), the control plane only accepts requests whose peer is a loopback address, and the bridge needs no token.Non-loopback enforces a token: binding to a non-loopback address requires
PHONE_AGENT_ADB_TOKEN; otherwise the startup guardassertBridgeAuththrows and aborts startup. Afterwards the control plane requiresAuthorization: Bearer <token>or?token=<token>, and the bridge requires?token=<token>.Mixed content: if the page is served over
https, the browser blocksws://; configurewss://for the bridge (TLS terminated by a reverse proxy).
Registered Tools
Tool | Permission | Timeout | Description |
| Write | Configurable | Run an AI Agent task on the connected phone with a natural language goal (supports async execution via the Tasks extension) |
| Write | 10s | Abort the currently running Agent task |
| Read | 10s | Get detailed results (including steps) of a completed task by task ID |
| Read | 10s | Get the result of the most recent Agent task in the current conversation |
| Read | 30s | Take a screenshot of the connected phone screen, returns a PNG image |
| Read | 15s | Get device information (model, brand, OS version, etc.) |
| Read | 10s | Search the Agent's persistent memory store by keyword |
| Write | 10s | Save a semantic memory entry to the memory store |
| Write | 10s | Delete a memory entry by ID |
run_agent_task in Detail
Parameter | Type | Required | Description |
|
| Yes | Natural language task goal, e.g. "Open WeChat and send 'Hello' to Zhang San" |
|
| No | Maximum execution time in milliseconds, default 1,200,000 (20 minutes) |
The Agent will automatically plan execution steps and achieve the goal through screen visual recognition and touch control. During execution, thinking/tool calls/step results are pushed in real time via MCP notifications/progress.
MCP Tasks Extension (Async Long-Running Tasks)
run_agent_task is registered as a task-based tool (taskSupport: 'optional'), supporting the MCP Tasks extension (io.modelcontextprotocol/tasks) to address blocking and connection interruption issues with long-running operations.
Workflow
Client Server
│ tools/call run_agent_task │
│ params: { arguments, task: { ttl } } │
├──────────────────────────────────────────────►│ createTask → returns immediately
│ CreateTaskResult { task: { taskId, │ continues executing in background
│ status: 'working', pollInterval } } │
│◄──────────────────────────────────────────────┤
│ tasks/get { taskId } ◄── poll ───► │ notifications/tasks/status proactive push
│ … status: working (statusMessage=progress) … │
│ tasks/result { taskId } │ after task completes
│◄────────────── CallToolResult ────────────────┤Task States
State | Meaning |
| Task is executing; |
| Task completed successfully; final result available via |
| Task failed (including browser not connected, timeout, etc.); result contains error details |
| Client cancelled via |
Server Capability Declaration
"capabilities": {
"tasks": {
"list": {},
"cancel": {},
"requests": { "tools": { "call": {} } }
}
}Supported endpoints: tasks/get (check status), tasks/result (get result), tasks/list (list tasks), tasks/cancel (cancel).
Key Parameters
Parameter | Value | Description |
TTL |
| How long results are retained after task completion; auto-cleaned after expiry |
pollInterval |
| Recommended client polling interval |
Backward Compatibility
New clients (declare tasks capability): Call with
taskparameter → immediately receivetaskId, polltasks/get/ fetch result viatasks/resultLegacy clients (no
taskparameter): Server automatically falls back to internal polling, synchronously waits and returnsCallToolResultdirectly — behavior identical to the previous version
Note:
tasks/cancelonly marks the task as cancelled and stops result writing; to actually interrupt execution on the phone, call theabort_tasktool separately.
Configuration for AI Clients
Streamable HTTP (Recommended)
Clients supporting remote/HTTP connections (including browser-side MCP clients) can point directly to the URL:
{
"mcpServers": {
"phone-agent": {
"url": "http://localhost:7789/mcp"
}
}
}Verify connectivity:
curl -N -X POST http://localhost:7789/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'The mcp-session-id response header is the session ID, which must be included in subsequent requests; the response body is an SSE stream (text/event-stream).
stdio (Qoder / Claude Desktop / OpenClaw Local Integration)
Add the following to the client's MCP configuration file:
{
"mcpServers": {
"phone-agent": {
"command": "node",
"args": ["/path/to/mcp-server/dist/server.js"],
"env": {
"PHONE_AGENT_WS_PORT": "7788"
}
}
}
}OpenClaw
mcp_servers:
phone-agent:
command: node
args:
- /path/to/mcp-server/dist/server.js
env:
PHONE_AGENT_WS_PORT: "7788"After configuration, all 9 phone Agent tools listed above will be available in the AI client — invoke them directly to control the phone.
Streamable HTTP Transport Details
Streamable HTTP is the standard MCP transport protocol. The server outputs intermediate progress notifications and final results sequentially within the same HTTP response via an SSE stream, eliminating the need for additional client polling:
Endpoint | Method | Purpose |
| POST | Client message entry point (initialize / tools/call / tasks/* etc.), response is an SSE stream |
| GET | Opens a dedicated SSE stream to receive server-initiated pushes (e.g. |
| DELETE | Close the session |
Streaming Output Content
During execution of long-running tools (e.g. run_agent_task), the response stream pushes in real time:
notifications/progress: Agent thinking/execution progress (when client declaresprogressToken)notifications/message: Fallback channel for progress log downgradesnotifications/tasks/status: Task state changes (working/completed/failed)
The end of the stream contains the final CallToolResult or CreateTaskResult (task mode).
Session Management
Stateful mode: Server generates a sessionId, delivered via the
mcp-session-idresponse header withinitialize; subsequent requests must include itOne McpServer instance per session; tool handlers share a global browser relay and task store (
taskStoreis cross-session — tasks can continue to be polled after disconnect/reconnect)CORS is open: Browser-side MCP clients can access directly
Connection Flow
Start mcp-server:
pnpm start— launches stdio / Streamable HTTP dual channels and the WS relayOpen the browser page: Navigate to the WebADB page, ensuring the device is connected
Confirm Relay connection: The Relay status indicator in the top bar turns green; console outputs
Browser connectedConnect MCP client:
HTTP clients point to
http://localhost:7789/mcp(includemcp-session-idafter initialize)Local CLI clients launch via stdio:
node dist/server.js
Invoke tools: Requests are forwarded via WebSocket to the browser for execution; results and intermediate progress are streamed back via SSE / stdio
Project Structure
mcp-server/
├── src/
│ └── server.ts # Main server: McpServer + WS + 9 tool registrations
├── dist/
│ └── server.js # Build output
├── package.json
├── tsconfig.json # TypeScript config (ES2022 / NodeNext)
└── pnpm-lock.yamlTech Stack
Component | Version | Purpose |
| ^1.12.0 | MCP server framework (McpServer + StdioServerTransport) |
| ^8.18.0 | WebSocket server, relays browser connection |
| ^4.4.3 | Tool parameter validation and schema declarations |
| ~5.8.3 | Type safety |
| ^4.19.0 | Run TS directly in development mode |
Design Highlights
Dual transport channels: Streamable HTTP (SSE streaming for results and intermediate progress, multi-session) and stdio (local CLI compatible) coexist; tool registration logic is unified by the
createPhoneAgentServer()factory functionCross-session task store sharing:
InMemoryTaskStoreis a global singleton — clients can continue polling non-expired tasks viatasks/get/tasks/resultafter reconnecting (new session)Single browser connection: Only one browser WS connection is accepted at a time; new connections replace old ones
Request-response matching: WS responses are routed to the corresponding pending Promise via the
idfieldTimeout fallback: Each tool call has an independent timeout; returns an error message on timeout instead of hanging
Dual-channel progress: Prefers
notifications/progress(requires client to declareprogressToken), falls back tonotifications/message(logging); in task mode, also writestask.statusMessageand pushesnotifications/tasks/statussimultaneouslySilent fault tolerance: Progress push failures do not interrupt task execution; background writes are safely skipped after task cancellation/TTL cleanup
Browser offline hint: Returns a friendly error "Browser not connected" when the WS is not connected
Available Tools
9 toolsabort_taskB
Abort the currently running Agent task.
Inputs: no named parameters.
delete_memoryA
Delete one memory entry (semantic or episodic) by its id.
Inputs: id (required).
get_device_statusARead-only
Get information about the connected phone device (model, brand, OS version, etc.).
Inputs: no named parameters.
get_latest_taskARead-only
Get the most recent Agent task result from the current conversation.
Inputs: no named parameters.
get_task_resultARead-only
Get the detailed result of a completed Agent task by its task ID.
Inputs: taskId (required), includeSteps.
run_agent_taskADestructive
Run an AI Agent task on the connected phone. The agent will plan and execute multiple steps to achieve the goal using screen vision and touch controls.
Inputs: goal (required), timeoutMs.
save_memoryB
Save a semantic memory (reusable knowledge) into the phone agent's persistent memory.
Inputs: title (required), content (required), keywords.
search_memoryBRead-only
Search the persistent memory of the phone agent by keywords. Returns semantic memories (learned experience) and/or episodic records (task history).
Inputs: query (required), type, limit.
take_screenshotARead-only
Take a screenshot of the connected phone screen. Returns a PNG image.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools are clearly distinct: run_agent_task, get_task_result, get_latest_task, take_screenshot, get_device_status, abort_task, and the three memory tools all have obvious purposes. get_task_result and get_latest_task could be mildly confused (both retrieve task results), and save_memory vs search_memory vs delete_memory are clear. No significant overlap issues.
All tools follow a consistent verb_noun pattern throughout: delete_memory, run_agent_task, get_task_result, get_latest_task, take_screenshot, get_device_status, save_memory, search_memory, abort_task. Every name is snake_case with a clear action verb followed by a target noun, showing strong uniformity.
Nine tools is well within the ideal 3-15 range for a phone agent MCP server. Each tool corresponds to a distinct capability: task management (run/get/latest/abort), memory management (save/search/delete), device inspection, and screen capture. None feels redundant or unnecessary.
The server covers core workflows: device inspection, task execution/retrieval/abort, screenshots, and memory operations. However, there are no explicit memory update operations (only save/delete/search), and no direct touch-input tool outside of the agent task abstraction, which may be fine given the agent-centric design but leaves some gaps for low-level control.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Melaya is a remote MCP server. It gives an assistant hands on your own Android phone and browser: it reads the screen through the accessibility tree, then taps, types and navigates inside the apps and sites you allow-list, with no per-app API. It also builds, schedules and runs agent pipelines across 6k+ connected tools. OAuth 2.1, nothing to install.
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseAqualityCmaintenanceA MCP server that enables AI assistants to control Android devices via ADB, supporting device info, screen control, input simulation, app management, shell execution, file transfer, and UI parsing.20MIT
- AlicenseAqualityBmaintenanceMCP server that gives AI agents full vision and control over Android devices via ADB and scrcpy. Supports screenshots, input, apps, UI automation, shell, files, and clipboard.38392 npm136MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that wraps Android ADB functionality into AI assistant tools, enabling device management, shell execution, file operations, app management, media capture, and log analysis via natural language.23 npm3MIT
- AlicenseNot gradedqualityAmaintenanceAn MCP server that enables AI agents to control Android and iOS devices via natural language, using platform tools like adb and simctl.1,561 npm58Apache 2.0