android-mcp
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"android-mcp": {
"args": [
"--yes",
"tsx",
"/home/ivan/code/android-mcp/src/server.ts"
],
"command": "npx",
"cwd": "/home/ivan/code/android-mcp",
"type": "stdio"
}
}
}
服务介绍
Android MCP
Friendly MCP stdio server that chats with Android devices over ADB using @devicefarmer/adbkit, speaking newline-delimited JSON-RPC via @modelcontextprotocol/sdk (no Content-Length headers needed). Plug it into Cursor/Claude MCP and start poking at devices.
What is this?
- MCP transport that forwards handy ADB actions (tap, text, screenshot, UI dump, etc).
- Uses newline-delimited JSON on stdin/stdout; one request per line, one response per line.
- Prototype-friendly: swap out the minimal JSON-RPC loop for a full MCP SDK later if you want.
Requirements
- ADB server running on your host (
adb start-server). - Node.js 18+.
- At least one device or emulator attached (
adb devices).
Quickstart
git clone <repo-url> android-mcp
cd android-mcp
npm install
npm run dev
Keep adb devices happy, then fire JSON-RPC lines at stdin and watch stdout for replies.
MCP config (Cursor/Claude)
Example ~/.cursor/mcp.json entry:
{
"mcpServers": {
"android-mcp": {
"type": "stdio",
"command": "npx",
"args": ["--yes", "tsx", "/home/ivan/code/android-mcp/src/server.ts"],
"cwd": "/home/ivan/code/android-mcp"
}
}
}
Tools exposed
selectDevice{ serial }set default device for subsequent calls.keyEvent{ keyCode, serial? }sendinput keyevent.tap{ x, y, serial? }text{ text, serial? }usesinput text(spaces become%s).startActivity{ component, serial? }e.g."org.example/.MainActivity".screenshot{ serial? }{ mimeType: "image/png", base64 }.uiDump{ serial? }parseduiautomator dumptree (text, contentDesc, resourceId, bounds).findAndTap{ text?, contentDesc?, serial? }finds the first matching node and taps its center.listDevicesDetailedlists attached devices with model/manufacturer/sdk info.
Notes & limits
- Screenshot and UI dump are periodic snapshots (no streaming yet).
- UI dump depends on
uiautomatorbeing present on the device. - Prototype transport; you can wire in a richer MCP SDK without changing the ADB helpers.
Tests
npm test