Android Camera MCP
Turns an Android 10+ phone into a LAN-first remote camera for AI agents: lists connected devices and per-camera capabilities, captures stills and fast previews with configurable downscaling, crops ROIs phone-side, switches lenses, controls optical/digital zoom, torch, flash, autofocus and manual focus distance, exposure compensation, applies capture presets, and runs on-device ML Kit OCR/barcode/scene analysis — all without cloud dependency.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Android Camera MCP
Turn any Android phone into a private, LAN-first remote camera for AI agents via the Model Context Protocol (MCP).
Android Camera MCP connects a Kotlin / CameraX Android foreground service agent to a decoupled Python asyncio Camera Gateway and MCP Server, giving multimodal AI assistants such as Antigravity, Claude Desktop / Claude Code, Cursor, Kiro, and custom LLM agents real-world visual perception, offline on-device ML Kit OCR/barcodes, and hardware camera controls (snapshot capture, phone-side ROI crop, optical/digital zoom, lens switching, torch, flash, autofocus/manual focus, and exposure compensation) over your local network — with zero cloud dependency.
Guide Site · PyPI · MCP Registry · Download APK · Quick Start · Install · MCP Tools · Architecture · Documentation
Key Features
LAN-First & Private: All control messages and JPEG frames stay strictly inside your local network — no cloud relays, accounts, or subscriptions.
Decoupled Gateway Daemon: Run
android-camera-mcp gatewayonce (:8765for phones,127.0.0.1:8766for local MCP clients). Restarting Claude Desktop/Cursor/Antigravity or running multiple AI clients simultaneously never drops the phone connection.Screen-Off & Background Capture: CameraX is bound to an Android
LifecycleServiceforeground service (FOREGROUND_SERVICE_TYPE_CAMERA) with wake and Wi-Fi locks so the phone keeps answering capture requests with the screen off or after rotation.LLM-Ready Smart Downscaling & Upright Rotation: Captures default to
1600pxon the long edge (640pxforcamera_preview) with upright pixel rotation (no broken EXIF orientation), plusmax_dimension=0for full sensor resolution.Per-Camera Hardware Controls: Advertises real capabilities per physical/logical camera — zoom ratio (including ultra-wide
<1.0x), torch, flash, autofocus, Camera2 manual focus distance, and EV steps.Built-In Resilience: Connection-scoped device registry, mutex-serialized JSON+JPEG framing, 10s heartbeats with ack, exponential backoff reconnect (immediate when Wi-Fi returns), per-device FIFO command queue, per-command deadlines enforced on the phone, and a capture watchdog that reopens a stuck camera.
Fast Preview & Temporary Streaming:
camera_previewgrabs a frame from the live camera feed without the still-capture sequence;camera_stream_*pushes low-FPS frames that stop on duration, idle timeout, thermal limit or disconnect.Traceable: every command is logged on the phone (SQLite log database with a log screen, crash report) and on the gateway with request ID and queue / phone / transfer timing.
On-device OCR / barcodes / scene stats:
camera_analyzeruns ML Kit on the phone and returns text boxes + exposure/focus hints without uploading a large image.On-device crop / ROI:
crop_x/y/w/h(0..1) crop on the phone before transfer; combine withzoom_ratioandmax_dimensionso the AI never downloads a full multi‑MP frame just to inspect a corner.Capture presets:
general,document,macro,low_lightvia thepresetargument oncamera_capture(explicit params always win).mDNS discovery: gateway advertises
_android-camera-mcp._tcpwhenzeroconfis installed; the app has a Discover button.Phone log upload: unsynced SQLite rows are pushed to the gateway (
~/.android-camera-mcp/device-logs/).One-Scan APK Releases: Every build is compiled and tested in GitHub Actions with an auto-generated QR code, SHA-256 checksum, and Release Notes.
Related MCP server: Droidline
Use Cases
Hardware & Electronics Bench: Let your AI inspect PCBs, soldering joints, multimeter screens, or wiring diagrams using your phone's macro/telephoto lens and torch.
3D Printing & Lab Monitoring: Take on-demand high-resolution stills of a print bed or workspace without running a continuous video stream.
Document & Whiteboard Capture: Snap crisp, upright photos of whiteboards, handwritten notes, or receipts straight into your AI context.
Physical-World AI Agents: Give local coding or robotics agents an inexpensive, high-quality optical sensor by reusing any spare Android 10+ phone.
Architecture
flowchart LR
A["Android Camera Agent<br/>(Kotlin + CameraX LifecycleService)<br/>Capture, ROI Crop & ML Kit OCR"]
B["Camera Gateway Daemon<br/>(android-camera-mcp gateway)<br/>TCP :8765 & Local API 127.0.0.1:8766"]
C["MCP Server (stdio)<br/>(uvx android-camera-mcp)<br/>15 Typed Camera Tools"]
D["AI Agents / MCP Clients<br/>(Antigravity, Claude, Cursor, Kiro)"]
A -- "Persistent TCP :8765<br/>Framed JSON + Binary JPEG" --> B
B -- "Local Control API :8766" --> C
C -- "MCP over stdio" --> DQuick Start
1. Install the Android App (APK)
Option A — Scan QR Code / Download from GitHub Releases (Recommended)
Scan the QR code below on your Android phone (or open the Releases page):
Install
android-camera-agent-debug.apk(requires Android 10 / API 29+).
Option B — Build Locally
./gradlew assembleDebug
# Output: app/build/outputs/apk/debug/app-debug.apk2. Start the Camera Gateway Daemon
Requires Python 3.10+ (mcp>=1.2,<2).
Option A — Install from PyPI / uvx (Recommended)
# Install with pip (add [mdns] for automatic LAN discovery)
pip install "android-camera-mcp[mdns]"
# Start the gateway daemon (phone TCP :8765, local API 127.0.0.1:8766)
android-camera-mcp gateway
# Or run directly via uvx without creating a virtualenv
uvx --from "android-camera-mcp[mdns]" android-camera-mcp gatewayOption B — Run from Source
git clone https://github.com/sinhsac/android-camera-mcp.git
cd android-camera-mcp/server
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[mdns]"
# Start the gateway daemon (phone TCP :8765, local API 127.0.0.1:8766)
python main.py gateway
# Optional: verbose debug logs
python main.py gateway -v3. Configure Your MCP Client (Claude Desktop / Cursor / Kiro / Antigravity)
Add android-camera to your MCP client configuration using uvx:
{
"mcpServers": {
"android-camera": {
"command": "uvx",
"args": ["android-camera-mcp"]
}
}
}Or if running from a local git clone:
{
"mcpServers": {
"android-camera": {
"command": "/absolute/path/to/android-camera-mcp/server/.venv/bin/python",
"args": ["/absolute/path/to/android-camera-mcp/server/main.py", "mcp"]
}
}
}Antigravity CLI shortcut:
agy mcp add android-camera uvx android-camera-mcp
Windows (from source): Set"command"toC:\\path\\to\\android-camera-mcp\\server\\.venv\\Scripts\\python.exe.
Keepandroid-camera-mcp gatewayrunning in the background; if stopped, MCP tools cleanly returnGATEWAY_UNAVAILABLE.
4. Connect Your Phone & Capture with AI
Open Android Camera Agent on your phone and grant Camera permission (and Notifications on Android 13+).
Enter your computer's LAN IP address and port
8765, then tap Connect.Verify locally with Test Capture, or ask your AI assistant:
"List my connected Android cameras and inspect their supported controls."
"Take a quick preview shot to check framing, then capture a sharp photo at 2x zoom."
"Turn on the torch, capture a close-up photo, then turn the torch off."
Tips for long-running background use: Keep the phone plugged into power while connected (the service holds a wake lock and Wi-Fi lock), and disable aggressive battery optimization for the app on Samsung/Xiaomi/Oppo devices so Android does not kill the foreground service.
Available MCP Tools
The MCP server exposes 15 tools via FastMCP:
Category | Tool | Description | Key Parameters |
Discovery |
| List connected Android agents, online/stale status, active camera, lenses, stream, battery/thermal | — |
Discovery |
| Inspect per-camera capabilities (zoom/EV ranges, flash, manual focus), features, queue and pending commands |
|
Discovery |
| Live phone state: idle/capturing/streaming, battery, temperature, thermal status, uptime |
|
Analysis |
| Offline on-device ML Kit OCR, QR/barcodes, and exposure/focus hints (compact JSON + normalized crop boxes, no large JPEG by default) |
|
Capture |
| Capture an upright JPEG still ( |
|
Capture |
| Fast low-resolution frame from the live feed ( |
|
Stream |
| Start a temporary low-FPS stream with duration and idle auto-stop |
|
Stream |
| Newest stream frame; optionally wait for one newer than |
|
Stream |
| Stop the stream (idempotent) |
|
Controls |
| Set zoom ratio on the active camera (clamped to supported bounds, including ultra-wide |
|
Controls |
| Toggle continuous flashlight/torch on or off |
|
Controls |
| Set flash mode for subsequent captures |
|
Controls |
| Configure |
|
Controls |
| Set EV compensation steps or omit to reset to auto exposure ( |
|
Controls |
| Switch active camera/lens by |
|
CLI Reference
Command | Options | Description |
|
| Run the persistent TCP device gateway and local control API |
|
| Run the MCP |
|
| Print installed package version |
Optional environment variables:
ANDROID_CAMERA_API_HOST(default127.0.0.1) andANDROID_CAMERA_API_PORT(default8766). When running from a source checkout,python main.py ...remains fully supported.
Pacing & Error Handling
Queue, not reject: calls for one phone run one at a time in arrival order; a capture within ~1.5s of the previous one waits for the cooldown. Only more than 4 waiting calls return
RATE_LIMITED.Deadlines: each command carries
timeout_ms; the phone abandons work past it, and a still that never arrives (20s) makes the phone reopen the camera.Structured errors:
GATEWAY_UNAVAILABLE,DEVICE_OFFLINE,REQUEST_TIMEOUT,CAMERA_BUSY,UNSUPPORTED_CONTROL,INVALID_ARGUMENT,STREAM_NOT_ACTIVE,THERMAL_LIMIT— AI agents never hang on an unreachable phone.
Debugging slow or failed calls
Phone: the Activity log card shows each command (
-> capture [req-…],<- capture [req-…] OK 975ms (wait 0, camera 820, encode 140)), reconnects and camera errors. Every line (DEBUG to ERROR) is stored in an on-phone SQLite database; All logs opens a log screen with level / text / request-id filters, live updates and Share/Copy. A crash report is imported into the same database and shown on the next launch.adb logcat -s 'CamAgent.*'shows the same lines.Gateway: one line per command with the same request ID and
total / queue / device / transfertimes. Add--log-file gateway.log, and-vfor frame-level detail.MCP server: one line per tool call. Use
"args": ["android-camera-mcp", "mcp", "--log-file", "/path/to/mcp.log"]withuvx(or[".../main.py", "mcp", "--log-file", ".../mcp.log"]from source), since MCP clients often hide stderr.
LAN security
There is no pairing or authentication (ADR-008). Anyone who can reach port 8765 can register a fake camera, so:
Run the gateway only on a trusted home/lab network.
Allow
8765on the private network profile only. Windows:netsh advfirewall firewall add rule name="Camera Gateway" dir=in action=allow protocol=TCP localport=8765 profile=private.Keep the local API on
127.0.0.1:8766(the default). Do not bind it to0.0.0.0.Do not forward either port on the router.
Wire Protocol Overview
The Android agent and Camera Gateway communicate over persistent TCP (:8765) with length-prefixed framing:
+-----------------------+------------------+----------------------------+
| Length (4B big-endian)| Kind (1B) | Payload (Length - 1 bytes) |
+-----------------------+------------------+----------------------------+
Kind 0x01 = UTF-8 JSON control frame (register, heartbeat/ack, command, response)
Kind 0x02 = Raw binary JPEG payload (immediately follows capture response)Full specification: docs/PROTOCOL.md.
Testing
cd server
pip install -e ".[dev,mdns]"
python -m pytest -qTests verify frame decoding, reconnect race handling, slow/late JPEG correlation, framing-error recovery, the FIFO queue and its overflow limit, stream frames/stop, preview fallback for older apps, local Gateway API roundtrips over real TCP sockets, and package/CLI/MCP Registry metadata consistency.
Project Structure
android-camera-mcp/
├── .github/workflows/
│ ├── android-apk.yml # CI: Android APK build, QR Release & Python server tests
│ └── publish-mcp.yml # CD: Publish PyPI package & Official MCP Registry via OIDC
├── app/ # Android Camera Agent (Kotlin, CameraX, LifecycleService)
│ └── src/main/java/com/androidcameramcp/agent/
│ ├── agent/ # Registration, heartbeat + health, command dispatch with deadlines, frame streamer
│ ├── camera/ # CameraX stills + live analysis frames, Camera2 capabilities, controls, JPEG encoder
│ ├── log/ # TraceLog + LogStore: logcat, SQLite log database, crash report
│ ├── service/ # Foreground LifecycleService owning camera, wake/Wi-Fi locks, network callback
│ ├── transport/ # Framed TCP client with write mutex & network-aware backoff reconnect
│ └── ui/ # MainActivity: status, gateway, camera and activity-log cards
├── server/ # Python Camera Gateway + MCP Server (PyPI: android-camera-mcp)
│ ├── android_camera_mcp/ # Installable Python package
│ │ ├── cli.py # CLI entrypoint (`gateway` and `mcp` subcommands)
│ │ ├── gateway/ # TCP listener, connections, registry, sessions, rate limit, local API
│ │ ├── mcp_server/ # FastMCP tool definitions & local gateway API client
│ │ └── protocol/ # Framing codec & control message schemas
│ ├── main.py # Backwards-compatible source-checkout entrypoint
│ └── tests/ # Automated pytest suite over real TCP sockets
├── server.json # Official MCP Registry manifest
├── glama.json # Glama MCP directory manifest
├── smithery.yaml # Smithery stdio/uvx manifest
├── docs/ # Architecture, protocol, MCP contract & roadmap
├── PROJECT_CONTEXT.md # Canonical architecture & AI coding agent context
└── LICENSE # MIT LicenseDocumentation
Architecture Overview — System components, gateway daemon design, and reliability model
Wire Protocol Specification — TCP framing, registration, heartbeats, and JPEG payloads
MCP Tool Contract — Tool schemas, error codes, and agent guidelines
Android App Guide — Permissions, foreground service, and camera controls
Server README — Python server setup, CLI subcommands, and tests
Engineering Decisions — Technical trade-offs and constraints
Roadmap — Planned milestones from MVP to streaming, pairing security, and mDNS
Roadmap
Phase 0 & 1: End-to-end LAN snapshot pipeline (
Android → TCP → Gateway → MCP → Image)Phase 2: Per-camera capability discovery, zoom/torch/flash/focus/exposure/lens controls, foreground
LifecycleService, decoupled gateway daemon, automated server tests, and CI QR APK Releases (v0.2.0)Phase 3 (
v0.3.0): Live-framecamera_preview, bounded low-FPS temporary streaming, battery/thermal reportingPhase 4 (
v0.3.0–v0.4.0): FIFO command queue, phone-side deadlines, capture watchdog, network-aware reconnect, trace logging & phone log sync, Material 3 app UI (device pairing tokens deferred per ADR-008)Phase 5 (
v0.4.0–v0.5.0): mDNS/NSD automatic gateway discovery, multi-device registry, capture presets, phone-side ROI crop, on-device ML Kitcamera_analyze, PyPI package (android-camera-mcp), and Official MCP Registry listing (io.github.sinhsac/android-camera-mcp)
Contributing & License
Contributions, bug reports, and feature requests are welcome via Issues and Pull Requests.
Licensed under the MIT License — see LICENSE for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Let Claude, ChatGPT and other agents use your Android phone: see the screen, tap, type, open apps.
Turns a phone into a camera+Bluetooth remote so AI assistants can see and control any PC.
Cloud Android devices for AI agents: install an APK, read the screen, tap, type, read logcat.
Give your AI agent a real cloud Android phone: push APKs, drive it, get screenshots and logs.
Related MCP Servers
- AlicenseAqualityDmaintenanceGives PC AI agents real-world senses by connecting to an Android phone's camera, sensors, and files over local Wi-Fi without cloud relay or ADB.731 PyPI2MIT
- AlicenseNot gradedqualityAmaintenanceLets AI agents see and use a real Android phone over Wi-Fi: read the screen, find elements by text or ID, tap, type, swipe, take screenshots and read notifications, without ADB or root.576MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to see and control Android devices through ADB and scrcpy, supporting screenshots, input, app management, UI automation, shell/file access, and audio/video streaming.1,154 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to see and control Android devices over ADB and scrcpy—taking screenshots, tapping, swiping, typing, launching apps, inspecting UI elements, transferring files, streaming video/audio, and running shell commands. It uses scrcpy's control protocol for fast input and near-instant screenshots, with ADB fallback when scrcpy is unavailable.1,154 npmMIT