mobilecoder-mcp 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +335 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# MobileCoder MCP
|
|
2
|
+
|
|
3
|
+
> MCP server for MobileCoderMCP - enables mobile to desktop coding
|
|
4
|
+
|
|
5
|
+
Transform your mobile device into a powerful coding companion for Cursor, Windsurf, and VSCode. Connect your phone to your IDE and code from anywhere with WebRTC-powered real-time communication.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🚀 **QR Code Quick Connect** - Scan and connect in seconds
|
|
10
|
+
- 🔐 **End-to-End Encryption** - DTLS-secured WebRTC connections
|
|
11
|
+
- 📱 **Universal IDE Support** - Works with Cursor, Windsurf, and VSCode
|
|
12
|
+
- ⚡ **Real-Time Sync** - Low-latency signaling over WebSocket
|
|
13
|
+
- 🛡️ **Security Hardened** - HMAC integrity, SDP validation, replay protection
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What's New in v1.0.2
|
|
18
|
+
|
|
19
|
+
### 🔐 Security Hardening & Stability
|
|
20
|
+
|
|
21
|
+
This version brings critical security improvements to ensure robust WebRTC signaling and data integrity.
|
|
22
|
+
|
|
23
|
+
- **HMAC Message Integrity**: Added Hash-based Message Authentication Code (HMAC) to verify that signaling messages haven't been tampered with during transit.
|
|
24
|
+
|
|
25
|
+
- **SDP Validation**: Strict Session Description Protocol (SDP) validation to prevent malicious payload injection.
|
|
26
|
+
|
|
27
|
+
- **DTLS Fingerprint Check**: Added validation for DTLS fingerprints to ensure secure end-to-end encrypted media streams.
|
|
28
|
+
|
|
29
|
+
- **Replay Attack Protection**: Implemented message nonces and tracking to block unauthorized session re-use.
|
|
30
|
+
|
|
31
|
+
- **Memory Leak Prevention**: Optimized event listeners and connection cleanup cycles for long-running sessions.
|
|
32
|
+
|
|
33
|
+
- **HTTPS Enforcement**: Enhanced origin validation to ensure secure contexts (HTTPS) for all WebRTC operations.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Global Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g mobilecoder-mcp@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Using npx (No Install Required)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx mobilecoder-mcp@latest init
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
### 1. Initialize Connection
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
mobilecoder-mcp init
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This will:
|
|
62
|
+
- Generate a unique 6-character pairing code
|
|
63
|
+
- Display a QR code for mobile scanning
|
|
64
|
+
- Automatically configure your IDEs (Cursor, Windsurf, VSCode)
|
|
65
|
+
- Start the MCP server
|
|
66
|
+
|
|
67
|
+
### 2. Connect Mobile Device
|
|
68
|
+
|
|
69
|
+
1. Visit [https://mobilecoder.xyz/connect](https://mobilecoder.xyz/connect) on your mobile device
|
|
70
|
+
2. Enter the pairing code displayed in terminal
|
|
71
|
+
3. Alternatively, scan the QR code shown in terminal
|
|
72
|
+
|
|
73
|
+
### 3. Start Coding
|
|
74
|
+
|
|
75
|
+
Your mobile device is now connected! Use it to:
|
|
76
|
+
- Generate code with AI assistance
|
|
77
|
+
- Execute terminal commands
|
|
78
|
+
- Browse and edit files
|
|
79
|
+
- Get real-time feedback
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Commands
|
|
84
|
+
|
|
85
|
+
### `mobilecoder-mcp init`
|
|
86
|
+
|
|
87
|
+
Initialize a new connection, generate QR code, and start the agent.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
mobilecoder-mcp init
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Options:**
|
|
94
|
+
- `-s, --signaling <url>` - Custom signaling server URL (default: https://api.mobilecoder.xyz/api)
|
|
95
|
+
- `--debug` - Enable debug logging
|
|
96
|
+
|
|
97
|
+
### `mobilecoder-mcp start`
|
|
98
|
+
|
|
99
|
+
Start the agent with an existing connection code.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
mobilecoder-mcp start --code=ABC123
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Options:**
|
|
106
|
+
- `-c, --code <code>` - Your 6-character connection code (required)
|
|
107
|
+
- `-s, --signaling <url>` - Custom signaling server URL
|
|
108
|
+
- `--debug` - Enable debug logging
|
|
109
|
+
|
|
110
|
+
### `mobilecoder-mcp reset`
|
|
111
|
+
|
|
112
|
+
Remove MobileCoderMCP configuration from IDEs.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
mobilecoder-mcp reset
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Options:**
|
|
119
|
+
- `-i, --ide <ide>` - Specific IDE to reset (cursor, windsurf, vscode, all)
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Environment Variables
|
|
124
|
+
|
|
125
|
+
| Variable | Description | Default |
|
|
126
|
+
|----------|-------------|---------|
|
|
127
|
+
| `MCP_SIGNALING_URL` | Signaling server URL | `https://api.mobilecoder.xyz/api` |
|
|
128
|
+
| `MOBILE_CODER_WEB_URL` | Web app URL for QR codes | `https://mobilecoder.xyz` |
|
|
129
|
+
| `MCP_CONNECTION_CODE` | Pre-defined connection code | Auto-generated |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## How It Works
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
┌─────────────┐ WebRTC (P2P) ┌─────────────┐
|
|
137
|
+
│ Desktop │◄──────────────────────────────►│ Mobile │
|
|
138
|
+
│ (IDE) │ Encrypted Data Stream │ Device │
|
|
139
|
+
│ │ │ │
|
|
140
|
+
│ MCP Server │ Signaling │ Web App │
|
|
141
|
+
└─────────────┘◄──────────────────────────────►└─────────────┘
|
|
142
|
+
(WebSocket + Redis)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
1. **Desktop**: MCP server starts, generates pairing code
|
|
146
|
+
2. **Mobile**: User enters code on web app
|
|
147
|
+
3. **Signaling**: Server facilitates WebRTC handshake
|
|
148
|
+
4. **P2P Connection**: Direct peer-to-peer connection established
|
|
149
|
+
5. **Data Flow**: Commands/results flow directly (no server middleman)
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## IDE Configuration
|
|
154
|
+
|
|
155
|
+
The `init` command automatically configures supported IDEs:
|
|
156
|
+
|
|
157
|
+
### Cursor
|
|
158
|
+
```json
|
|
159
|
+
~/.cursor/mcp.json
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Windsurf
|
|
163
|
+
```json
|
|
164
|
+
~/.codeium/windsurf/mcp_config.json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### VSCode
|
|
168
|
+
```json
|
|
169
|
+
~/.vscode/mcp.json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Manual configuration example:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"mcpServers": {
|
|
177
|
+
"mobile-coder": {
|
|
178
|
+
"command": "npx",
|
|
179
|
+
"args": ["mobilecoder-mcp", "start", "--code", "YOUR_CODE", "--signaling", "https://api.mobilecoder.xyz/api"],
|
|
180
|
+
"env": {
|
|
181
|
+
"MCP_CONNECTION_CODE": "YOUR_CODE",
|
|
182
|
+
"MCP_SIGNALING_URL": "https://api.mobilecoder.xyz/api"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Security
|
|
192
|
+
|
|
193
|
+
### End-to-End Encryption
|
|
194
|
+
|
|
195
|
+
- **DTLS 1.2/1.3**: All WebRTC media encrypted
|
|
196
|
+
- **HMAC-SHA256**: Message integrity verification
|
|
197
|
+
- **SDP Validation**: Malicious payload prevention
|
|
198
|
+
- **Nonce Tracking**: Replay attack protection
|
|
199
|
+
|
|
200
|
+
### Data Privacy
|
|
201
|
+
|
|
202
|
+
- **No Server Storage**: Signaling only, no message logging
|
|
203
|
+
- **P2P Architecture**: Data flows directly between devices
|
|
204
|
+
- **Ephemeral Keys**: Session-specific encryption keys
|
|
205
|
+
|
|
206
|
+
### Best Practices
|
|
207
|
+
|
|
208
|
+
1. **Use HTTPS**: Always in production (enforced by default)
|
|
209
|
+
2. **Secure Codes**: Connection codes expire after 5 minutes
|
|
210
|
+
3. **Rate Limiting**: Signaling endpoints protected
|
|
211
|
+
4. **CORS Whitelist**: Only authorized origins allowed
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Troubleshooting
|
|
216
|
+
|
|
217
|
+
### Connection Issues
|
|
218
|
+
|
|
219
|
+
**Problem**: "Connection timeout" or "Cannot connect to signaling server"
|
|
220
|
+
|
|
221
|
+
**Solutions**:
|
|
222
|
+
- Check internet connection on both devices
|
|
223
|
+
- Verify `MCP_SIGNALING_URL` is correct
|
|
224
|
+
- Ensure signaling server is running: `curl https://api.mobilecoder.xyz/api/health`
|
|
225
|
+
|
|
226
|
+
### WebRTC Handshake Fails
|
|
227
|
+
|
|
228
|
+
**Problem**: "ICE connection failed" or "No remote candidate"
|
|
229
|
+
|
|
230
|
+
**Solutions**:
|
|
231
|
+
- Check firewall settings (UDP ports 3478, 5349)
|
|
232
|
+
- Verify TURN server is accessible
|
|
233
|
+
- Try different network (disable VPN if needed)
|
|
234
|
+
|
|
235
|
+
### Code Already in Use
|
|
236
|
+
|
|
237
|
+
**Problem**: "Connection code is already in use"
|
|
238
|
+
|
|
239
|
+
**Solution**:
|
|
240
|
+
- Wait 2 minutes for code to expire
|
|
241
|
+
- Or generate new code: `mobilecoder-mcp init`
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Development
|
|
246
|
+
|
|
247
|
+
### Build from Source
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
git clone https://github.com/hasmetdurak/mobilecoder-mcp.git
|
|
251
|
+
cd mobilecoder-mcp/mcp-server
|
|
252
|
+
npm install
|
|
253
|
+
npm run build
|
|
254
|
+
npm link
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Run in Development Mode
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
npm run dev # Watch mode with auto-rebuild
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Run Debug Mode
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
mobilecoder-mcp init --debug
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Architecture
|
|
272
|
+
|
|
273
|
+
### MCP Server
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
mcp-server/
|
|
277
|
+
├── src/
|
|
278
|
+
│ ├── index.ts # CLI entry point
|
|
279
|
+
│ ├── agent.ts # Universal MCP agent
|
|
280
|
+
│ ├── webrtc.ts # WebRTC connection manager
|
|
281
|
+
│ ├── security.ts # HMAC & validation
|
|
282
|
+
│ ├── mcp-handler.ts # MCP tool handlers
|
|
283
|
+
│ ├── tool-detector.ts # IDE tool detection
|
|
284
|
+
│ └── adapters/
|
|
285
|
+
│ └── cli-adapter.ts # CLI-specific adapters
|
|
286
|
+
├── dist/ # Compiled JavaScript
|
|
287
|
+
└── package.json
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Dependencies
|
|
291
|
+
|
|
292
|
+
- `@modelcontextprotocol/sdk` - MCP protocol implementation
|
|
293
|
+
- `simple-peer` - WebRTC wrapper for Node.js
|
|
294
|
+
- `@roamhq/wrtc` - Native WebRTC bindings
|
|
295
|
+
- `commander` - CLI framework
|
|
296
|
+
- `qrcode-terminal` - Terminal QR codes
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Contributing
|
|
301
|
+
|
|
302
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
303
|
+
|
|
304
|
+
1. Fork the repository
|
|
305
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
306
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
307
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
308
|
+
5. Open a Pull Request
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
MIT License - see LICENSE file for details
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Support
|
|
319
|
+
|
|
320
|
+
- **Issues**: [GitHub Issues](https://github.com/hasmetdurak/mobilecoder-mcp/issues)
|
|
321
|
+
- **Web App**: [https://mobilecoder.xyz](https://mobilecoder.xyz)
|
|
322
|
+
- **API Docs**: [https://api.mobilecoder.xyz](https://api.mobilecoder.xyz)
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Acknowledgments
|
|
327
|
+
|
|
328
|
+
Built with:
|
|
329
|
+
- [Model Context Protocol (MCP)](https://modelcontextprotocol.io)
|
|
330
|
+
- [Simple Peer](https://github.com/feross/simple-peer)
|
|
331
|
+
- [WebRTC](https://webrtc.org/)
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
**Version**: 1.0.2 | **Author**: @hasmetdurak | **License**: MIT
|