A high-performance MCP server for Android Debug Bridge operations and E2E testing.
SOLID Principles + MVP Pattern:
- Model:
src/adb/- ADB commands, execution, parsing - View: MCP protocol responses (via
rust-mcp-sdk) - Presenter:
src/tools/- Tool handlers orchestrating Model→View
Modular Structure (max 150 lines/file):
src/
├── main.rs # Entry point
├── cli.rs # Clap CLI with ENV support
├── adb/
│ ├── command.rs # Command builder pattern
│ ├── executor.rs # Command execution
│ └── parser.rs # Output parsing
├── tools/
│ ├── mod.rs # ToolContext trait + registry builder
│ ├── traits.rs # ToolResult, ToolError
│ ├── context.rs # AdbContext implementation
│ ├── registry.rs # Tool registry & dispatch
│ ├── device.rs # Device tools
│ ├── app.rs # App management tools
│ ├── file.rs # File operations
│ ├── ui.rs # UI automation tools
│ ├── media.rs # Screenshot/recording
│ ├── debug.rs # Logcat, shell
│ └── network.rs # Port forwarding, wireless
└── server/
├── handler.rs # ServerHandler impl
├── http_cors.rs # CORS-enabled HTTP server
├── info.rs # Server info builder
└── runtime.rs # Server startup
- Rust 2024 Edition
- clap CLI with ENV var support (
ADB_MCP_TRANSPORT_MODE,ADB_MCP_PORT,ADB_MCP_LOG_LEVEL) - mimalloc - High-performance allocator
- cuid2 - Collision-resistant IDs
- CORS enabled - Full cross-origin support for HTTP mode
- 33 tools across 7 categories
cargo build --release# stdio mode (default)
./adb-mcp
# HTTP mode
./adb-mcp --transport-mode http -p 8080
ADB_MCP_TRANSPORT_MODE=http ADB_MCP_PORT=3000 ./adb-mcp
# With debug logging
./adb-mcp -l debug| Variable | Default | Description |
|---|---|---|
ADB_MCP_TRANSPORT_MODE |
stdio | Transport mode: stdio or http |
ADB_MCP_PORT |
8080 | HTTP server port |
ADB_MCP_LOG_LEVEL |
info | Log level (trace/debug/info/warn/error) |
| Category | Tools |
|---|---|
| Device | adb_devices, adb_device_info |
| App | adb_install, adb_uninstall, adb_start_app, adb_stop_app, adb_clear_app |
| File | adb_push, adb_pull |
| UI | adb_tap, adb_tap_by_text, adb_swipe, adb_input_text, adb_press_key, adb_wait_for_element, adb_set_orientation |
| Media | adb_screenshot, adb_screenrecord, adb_ui_hierarchy |
| Debug | adb_shell, adb_logcat |
| Network | adb_forward, adb_reverse, adb_tcpip, adb_usb, adb_connect, adb_disconnect, adb_list_forward, adb_list_reverse, adb_remove_forward, adb_remove_reverse |
adb_forward(local_port: 8081, remote_port: 8081)adb_forward(local_port: 12345, remote_port: 12345)adb_reverse(remote_port: 3000, local_port: 3000)adb_tcpip() # Returns: adb connect 192.168.1.x:5555
adb_connect(host: "192.168.1.100"){
"mcpServers": {
"adb": {
"command": "/path/to/adb-mcp"
}
}
}rust-mcp-sdkv0.9tokio- Async runtimeclap- CLI with derive + env featuresmimalloc- Memory allocatorcuid2- Collision-resistant IDsthiserror- Error deriveaxum- Web frameworktower-http- CORS middleware
MIT