-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
134 lines (96 loc) · 4.55 KB
/
Copy pathREADME
File metadata and controls
134 lines (96 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Android MCP Server
This is a Docker-based Model Context Protocol (MCP) server that allows n8n to remotely control one or more Android devices over Tailscale using ADB. The server has Tailscale and ADB built in, so you only need to provide a Tailscale auth key to get started.
## Features
- **No Setup Required**: Tailscale and ADB are pre-installed in the Docker container
- **Multiple Device Support**: Control any number of Android devices on your Tailscale network
- **n8n Integration**: Works seamlessly with n8n's MCP Client Tool node
- **Full ADB Capability**: Access all ADB features remotely through the MCP interface
## Quick Start
1. Clone this repository
2. Add your Tailscale auth key to `docker-compose.yml`
3. Build the image (first time only):
```bash
docker-compose -f docker-compose.yml -f docker-compose.build.yml build
```
4. Start the container:
```bash
docker-compose up -d
```
That's it! The MCP server will start, connect to Tailscale, and be ready to communicate with your Android devices.
## Docker Compose Files
This project uses multiple Docker Compose files for better compatibility:
- `docker-compose.yml` - Main configuration file
- `docker-compose.build.yml` - Build configuration (use when building the image)
- `docker-compose.override.yml` - Contains device mappings and container name
## Device Setup
For each Android device you want to control:
1. Install Tailscale on the device from the Google Play Store
2. Log in to your Tailscale account
3. Note the device's Tailscale IP address (usually starts with 100.x.y.z)
4. Enable Developer Options on the device
5. Enable USB Debugging in Developer Options
6. Connect the device to your computer via USB
7. Run the following command to enable remote ADB:
```bash
adb tcpip 5555
```
8. You can now disconnect the USB cable
## Connecting from n8n
1. In n8n, add the "MCP Client Tool" node
2. Set the SSE Endpoint URL:
- For the default device: `http://android-mcp-server:3001/sse`
- For a specific device: `http://android-mcp-server:3001/sse/100.x.y.z` (replace with the device's Tailscale IP)
3. Save the node and test the connection
## Available Tools
The MCP server provides the following tools to n8n workflows:
- `takeScreenshot`: Captures a screenshot from the device
- `tapScreen`: Taps at specified coordinates
- `swipeScreen`: Performs a swipe gesture
- `sendText`: Types text on the device
- `pressKey`: Presses a system key (home, back, etc.)
- `launchApp`: Launches an application
- `getSensorData`: Retrieves data from device sensors
- `getDeviceInfo`: Gets device information
- `listInstalledApps`: Lists installed applications
- `executeShellCommand`: Runs a custom shell command
## Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `TS_AUTHKEY` | Tailscale auth key (required) | "" |
| `DEFAULT_PHONE_IP` | Default Android device Tailscale IP | 100.100.100.100 |
| `PORT` | MCP server port | 3001 |
## API Endpoints
- `/sse` - MCP Protocol endpoint (default device)
- `/sse/:device` - MCP Protocol endpoint (specific device)
- `/devices` - List all connected devices
- `/connect/:device` - Connect to a new device
- `/status` - Server status including Tailscale and ADB info
- `/health` - Health check endpoint
- `/tailscale/status` - Tailscale status information
- `/adb/restart` - Restart the ADB server
## Troubleshooting
- **Cannot connect to device**: Check that the device is on the same Tailscale network and has ADB enabled
- **Tailscale not connecting**: Ensure your auth key is valid and has not expired
- **Command failures**: Check the Docker logs with `docker logs android-mcp-server`
- **Deployment errors**: If you see errors like "Ignoring unsupported options" or "invalid reference format", make sure you're using the correct Docker Compose files:
- For building: `docker-compose -f docker-compose.yml -f docker-compose.build.yml build`
- For running: `docker-compose up -d` (this automatically uses docker-compose.override.yml)
## Debugging
If you're having issues, you can access the Docker container:
```bash
docker exec -it android-mcp-server /bin/bash
```
From inside the container, you can run commands like:
```bash
# Check Tailscale status
tailscale status
# Check ADB devices
adb devices
# Test a connection
adb -s 100.x.y.z:5555 shell echo "Connected!"
```
## Security Considerations
The MCP server provides full control of your Android devices. To maintain security:
1. Do not expose port 3001 to the public internet
2. Use a separate Tailscale account or ACLs to restrict access
3. Use ephemeral auth keys with appropriate expiration