Android AI Optimizer
Enables AI agents to audit, debloat, and tune non-rooted Android devices via ADB, including package removal, AppOps/standby restrictions, ART dexopt, and reversible rollback.
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 AI Optimizer (for Google Antigravity)
A zero-dependency, safety-first MCP server and 5-stage ADB optimization pipeline that lets AI agents audit, debloat, and tune non-rooted Android devices with 1-click rollback.
Interactive Guide & Benchmarks • Quickstart • Architecture • Real-Device Benchmarks • Safety & Rollback • FAQ
Use at your own risk. Modifying system packages and Android framework settings via ADB can disrupt device features or cause bootloops if critical OEM services are removed improperly. This project enforces Audit-First Mode, pre-flight backups, UAD-NG cross-checking, offline bootloop blocklists, a PreToolUse safety hook, and 1-click rollback, but you remain responsible for reviewing every proposed action before approving execution.
⚡ What Is Android AI Optimizer?
Android AI Optimizer is an open-source Model Context Protocol (MCP) toolkit for Google Antigravity (IDE, CLI, and App) and compatible MCP clients that automates non-root Android performance tuning via ADB (Android Debug Bridge).
Unlike blind shell scripts or risky "booster" apps, this project enforces a strict Audit → Snapshot → UAD-NG Cross-Check → Human Approval → Execute → Benchmark workflow. Every mutating MCP tool defaults to dry_run=true, validates inputs inside a zero-dependency Python 3.10+ MCP server (mcp_server/server.py), and logs exact undo commands for 100% reversible changes.
Key Capabilities
Zero-Dependency Scoped MCP Server: Built on Python 3.10+ stdlib (newline-delimited JSON-RPC 2.0 over stdio) with 10 scoped tools and zero raw shell access.
Hallucination-Proof Debloating: Cross-references installed packages against the live Universal Android Debloater Next Generation (UAD-NG) database (
uad_lists.json), surfacesneededBydependency warnings, and enforces a local safety/hard_blocklist.json.SDK-Aware AOSP Tuning: Automatically adapts commands across Android 9–15 (
pm art dexopt-packages -r bg-dexopton Android 14+ / SDK 34+,cmd game seton Android 13+ / SDK 33+, Phenotype-safe Cached Apps Freezer persistence on Android 11+, and exactappopsstate restoration).Wired, Wireless & On-Device (Termux + Shizuku): Auto-discovers
adbonPATHor standard SDK paths, works over Android 11+ Wireless Debugging, and supports PC-less on-device execution via Termux + Shizuku (rish).
Comparison vs Alternatives
Capability | Android AI Optimizer (MCP) | Manual UAD-NG GUI | Raw Shell / Batch Scripts | Play Store "Boosters" |
Zero-Shell Scoped MCP ( | ✅ JSON-RPC 2.0 stdio | ❌ GUI only | ❌ Unrestricted shell | ❌ No ADB access |
Bootloop Shield + | ✅ | ⚠️ Warnings only | ❌ None | ❌ Kills active caches |
Wired, Wireless & Termux + Shizuku | ✅ PC & PC-less | ❌ PC only | ⚠️ Manual setup | ❌ No ADB bridge |
1-Click State + AppOps Rollback | ✅ | ⚠️ Reinstall only | ❌ Manual undo | ❌ None |
Related MCP server: shapeyourphone
📊 Verified Real-Device Benchmark (Oppo A57)
Tested live on a consumer budget phone (OPPO CPH2387 / Oppo A57) running Android 14 (SDK 34), ColorOS V14.0.0, MediaTek Helio G35 (mt6765), and ~3.88 GB RAM (13.62 GB free on /data).
System Resource Impact
Metric | Before | After | Net Delta |
Free RAM | 1,118.3 MB | 1,643.9 MB | +525.7 MB (+47.0%) |
Used RAM | 3,892.2 MB | 3,766.0 MB | -126.2 MB |
Active Service Records | 166 | 148 | -18 background services |
Bloatware Removed (User 0) | 0 | 36 / 37 removed | 1 OS-protected package throttled via AppOps |
ART | 40 | 50+ | Partial |
App Cold-Start Latency (am start -W)
Target App | Before (ms) | After (ms) | Delta |
YouTube ( | 3,475 ms | 3,082 ms | -393 ms faster |
Instagram ( | 3,178 ms | 3,075 ms | -103 ms faster |
WhatsApp ( | 3,325 ms | 3,928 ms* | *Measured immediately post- |
Real-World Findings:
Eliminated
com.heytap.mcs(which was firing 2,307 wakeups/alarms) and the Facebook background updater suite (7m30sbackground CPU +37swakelocks).Throttled background sensor/RAM hogs (
com.meesho.supply, shopping apps, and social media) viaappops+rarestandby buckets while keeping WhatsApp, ProtonVPN, Truecaller, and alarms unrestricted.When ColorOS 14 blocked
com.nearme.instant.platformwithDELETE_FAILED_INTERNAL_ERROR, the pipeline automatically handled the failure and restricted it via Module A AppOps throttling instead.Note: On the Helio G35 (
mt6765),pm art dexopt-packages -r bg-dexopthit its 600s timeout after compiling key apps (speed-profilerose from 40 to 50) and gracefully continued to targetedspeed-profilecompilation andsm fstrim.
🏗️ 4-Layer Safety Architecture
+------------------------------------------------------------------------+
| LAYER 1: Orchestration & Guardrails (Google Antigravity) |
| - Root AGENTS.md & .agents/rules/ (Audit-First, Human Approval Gate) |
| - .agents/skills/ (android-audit, android-debloat, android-tune) |
| - .agents/hooks.json (PreToolUse hook blocking bootloop & placebo cmds) |
+-----------------------------------+------------------------------------+
| MCP Protocol (JSON-RPC 2.0 / stdio)
+-----------------------------------v------------------------------------+
| LAYER 2: Zero-Dependency Scoped MCP Server (mcp_server/server.py) |
| - 10 scoped, input-validated tools (zero raw shell access) |
| - Enforces hard_blocklist.json + snapshot gate + dry_run=true default |
| - Optional companion: FlashZ/adb-mcp (.agents/mcp_config.adbmcp.example)|
+---------------+-----------------------------------+--------------------+
| USB / Wireless ADB | Local JSON
+---------------v--------------------+ +-----------v--------------------+
| LAYER 3: Target Android Device | | LAYER 4: Safety Knowledge |
| - PackageManager (`pm`) & ART | | - Runtime-synced UAD-NG |
| - ActivityManager (`am`) & AppOps | | (`cache/uad_lists.json`) |
| - Settings & Storage (`sm fstrim`) | | - `safety/hard_blocklist.json` |
| - Kernel cgroup v2 Freezer | | - `logs/rollback_log.json` |
+------------------------------------+ +--------------------------------+🚀 Quickstart (Wired & Wireless ADB)
Prerequisites
Python 3.10+ (zero
pip installdependencies required)Android SDK Platform-Tools (
adb) installed — see docs/SETUP_ADB.mdGoogle Antigravity (or any MCP-compatible AI coding agent)
1. Clone the Repository
git clone https://github.com/HamzaShaikhAI/android-ai-optimizer.git
cd android-ai-optimizer2. Connect Your Android Device
Option A: Wired USB (Recommended for First Run)
Enable Developer options on your phone (Settings → About phone → tap Build number 7 times).
Enable USB debugging.
ColorOS / RealmeUI / OxygenOS: Also toggle Disable permission monitoring ON in Developer options.
MIUI / HyperOS: Also enable USB debugging (Security settings).
Plug in via USB, tap Allow on the RSA debugging prompt, and verify:
adb devices -l
Option B: Wireless ADB (Android 11+ — No Cable Needed)
Connect your PC and phone to the same Wi-Fi network.
Enable Wireless debugging in Developer options → tap Pair device with pairing code.
Pair once and connect:
adb pair <ip_address>:<pairing_port> adb connect <ip_address>:<connect_port>
3. Run the 5-Stage Pipeline in Google Antigravity
Open the repository folder in Google Antigravity. .agents/mcp_config.json automatically registers mcp_server/server.py. Use the prompts in prompts/ or run the CLI tools directly:
Stage 1 — Read-Only Audit:
python scripts/audit_device.pycollects SDK level, OEM profile, RAM pressure, battery/alarm wakeups,/datafree space, Cached Apps Freezer support, and ART dexopt state.Stage 2 — Pre-Flight Backup:
python scripts/backup_packages.pysaveslogs/packages_backup.txt,logs/settings_backup.txt, and initializeslogs/rollback_log.json.Stage 3 — UAD-NG Check & Safe Debloat:
python scripts/sync_uad.py+python scripts/check_packages.pyclassify bloatware withneededBydependency warnings;python scripts/debloat_packages.pyexecutes approved User-0 removals.Stage 4 — SDK-Aware Tuning:
python scripts/tune_performance.pyapplies approved modules (AppOps + standby buckets, Cached Apps Freezer if kernel supports it, ARTbg-dexopt+ targetedspeed-profile,0.5xanimations,disable_window_blurs, Private DNS, and Android 12+ Game Mode).Stage 5 — Benchmark Report:
python scripts/benchmark_device.pygenerates a before/afterlogs/optimization_report.md.
Supported Devices & OEM Quirks
OEM / OS | Required Developer Option Tweak | Critical Keep / Notes |
Oppo / Realme / OnePlus (ColorOS / RealmeUI / OxygenOS) | Toggle Disable permission monitoring ON | OS-protected |
Xiaomi / Redmi / Poco (MIUI / HyperOS) | Enable USB debugging (Security settings) | Never remove |
Samsung (One UI) | Standard USB Debugging | Keep |
Pixel / Motorola / Nothing (AOSP) | Standard USB Debugging | Minimal bloat; focus on AppOps, Cached Apps Freezer, ART |
See docs/OEM_NOTES.md, docs/TROUBLESHOOTING.md, and docs/MYTHS_AND_TRAPS.md for full details.
🛡️ Safety Guardrails & 1-Click Rollback
Every change is logged locally in logs/rollback_log.json and logs/removed_packages.txt (excluded from Git via .gitignore).
Restore a single removed app:
python scripts/restore_package.py --package <package_name>Revert everything (removed packages, settings, Private DNS, Game Mode, and exact prior AppOps states):
python scripts/restore_package.py --undo-allBuilt-in Guardrails:
Enforces safety/hard_blocklist.json in scripts, the MCP server, and .agents/hooks.json.
Blocks destructive placebo commands (
cmd package compile -m everything -a,adb shell su, non---user 0uninstalls).Automatically skips banking, UPI, authenticator, alarm, messaging, VPN, and accessibility packages during AppOps throttling (
never_throttle_keywords).Keeps
pm trim-caches 100Gopt-in (--trim-caches) so healthy devices don't needlessly drop warm app caches.
❓ Frequently Asked Questions
Does this require root or unlocking the bootloader? No. All optimizations use standard, non-root Android Debug Bridge (ADB) commands. Your warranty, Play Integrity, and banking/UPI apps remain intact.
Will this work on Samsung, Xiaomi, OnePlus, Oppo, and Pixel?
Yes. The pipeline automatically detects the OEM and Android SDK version (SDK 28+) and applies OEM-specific rules documented in docs/OEM_NOTES.md.
Can the AI accidentally uninstall a critical system app and cause a bootloop?
The MCP server and scripts enforce safety/hard_blocklist.json, block raw shell execution, require a pre-flight backup snapshot, cross-check UAD-NG dependency warnings (neededBy), and default all mutating tools to dry_run=true until you explicitly approve.
Running Tests
python -m unittest discover -s tests -v📄 License, Security & Privacy
License: Released under the MIT License. Package classifications are dynamically fetched at runtime from UAD-NG into gitignored
cache/.Security: Read our Security Policy for responsible disclosure and MCP threat-model details.
Privacy: Read our Privacy Policy — 100% local execution, zero telemetry.
Contributing: See CONTRIBUTING.md or submit device benchmarks and blocklist updates via GitHub Issues.
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.
Cloud Android devices for AI agents: install an APK, read the screen, tap, type, read logcat.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Give your AI agent a real cloud Android phone: push APKs, drive it, get screenshots and logs.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to directly control Android devices via Termux, providing 120+ tools for screen manipulation, file management, app control, and system operations with layered loading and security gating.4MIT
- AlicenseBqualityBmaintenanceEnables AI agents to debloat, harden privacy, tune settings, and rebuild the home screen of a non-rooted Android phone over adb, using tiered bloat lists, plain-language preferences and time rules. Every change is previewed, requires explicit owner approval, and is undoable with full restore.33MIT
- AlicenseBqualityBmaintenanceEnables AI agents to inspect and control Android devices through ADB, including shell commands, logcat, UI automation, app management, screenshots, and file transfer, even inside Termux/proot without a native adb binary.41MIT
- AlicenseAqualityBmaintenanceEnables AI agents to perform exploratory Android QA over adb through ten typed, validated tools — UI dumps, taps, text input, key presses, screenshots, logcat, APK installs, app launches and configured test suites — behind a command allowlist, sandboxed paths, dry-run mode and a JSONL audit log, so agents can test an app without getting a shell.10MIT