a

android-mcp

@hamen/android-mcp
0 Stars 235 次浏览 hamen 更新于 2026-08-23

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

npm node adb ci

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? } send input keyevent.
  • tap { x, y, serial? }
  • text { text, serial? } uses input text (spaces become %s).
  • startActivity { component, serial? } e.g. "org.example/.MainActivity".
  • screenshot { serial? } { mimeType: "image/png", base64 }.
  • uiDump { serial? } parsed uiautomator dump tree (text, contentDesc, resourceId, bounds).
  • findAndTap { text?, contentDesc?, serial? } finds the first matching node and taps its center.
  • listDevicesDetailed lists attached devices with model/manufacturer/sdk info.

Notes & limits

  • Screenshot and UI dump are periodic snapshots (no streaming yet).
  • UI dump depends on uiautomator being present on the device.
  • Prototype transport; you can wire in a richer MCP SDK without changing the ADB helpers.

Tests

npm test

相关 MCP 服务