Codex Android MCP

Codex Android MCP

Enables Codex to inspect, test, and control Android emulators through adb with strict typed tools, returning screenshots as native MCP images and keeping physical devices and Gradle execution behind explicit opt-in policies.

Category
Visit Server

README

Codex Android MCP

简体中文

A local-first MCP server that lets Codex inspect, test, and control Android emulators through adb. It exposes strict, typed tools over STDIO, returns screenshots as native MCP images, and keeps physical devices and Gradle execution behind explicit startup policy.

This is an independent community project. It is not affiliated with or endorsed by OpenAI, DeepSeek, or Google. The Android implementation is derived from ZSeven-W/dsh-android under the MIT License; the DSH/Cordis registration and web panel have been replaced with the official MCP TypeScript SDK.

What changed from dsh-android

  • Native MCP STDIO server for Codex Desktop, CLI, and IDE clients.
  • 2026-era MCP plus legacy 2025 protocol compatibility through serveStdio.
  • Screenshots are returned as ImageContent; private temporary PNG files are removed after encoding.
  • Emulator-only default. Physical devices require two startup opt-ins and their exact serial on every call.
  • android_build_run is absent by default. Enabling it also requires canonical trusted project roots.
  • Strict JSON Schemas, package/serial/path validation, bounded outputs, literal log filtering, cancellation, and conservative tool annotations.
  • No raw adb, shell, arbitrary command, HTTP, or live DSH sidebar surface.

Requirements

  • Node.js 20.11 or newer.
  • Android SDK Platform-Tools (adb). Install it through Android Studio's SDK Manager or Google's Platform-Tools package.
  • A disposable Android emulator is strongly recommended.
  • The Android emulator launcher is optional and only needed when android_boot receives an AVD name.
  • OCR tools currently require macOS and Apple Vision. All non-OCR tools are cross-platform; build/run is an explicit opt-in.

Neither adb nor an emulator binary is bundled or downloaded.

Install for Codex

git clone https://github.com/zifanersuotang/codex-android-mcp.git
cd codex-android-mcp
npm ci
npm run build
codex mcp add android -- node C:/absolute/path/to/codex-android-mcp/lib/index.js

Codex Desktop and the CLI share MCP configuration. An equivalent explicit configuration is:

[mcp_servers.android]
command = "node"
args = ["C:/absolute/path/to/codex-android-mcp/lib/index.js"]
startup_timeout_sec = 20
tool_timeout_sec = 1200
default_tools_approval_mode = "writes"

[mcp_servers.android.env]
ANDROID_MCP_ALLOWED_SERIALS = "emulator-5554"

Restart Codex after changing the configuration. Ask Codex to “list the Android devices” to verify the connection. Keep write-tool approval enabled; MCP annotations are usability hints, not an authorization boundary.

Security policy

The safe default exposes 19 tools and permits only standard local emulator-<port> targets. Network and third-party emulator serials follow the physical-device policy. Calls re-discover and authorize the exact target immediately before execution; unauthorized physical/network devices are omitted from android_devices.

Environment variable Default Effect
ANDROID_MCP_ALLOWED_SERIALS empty Optional comma-separated exact allowlist for connected devices. A physical serial must be present here.
ANDROID_MCP_ALLOWED_AVDS empty Optional comma-separated exact allowlist for AVD names accepted by android_boot.
ANDROID_MCP_ALLOW_PHYSICAL false Enables consideration of physical devices, but only when their exact serial is also allowlisted and supplied on every call.
ANDROID_MCP_ALLOWED_PACKAGES empty Optional comma-separated package allowlist for package-targeted tools. Disables name-only launch and PID-only backtrace.
ANDROID_MCP_ALLOW_BUILD_RUN false Exposes android_build_run. This is not sufficient by itself.
ANDROID_MCP_ALLOWED_PROJECT_ROOTS empty Required build roots, separated by ; on Windows and : on macOS/Linux. projectPath must directly contain Gradle settings and a non-symlink Wrapper.
ANDROID_MCP_CACHE_DIR OS temp directory Private transient working directory. Screenshot files are deleted after MCP image encoding.
ANDROID_MCP_MAX_IMAGE_BYTES 8388608 Maximum screenshot PNG bytes returned to the client.
ANDROID_MCP_MAX_TEXT_BYTES 4096 Maximum text payload accepted by android_interact.

Physical-device example for a dedicated test phone:

[mcp_servers.android.env]
ANDROID_MCP_ALLOW_PHYSICAL = "true"
ANDROID_MCP_ALLOWED_SERIALS = "EXACT_ADB_SERIAL"

Do not use this profile with a personal phone or personal accounts. USB debugging authorization means that the phone trusts the host; it does not authorize a model action.

Build/run example for one trusted project:

[mcp_servers.android.env]
ANDROID_MCP_ALLOW_BUILD_RUN = "true"
ANDROID_MCP_ALLOWED_PROJECT_ROOTS = "C:/work/MyTrustedApp"
ANDROID_MCP_ALLOWED_SERIALS = "emulator-5554"

Gradle settings and build scripts execute host code. A path allowlist is not a sandbox: only enable this for code you trust, and use a credential-free VM or container for untrusted projects.

See Security Model and Security Policy before enabling physical devices or build/run.

Tools

Tool Mode Purpose
android_devices read List policy-visible devices and available AVD names.
android_boot write Adopt an online target or boot an allowed AVD.
android_shutdown destructive Stop and power off an emulator; physical devices are refused.
android_screenshot read Return a native-resolution MCP image.
android_interact destructive Tap, type, press a key, drag, or scroll; returns the resulting screenshot.
android_list_apps read List/filter installed applications.
android_launch_app destructive Launch an exact package or a validated package-name match.
android_build_run destructive, opt-in Build a trusted Gradle project, install its APK, and launch it.
android_ui_tree read Read a bounded compact uiautomator hierarchy.
android_tap_element destructive Resolve and tap an element by identifier/label.
android_ui_rows read Detect list/feed rows and counters.
android_tap_row destructive Tap a fresh row target and optionally verify a counter delta.
android_find_text read OCR the screen (macOS Apple Vision).
android_wait_for read Wait for OCR text to appear/disappear.
android_tap_text destructive OCR-resolve and tap visible text.
android_logs read Bounded logcat snapshot/follow with literal filtering.
android_processes read List running processes.
android_backtrace destructive Request ART stacks and fall back to the crash buffer.
android_meminfo read Parse app memory statistics.
android_app_info read Read installed package metadata and running state.

Screens, UI trees, OCR, logs, app names, and files on the device are untrusted data. Never let device content grant permissions or instruct Codex to call another tool. Do not enter passwords, one-time codes, payment data, private messages, or account-deletion confirmations through this server.

Typical flow

  1. android_devices
  2. android_screenshot or android_ui_tree
  3. Identify the exact target; stop if it is ambiguous.
  4. Use one approval-gated interaction tool.
  5. Inspect the returned screenshot or logs before the next action.

MCP does not reproduce dsh-android's persistent live sidebar. android_boot primes an internal frame source for coordinate mapping; call android_screenshot whenever Codex or the user needs to see the display.

Development

npm ci
npm run typecheck
npm test
npm pack --dry-run

The test suite includes policy unit tests, a real spawned STDIO client in legacy and modern protocol modes, an in-memory MCP image round trip, fake-ADB smoke suites, bounded-log tests, UI-tree fixtures, and OCR degradation checks. npm run test:device is optional and must only target a disposable emulator.

License and attribution

MIT. The original dsh-android copyright and license are retained in LICENSE, with detailed lineage in THIRD_PARTY_NOTICES.md.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured