Android computer use for AI agents over ADB: one MCP server shared by Claude Code, Codex and Antigravity
pip install nexus-android==0.9.7 Copy PIP instructions
Built and tested on a Samsung Galaxy Fold (SM-F971B, One UI) with a Windows PC. Other Android phones with USB debugging should work but have not been tested. Everything sent to the client is in English: server instructions, tool descriptions and tool reports (results, refusals, errors). Part of the Nexus family: NexusWindows (Claude · Codex · Antigravity), NexusBrowser (repo), NexusAndroid (repo). Project page: julienpiron.fr/nexusandroid.
claude mcp add nexus-android --scope user -- uvx nexus-android Then ask your agent: "Look at my phone and tell me what is on the screen."
[mcp_servers.nexus-android] command = "uvx" args = ["nexus-android"] Antigravity, Claude Desktop, Cursor and other JSON clients { "mcpServers": { "nexus-android": { "command": "uvx", "args": ["nexus-android"] } } } If adb is not on the PATH, set NEXUS_ANDROID_ADB to its full path in the server's environment. Typing accents and emoji needs the scrcpy server (Genymobile, Apache 2.0, version 5.0.1 pinned): the first time an agent types such text, the server downloads it from the official scrcpy release on GitHub, checks its SHA-256 against the value written in the code and keeps it in ~/.nexus/nexus-android/tools (install.ps1 fetches it ahead of time). If the download is impossible (offline, proxy), accented text is refused with a message saying where to put the file; it is never replaced by other text. ASCII typing works without it.
flowchart LR A["Claude Code"] --> S B["Codex"] --> S C["Antigravity"] --> S S["nexus-android
MCP server (Python)"] -->|"ADB over USB or local Wi-Fi"| P["Android phone
(no app, no root)"] S -.->|"shared lock, screen-awake state"| L[("~/.nexus")] look returns a screenshot plus the numbered UI tree; act runs a batch of gestures, re-reading the screen before each one and reporting what really happened. Messages, notifications, contacts and settings are read through Android's own providers and dumpsys, never by scraping the screen.
Each agent has its own desktop computer use, but none of the three clients has a built-in tool for a phone. One server avoids maintaining the same ADB access three times, and lets the three agents share one lock, one screen-awake session and the same safeguards.
Google Messages stores RCS messages in Android's messaging provider, like MMS, so the server reads them without going through the screen. An RCS group only has an encoded address there: the server works out its members and names the sender of each received message. A conversation archived or trashed in Google Messages stays readable and is labelled as hidden in the app.
Reads are fast: every adb shell content query starts a Java process on the phone (about 1 s), so at the first read the server pushes a 20 KB helper (phone/NexusQuery.java, built into nexus-query.dex) to /data/local/tmp and starts it once with app_process under the shell identity, as scrcpy does: no app to install, no permission beyond ADB's. It queries the providers the way Android's own content command does, read-only (query only), and serializes the rows itself with length-prefixed values, so a message text can never pose as an extra row. Each start draws a random token that goes into the socket name and comes back in every answer; any other server is refused. It answers only connections from the shell or root user (adbd, checked by the kernel) and stops after 10 minutes without a request. If the helper cannot run, reads fall back to adb shell with the same results; there, a read whose row numbers or row count (checked against the same read reduced to _id) do not add up is refused rather than shown.
The same helper reads the screen: it opens one accessibility connection (UiAutomation, what uiautomator dump opens and closes on every call) and keeps it, so look gets the UI tree, the screenshot (JPEG made on the phone) and the screen state in one exchange. It is read-only (no gesture, no global action, no typing) and leaves the user's own accessibility services running. Android allows only one such connection at a time: the helper is shared by every agent, hands it back before any uiautomator dump fallback, on its own after 45 s without a screen read, and right after reading a protected (banking or identity) app, so other tools (Appium, uiautomator2) can take it. The element list, its numbering, code masking and the refusal rules are the same as with uiautomator dump.
Measured on a Samsung Galaxy Fold: messages over USB through the shared daemon, the other rows over Wi-Fi:
Threat model for outward actions (sending, calling, paying, publishing, transferring): the agent must never be able to make an outward action leave that differs from the one the user approved. The approved action has one canonical identity: the foreground app, what the elements of the UI tree say in document order (their text, or a keyed seal of the raw text when it is masked; not their exact position, so a 4-pixel shift or the keyboard opening does not void it), and the complete target of the gesture (the element that receives the tap with its resource id, bounds and drawing order, the tap point, the start and end of a swipe, the direction of a scroll, the field that has the focus for a key). The contract sits at the boundary of each physical injection: every tap (each tap of a double tap, on a quick reading that does not wait for the screen to settle, or no second tap), every swipe of a scroll (judged where the finger lands, on what it actuates there), every submit key (alone in its step) is sent right after its own fresh reading of the screen, judged on it, and compared with the approved identity; any difference refuses it. The token is bound to that identity only; the readable summary (recipients, content, attachments) is shown with it. A swipe or drag is judged on one reading for both ends. type only types into an editable field that has the focus, and pastes any control character (line break, tab) as text, never as a key. What the UI tree does not describe (a target found only by OCR, a drawn surface over the target or the recipient, a drawn surface without tree text in the header) is never bound to an accord: such an outward action is refused, the user does it; a video or photo preview beside a send button and a recipient that the tree describes does not block. Limit, stated plainly: a screen that changes in the few milliseconds between that last reading and the ADB injection is beyond what an ADB tool can see.
Unlocking again and again while an agent works is tedious, but a phone used to pay must not stay unlocked. So, at the first gesture (act, launch, draft) on a phone the user has unlocked, the server saves the screen timeout (screen_off_timeout) and raises it to 5 minutes, a delay Android counts again from every gesture; phone shows until when. If the server is killed, the screen still turns off (and locks) at most 5 minutes after the last gesture. While the agent only looks, a screen that is on gets a wake-up key every 3 minutes (no visible effect), so it does not turn off during a long observation.
About 2 minutes after the last gesture of any agent, the original timeout is restored and the screen is turned off, which locks the phone again. If the user is holding the phone at that moment, or changed the timeout themselves, the screen is left alone. The original value is saved once (~\.nexus\nexus-android\awake.json) and shared by all servers under the common lock: one save, one restore, never the raised value taken for the original. After a crash, the next server to start restores it. The server never unlocks a phone that Android keeps locked. NEXUS_ANDROID_AWAKE_IDLE (seconds, default 120) changes the delay; NEXUS_ANDROID_KEEP_AWAKE=0 turns it off.
An alternative to uvx: one local environment, registered in the clients found on the PC, with the scrcpy server fetched ahead of time.
Prerequisites: Windows, PowerShell 7, uv and the Android Platform Tools (winget install Google.PlatformTools). On the phone: Developer options → USB debugging.
git clone https://github.com/pironjulien/NexusAndroid cd NexusAndroid pwsh -NoProfile -File install.ps1 # environment, scrcpy server, Codex/Antigravity registration, tests pwsh -NoProfile -File install.ps1 -Live # plus a run on the connected phone (types then clears a draft SMS, never sends) What the script does (safe to run again, for example after git pull):
Each client then starts its own server over stdio. They share the phone lock and the screen-awake state through ~\.nexus; for a single process shared by all clients, see Shared daemon.
From then on, nexus-android finds the phone on the local Wi-Fi. Since One UI does not announce the phone over mDNS, the server records its Wi-Fi address and the wireless debugging port every time it is plugged in over USB. This port changes after a reboot or a network change: plugging in over USB once is then enough. The last known address is tried first, then mDNS; only when the PC is on the same network does the server look for the new port, checking with an ADB handshake before connecting. When the phone cannot be found, the server does not search the Wi-Fi again for 2 minutes (a cable plugged in is still seen at once). The cable takes priority when it is plugged in. NEXUS_ANDROID_SERIAL forces a specific device, by serial number or ip:port address.
No shared Wi-Fi network (office PC on Ethernet only, with a Wi-Fi card): turn on the phone's hotspot and connect the PC to it, then, with the cable plugged in once, run adb tcpip 5555. The server records the phone's hotspot address and finds it there after the cable is removed. TCP mode lasts until the phone restarts (or adb usb). Raise the PC's Wi-Fi interface metric if its internet traffic should keep going through Ethernet rather than the phone's mobile data.
Not encrypted. Unlike wireless debugging (paired, TLS), adb tcpip 5555 is classic ADB over plain TCP: the traffic, screenshots and messages included, can be read on that network, and the port stays open on it. Use it only on the phone's own hotspot or another network you control, and turn it off afterwards with adb usb.
By default each client starts its own nexus-android process. To run a single process for all of them, start the server in HTTP mode:
$env:NEXUS_MCP_TOKEN = " " # or NEXUS_MCP_TOKEN_FILE = path of a file holding it nexus-android --http 16180 It serves MCP Streamable HTTP on 127.0.0.1 only (default port 16180), at http://127.0.0.1:16180/mcp, and refuses any request without the header Authorization: Bearer (HTTP 401); it does not start without a token. Point each client at that URL with that header. Each MCP session keeps its own [N] numbering and conversation list; the ADB link and the phone lock are shared. Starting the daemon (at logon, for example) is up to you: install.ps1 does not set it up. The token keeps a misconfigured client or a stray session from driving the phone; it is no protection against malicious software running on the same PC, which can reach the phone directly through ADB (see SECURITY.md).
NexusAndroid runs entirely on your PC and talks to your phone over ADB (USB cable or local Wi-Fi). It has no account, no telemetry, no analytics and no cloud relay. Its only internet request is the one-time download of the pinned scrcpy server from GitHub, the first time accented text is typed (skipped when install.ps1 already fetched it).
Questions or concerns: open an issue, or see SECURITY.md for private reports.
Install Node.js first. With Python and the locked packages already available locally, run:
pwsh -NoProfile -File test.ps1 # ruff, pyright and the unit tests, offline, no phone needed The check never downloads Python, packages or Pyright: uv is forced offline, automatic Python downloads are disabled, and Pyright runs from its bundled JavaScript using the installed Node.js. Missing Python or an incomplete dependency cache causes a clear failure. Each checkout keeps its test environment outside the source tree.
On a new machine or after a lockfile change, prepare the cache separately while online (the CI does this before its offline check):
$env:UV_PROJECT_ENVIRONMENT = Join-Path $env:TEMP 'nexus-android-prepare' uv sync --frozen --python 3.14 # explicitly online preparation, including development and build dependencies pwsh -NoProfile -File test.ps1 -Python 3.14 -Python 3.12, 3.13 or 3.14 selects an already installed interpreter and a separate test environment. -Full additionally runs the existing real-phone scenarios; the phone must be reachable and unlocked.
MIT. Not affiliated with Google, Samsung, Anthropic, OpenAI or Genymobile.
All 2 files in this release have provenance metadata.
mcp mcp-server android adb computer-use ai-agents claude codex antigravity
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
All 2 files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Oct 19, 2026 2 release files Change of provenance




