New mixins: - connectivity.py: adb_connect, adb_disconnect, adb_tcpip, adb_pair, device_properties (batch getprop) - settings.py: settings_get/put, wifi/bluetooth/airplane toggles, screen_brightness, screen_timeout, notification_list, clipboard_get, media_control Also fixes clipboard_set false-positive on devices where cmd clipboard returns exit 0 but has no implementation.
2.6 KiB
2.6 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
mcadb - A FastMCP server exposing Android Debug Bridge (ADB) functionality through the Model Context Protocol. Enables AI assistants to automate Android devices via screenshots, input simulation, app control, UI inspection, file transfer, and shell commands.
Commands
# Install dependencies
uv sync
# Run the server locally
uv run mcadb
# Run directly with uvx (no install needed)
uvx mcadb
# Development dependencies
uv sync --group dev
# Linting and formatting
uv run ruff check src/
uv run ruff format src/
# Type checking
uv run mypy src/
# Docker (requires privileged mode for USB access)
docker compose up --build
Architecture
Modular MCPMixin architecture with 65 tools across 8 domain mixins:
src/server.py: FastMCP app andADBServerclass (thin orchestrator inheriting all mixins)src/config.py: Persistent singleton config (~/.config/adb-mcp/config.json)src/models.py: Pydantic models (DeviceInfo,CommandResult,ScreenshotResult)src/mixins/base.py: Core ADB execution withrun_adb(),run_shell(), and injection-saferun_shell_args()usingshlex.quote()src/mixins/devices.py: Device discovery, info, logcat, rebootsrc/mixins/connectivity.py: TCP/IP connect/disconnect, wireless pairing, device propertiessrc/mixins/input.py: Tap, swipe, scroll, keys, text, clipboard, shell commandsrc/mixins/apps.py: Launch, close, install, intents, broadcastssrc/mixins/screenshot.py: Screen capture, recording, display settingssrc/mixins/ui.py: Accessibility tree dump, element search, text pollingsrc/mixins/files.py: Push, pull, list, delete, existssrc/mixins/settings.py: System settings, radio toggles, brightness, notifications, clipboard read, media control
Key Patterns
- All tools use
run_shell_args()(injection-safe) exceptshell_commandwhich intentionally usesrun_shell()for raw commands - Developer mode tools are gated by
is_developer_mode()checks and tagged withtags={"developer"} - Destructive operations use
ctx.elicit()for user confirmation @mcp_tool()and@mcp_resource()decorators fromfastmcp.contrib.mcp_mixin
MCP Client Configuration
{
"mcpServers": {
"mcadb": {
"command": "uvx",
"args": ["mcadb"]
}
}
}
Device Requirements
- ADB installed and accessible in PATH
- USB debugging enabled on Android device
- For Docker:
--privilegedflag and/dev/bus/usbvolume mount required