mobilecoder-mcp 1.0.4 ā 2.0.0
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/.security.log +5 -0
- package/dist/agent.d.ts +15 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +161 -61
- package/dist/agent.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +24 -21
- package/dist/index.js.map +1 -1
- package/dist/mcp-handler.d.ts.map +1 -1
- package/dist/mcp-handler.js +46 -6
- package/dist/mcp-handler.js.map +1 -1
- package/dist/security.d.ts.map +1 -1
- package/dist/security.js +2 -5
- package/dist/security.js.map +1 -1
- package/dist/webrtc.d.ts +4 -10
- package/dist/webrtc.d.ts.map +1 -1
- package/dist/webrtc.js +96 -305
- package/dist/webrtc.js.map +1 -1
- package/package.json +23 -24
- package/src/agent.ts +178 -67
- package/src/cli.ts +35 -0
- package/src/types.d.ts +8 -0
- package/src/adapters/cli-adapter.ts +0 -73
- package/src/index.ts +0 -172
- package/src/mcp-handler.ts +0 -327
- package/src/security.ts +0 -345
- package/src/tool-detector.ts +0 -110
- package/src/webrtc.ts +0 -387
package/dist/webrtc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webrtc.js","sourceRoot":"","sources":["../src/webrtc.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,sDAAsD;AACtD,IAAI,IAAS,CAAC;AACd,IAAI,CAAC;IACH,qCAAqC;IACrC,IAAI,GAAG,OAAO,CAAC,cAAc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CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobilecoder-mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"main": "dist/index.js",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Secure Zero-Knowledge Terminal Relay for MobileCoder",
|
|
5
|
+
"main": "dist/agent.js",
|
|
7
6
|
"bin": {
|
|
8
|
-
"mobilecoder-mcp": "dist/
|
|
7
|
+
"mobilecoder-mcp": "./dist/cli.js"
|
|
9
8
|
},
|
|
10
9
|
"scripts": {
|
|
10
|
+
"start": "node dist/cli.js",
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"
|
|
13
|
-
"start": "node dist/index.js"
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
14
13
|
},
|
|
15
14
|
"keywords": [
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
15
|
+
"terminal",
|
|
16
|
+
"mobile",
|
|
17
|
+
"ssh",
|
|
18
|
+
"relay",
|
|
19
|
+
"zero-knowledge"
|
|
20
20
|
],
|
|
21
|
-
"author": "",
|
|
22
|
-
"license": "
|
|
21
|
+
"author": "MobileCoder",
|
|
22
|
+
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
24
|
+
"chalk": "^4.1.2",
|
|
25
|
+
"commander": "^9.4.1",
|
|
26
|
+
"crypto-js": "^4.1.1",
|
|
27
|
+
"node-pty": "^0.10.1",
|
|
28
|
+
"ora": "^5.4.1",
|
|
29
|
+
"socket.io-client": "^4.7.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/
|
|
34
|
-
"
|
|
35
|
-
"typescript": "^5.5.0"
|
|
32
|
+
"@types/crypto-js": "^4.1.1",
|
|
33
|
+
"@types/node": "^18.11.9",
|
|
34
|
+
"typescript": "^4.9.3"
|
|
36
35
|
}
|
|
37
|
-
}
|
|
36
|
+
}
|
package/src/agent.ts
CHANGED
|
@@ -1,89 +1,200 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
|
|
2
|
+
import { io, Socket } from 'socket.io-client';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import * as pty from 'node-pty';
|
|
5
|
+
import CryptoJS from 'crypto-js';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import ora from 'ora';
|
|
8
|
+
|
|
9
|
+
// šØ BURAYI KENDİ DOMAIN ADRESİNLE DEÄİÅTİR!
|
|
10
|
+
const RELAY_SERVER_URL = 'https://api.mobilecoder.xyz';
|
|
11
|
+
|
|
12
|
+
export class ZKRelayAgent {
|
|
13
|
+
private socket: Socket;
|
|
14
|
+
private ptyProcess: any;
|
|
15
|
+
private secretCode: string;
|
|
16
|
+
private roomId: string;
|
|
17
|
+
private encryptionKey: string;
|
|
18
|
+
private spinner = ora('Initializing Secure Tunnel...');
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
this.setupSecurity();
|
|
22
|
+
this.initPTY();
|
|
23
|
+
this.connectToRelay();
|
|
13
24
|
}
|
|
14
25
|
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
// 1. Güvenlik Katmanı: Kod Ćret ve Anahtar Türet
|
|
27
|
+
private setupSecurity() {
|
|
28
|
+
// 6 Haneli rastgele kod (Kullanıcının gƶreceÄi)
|
|
29
|
+
const randomNum = Math.floor(100000 + Math.random() * 900000);
|
|
30
|
+
this.secretCode = randomNum.toString();
|
|
31
|
+
|
|
32
|
+
// Oda ID'si: Kodun Hash'i (Sunucu sadece bunu görür, kodu göremez)
|
|
33
|
+
this.roomId = CryptoJS.SHA256(this.secretCode).toString();
|
|
34
|
+
|
|
35
|
+
// Åifreleme Anahtarı: Kodun kendisi (AES-256 iƧin kullanılacak)
|
|
36
|
+
this.encryptionKey = this.secretCode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 2. Terminal (PTY) BaÅlatma
|
|
40
|
+
private initPTY() {
|
|
41
|
+
const shell = os.platform() === 'win32' ? 'powershell.exe' : (process.env.SHELL || 'bash');
|
|
42
|
+
|
|
43
|
+
this.ptyProcess = pty.spawn(shell, [], {
|
|
44
|
+
name: 'xterm-256color',
|
|
45
|
+
cols: 80,
|
|
46
|
+
rows: 24,
|
|
47
|
+
cwd: process.cwd(),
|
|
48
|
+
env: process.env
|
|
49
|
+
});
|
|
17
50
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
setupMCPServer(this.webrtc).catch(err => {
|
|
22
|
-
console.error('Failed to start MCP server:', err);
|
|
51
|
+
// Terminalden Ƨıkan veriyi Åifrele ve yolla
|
|
52
|
+
this.ptyProcess.onData((data: string) => {
|
|
53
|
+
this.sendSecurePayload('term_data', data);
|
|
23
54
|
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 3. Relay Sunucusuna BaÄlanma
|
|
58
|
+
private connectToRelay() {
|
|
59
|
+
this.spinner.start('Connecting to MobileCoder Relay Network...');
|
|
24
60
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
data: data,
|
|
30
|
-
timestamp: Date.now()
|
|
31
|
-
});
|
|
61
|
+
this.socket = io(RELAY_SERVER_URL, {
|
|
62
|
+
transports: ['websocket'], // Hız iƧin sadece websocket
|
|
63
|
+
reconnection: true,
|
|
64
|
+
reconnectionAttempts: Infinity
|
|
32
65
|
});
|
|
33
66
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Currently mcp-handler adds its own listener. SimplePeer supports multiple listeners.
|
|
67
|
+
this.socket.on('connect', () => {
|
|
68
|
+
this.spinner.succeed(chalk.green('Connected to Relay Node!'));
|
|
37
69
|
|
|
38
|
-
|
|
39
|
-
this.
|
|
70
|
+
// Odaya Katıl (Sadece Hash ID gƶnderilir)
|
|
71
|
+
this.socket.emit('join_room', { code: this.roomId, type: 'agent' });
|
|
72
|
+
// Note: Changed 'join_secure_room' to 'join_room' to match server implementation
|
|
73
|
+
// Server implementation in index.ts: socket.on('join_room', (data: { code: string; type: 'agent' | 'client' }) => ...)
|
|
74
|
+
|
|
75
|
+
this.printBanner();
|
|
40
76
|
});
|
|
41
77
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
78
|
+
this.socket.on('disconnect', () => {
|
|
79
|
+
this.spinner.warn(chalk.yellow('Connection lost. Reconnecting...'));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Mobilden biri baÄlandıÄında
|
|
83
|
+
this.socket.on('peer_joined', () => { // Changed peer_connected to peer_joined based on server impl
|
|
84
|
+
console.log(chalk.green('\nš± Mobile Client Connected via Encrypted Tunnel!'));
|
|
85
|
+
this.sendEnvInfo();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Mobilden Åifreli veri geldiÄinde
|
|
89
|
+
// RelayManager emits 'term_data' and 'meta_data'.
|
|
90
|
+
// Server implementation:
|
|
91
|
+
// socket.on('term_data', ...) -> pass through term_data
|
|
92
|
+
// socket.on('meta_data', ...) -> pass through meta_data
|
|
93
|
+
// Agent connects to /, Server index.ts uses / (global namespace) BUT has:
|
|
94
|
+
// const relayNamespace = io.of('/terminal');
|
|
95
|
+
// WAIT. Previous user setup had /terminal.
|
|
96
|
+
// My previous edit REMOVED /terminal and used RelayManager on root io.
|
|
97
|
+
// But RelayManager implementation listens on 'relay_data'.
|
|
98
|
+
// My RelayManager uses: socket.on('relay_data', ...)
|
|
99
|
+
// But user snippet provided for Agent uses 'relay_encrypted' and listens on 'stream_encrypted'.
|
|
100
|
+
// I need to align Agent and Server.
|
|
101
|
+
// The previous edit to server/index.ts instantiates RelayManager.
|
|
102
|
+
// RelayManager listens to 'relay_data'.
|
|
103
|
+
// So the Agent MUST emit 'relay_data'.
|
|
104
|
+
|
|
105
|
+
this.socket.on('relay_data', (message: { room: string, payload: any }) => {
|
|
106
|
+
// RelayManager checks payload structure?
|
|
107
|
+
// Wait, RelayManager implementation:
|
|
108
|
+
// socket.on('relay_data', (data) => { ... socket.to(room).emit('relay_data', data.payload) ... })
|
|
109
|
+
// So client receives `payload`.
|
|
110
|
+
// If payload is encrypted string, handle it.
|
|
111
|
+
this.handleIncomingMessage(message as any);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Also listen for connect_error
|
|
115
|
+
this.socket.on('connect_error', (err) => {
|
|
116
|
+
// console.error(err);
|
|
117
|
+
});
|
|
47
118
|
}
|
|
48
119
|
|
|
49
|
-
|
|
50
|
-
|
|
120
|
+
// Gelen veriyi Ƨƶz ve iÅle
|
|
121
|
+
private handleIncomingMessage(encryptedPayload: any) {
|
|
122
|
+
try {
|
|
123
|
+
// Payload might be wrapped { e: ... } or string
|
|
124
|
+
let ciphertext = encryptedPayload;
|
|
125
|
+
if (typeof encryptedPayload === 'object' && encryptedPayload.e) {
|
|
126
|
+
ciphertext = encryptedPayload.e;
|
|
127
|
+
}
|
|
51
128
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(`š Switched active tool to: ${this.activeTool}`);
|
|
129
|
+
const bytes = CryptoJS.AES.decrypt(ciphertext, this.encryptionKey);
|
|
130
|
+
const originalText = bytes.toString(CryptoJS.enc.Utf8);
|
|
55
131
|
|
|
56
|
-
|
|
57
|
-
type: 'system',
|
|
58
|
-
message: `Switched to ${this.activeTool}`
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
132
|
+
if (!originalText) return;
|
|
62
133
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
type
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
134
|
+
// Veri JSON mu? (Resize komutu vs olabilir)
|
|
135
|
+
try {
|
|
136
|
+
const cmd = JSON.parse(originalText);
|
|
137
|
+
if (cmd.type === 'resize') {
|
|
138
|
+
this.ptyProcess.resize(cmd.cols, cmd.rows);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (cmd.type === 'input') {
|
|
142
|
+
this.ptyProcess.write(cmd.data);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Fallback checks
|
|
146
|
+
} catch (e) {
|
|
147
|
+
// JSON deÄilse saf terminal girdisidir
|
|
148
|
+
this.ptyProcess.write(originalText);
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
// Åifre Ƨƶzülemezse (YanlıŠanahtar vb.) sessizce yut
|
|
70
152
|
}
|
|
153
|
+
}
|
|
71
154
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
155
|
+
// Veriyi Åifrele ve gƶnder
|
|
156
|
+
private sendSecurePayload(type: string, data: any) {
|
|
157
|
+
let payloadStr = data;
|
|
158
|
+
if (type === 'meta') {
|
|
159
|
+
// Standardize format
|
|
160
|
+
payloadStr = JSON.stringify(data);
|
|
161
|
+
} else if (type === 'term_data' && typeof data === 'string') {
|
|
162
|
+
// Wrap output in { type: 'output', data: ... } for client consistency if client expects JSON
|
|
163
|
+
// The Client handles { type: 'output' ... }
|
|
164
|
+
payloadStr = JSON.stringify({ type: 'output', data: data });
|
|
79
165
|
}
|
|
80
166
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
167
|
+
const encrypted = CryptoJS.AES.encrypt(payloadStr, this.encryptionKey).toString();
|
|
168
|
+
|
|
169
|
+
// RelayManager expects 'relay_data' event with { room, payload }
|
|
170
|
+
// It emits 'relay_data' with just payload to other peer.
|
|
171
|
+
this.socket.emit('relay_data', {
|
|
172
|
+
room: this.roomId,
|
|
173
|
+
payload: { e: encrypted }
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private sendEnvInfo() {
|
|
178
|
+
const info = {
|
|
179
|
+
type: 'host_info', // Changed to match client expectation
|
|
180
|
+
username: os.userInfo().username, // user -> username
|
|
181
|
+
hostname: os.hostname(), // host -> hostname
|
|
182
|
+
platform: os.platform(),
|
|
183
|
+
cwd: process.cwd()
|
|
184
|
+
};
|
|
185
|
+
this.sendSecurePayload('meta', info);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private printBanner() {
|
|
189
|
+
console.log('\n' + chalk.bgBlue.bold(' MOBILECODER ZK-RELAY v2.0 '));
|
|
190
|
+
console.log(chalk.gray('Secure, End-to-End Encrypted Terminal Bridge\n'));
|
|
86
191
|
|
|
87
|
-
|
|
192
|
+
console.log(chalk.yellow('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
193
|
+
console.log(chalk.yellow('ā š CONNECTION CODE (ENTER ON APP) ā'));
|
|
194
|
+
console.log(chalk.yellow('ā ā'));
|
|
195
|
+
console.log(chalk.yellow(`ā ${chalk.white.bold.bgBlack(` ${this.secretCode.slice(0, 3)} - ${this.secretCode.slice(3)} `)} ā`));
|
|
196
|
+
console.log(chalk.yellow('ā ā'));
|
|
197
|
+
console.log(chalk.yellow('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
198
|
+
console.log(chalk.cyan('\nWaiting for mobile connection...'));
|
|
88
199
|
}
|
|
89
200
|
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { ZKRelayAgent } from './agent.js';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
const program = new Command();
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.name('mobilecoder-mcp')
|
|
10
|
+
.description('MobileCoder Desktop Agent - ZK-Relay Edition')
|
|
11
|
+
.version('2.0.0');
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command('init')
|
|
15
|
+
.description('Start the secure relay agent')
|
|
16
|
+
.action(() => {
|
|
17
|
+
try {
|
|
18
|
+
new ZKRelayAgent();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(chalk.red('Fatal Error:'), error);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Varsayılan komut (argüman girilmezse init ƧalıÅsın)
|
|
26
|
+
if (!process.argv.slice(2).length) {
|
|
27
|
+
try {
|
|
28
|
+
new ZKRelayAgent();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(chalk.red('Fatal Error:'), error);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
program.parse(process.argv);
|
|
35
|
+
}
|
package/src/types.d.ts
ADDED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { spawn, ChildProcess } from 'child_process';
|
|
2
|
-
import { platform } from 'os';
|
|
3
|
-
|
|
4
|
-
export interface CLIResult {
|
|
5
|
-
output: string;
|
|
6
|
-
exitCode: number | null;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class CLIAdapter {
|
|
10
|
-
private process: ChildProcess | null = null;
|
|
11
|
-
private onOutputCallback?: (data: string) => void;
|
|
12
|
-
|
|
13
|
-
constructor() { }
|
|
14
|
-
|
|
15
|
-
execute(command: string, args: string[] = [], cwd: string = process.cwd()): void {
|
|
16
|
-
const isWindows = platform() === 'win32';
|
|
17
|
-
const shell = isWindows ? 'powershell.exe' : '/bin/bash';
|
|
18
|
-
const shellArgs = isWindows ? ['-c', `${command} ${args.join(' ')}`] : ['-c', `${command} ${args.join(' ')}`];
|
|
19
|
-
|
|
20
|
-
console.log(`[CLI] Executing: ${command} ${args.join(' ')}`);
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
this.process = spawn(shell, shellArgs, {
|
|
24
|
-
cwd,
|
|
25
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
26
|
-
env: process.env
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
this.process.stdout?.on('data', (data) => {
|
|
30
|
-
const output = data.toString();
|
|
31
|
-
if (this.onOutputCallback) {
|
|
32
|
-
this.onOutputCallback(output);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
this.process.stderr?.on('data', (data) => {
|
|
37
|
-
const output = data.toString();
|
|
38
|
-
if (this.onOutputCallback) {
|
|
39
|
-
this.onOutputCallback(output);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
this.process.on('error', (error) => {
|
|
44
|
-
if (this.onOutputCallback) {
|
|
45
|
-
this.onOutputCallback(`Error: ${error.message}\n`);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
this.process.on('close', (code) => {
|
|
50
|
-
if (this.onOutputCallback) {
|
|
51
|
-
this.onOutputCallback(`\n[Process exited with code ${code}]`);
|
|
52
|
-
}
|
|
53
|
-
this.process = null;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
} catch (error: any) {
|
|
57
|
-
if (this.onOutputCallback) {
|
|
58
|
-
this.onOutputCallback(`Failed to start process: ${error.message}\n`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
onOutput(callback: (data: string) => void): void {
|
|
64
|
-
this.onOutputCallback = callback;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
kill(): void {
|
|
68
|
-
if (this.process) {
|
|
69
|
-
this.process.kill();
|
|
70
|
-
this.process = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import * as fs from 'fs';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import * as os from 'os';
|
|
7
|
-
import * as crypto from 'crypto';
|
|
8
|
-
import { createRequire } from 'module';
|
|
9
|
-
const require = createRequire(import.meta.url);
|
|
10
|
-
const qrcode = require('qrcode-terminal');
|
|
11
|
-
import { UniversalAgent } from './agent.js';
|
|
12
|
-
import { WebRTCConnection } from './webrtc.js';
|
|
13
|
-
|
|
14
|
-
const program = new Command();
|
|
15
|
-
|
|
16
|
-
program
|
|
17
|
-
.name('mobilecoder-mcp')
|
|
18
|
-
.description('MCP server for MobileCoderMCP - enables mobile to desktop coding')
|
|
19
|
-
.version('1.0.0');
|
|
20
|
-
|
|
21
|
-
program
|
|
22
|
-
.command('init')
|
|
23
|
-
.description('Initialize connection, generate QR code and start the agent')
|
|
24
|
-
.option('-s, --signaling <url>', 'Signaling server URL', process.env.MCP_SIGNALING_URL || 'https://api.mobilecoder.xyz/api')
|
|
25
|
-
.option('--debug', 'Enable debug logging', false)
|
|
26
|
-
.action(async (options: { signaling: string; debug: boolean }) => {
|
|
27
|
-
const code = generateConnectionCode();
|
|
28
|
-
|
|
29
|
-
if (options.debug) {
|
|
30
|
-
console.log('š Debug mode enabled');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
console.log('\nš± MobileCoder MCP - Quick Setup');
|
|
34
|
-
console.log('================================');
|
|
35
|
-
console.log(`\nš Your Pairing Code: ${code}`);
|
|
36
|
-
console.log('Scan the QR code below with your mobile device to connect:\n');
|
|
37
|
-
|
|
38
|
-
// Generate QR code in terminal
|
|
39
|
-
// Use environment variable or default to the deployed URL
|
|
40
|
-
const webAppUrl = process.env.MOBILE_CODER_WEB_URL || 'https://mobilecoder.xyz';
|
|
41
|
-
const pairingUrl = `${webAppUrl}/connect?code=${code}`;
|
|
42
|
-
qrcode.generate(pairingUrl, { small: true });
|
|
43
|
-
|
|
44
|
-
console.log('\nš Configuring IDEs...');
|
|
45
|
-
await autoConfigureIDEs(code, options.signaling);
|
|
46
|
-
|
|
47
|
-
console.log('\nš Starting Universal Agent...');
|
|
48
|
-
const webrtc = new WebRTCConnection(code, options.signaling, options.debug);
|
|
49
|
-
const agent = new UniversalAgent(webrtc);
|
|
50
|
-
await agent.start();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
program
|
|
54
|
-
.command('start')
|
|
55
|
-
.description('Start the Universal Agent with an existing code')
|
|
56
|
-
.option('-c, --code <code>', 'Connection code')
|
|
57
|
-
.option('-s, --signaling <url>', 'Signaling server URL', process.env.MCP_SIGNALING_URL || 'https://api.mobilecoder.xyz/api')
|
|
58
|
-
.option('--debug', 'Enable debug logging', false)
|
|
59
|
-
.action(async (options: { code?: string; signaling: string; debug: boolean }) => {
|
|
60
|
-
if (!options.code) {
|
|
61
|
-
console.error('ā Error: Connection code is required');
|
|
62
|
-
console.log(' Use: mobilecoder-mcp start --code=YOUR_CODE');
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
console.log('š Starting Universal Agent...');
|
|
67
|
-
console.log(` Connection code: ${options.code}`);
|
|
68
|
-
console.log(` Signaling server: ${options.signaling}\n`);
|
|
69
|
-
|
|
70
|
-
const webrtc = new WebRTCConnection(options.code, options.signaling, options.debug);
|
|
71
|
-
const agent = new UniversalAgent(webrtc);
|
|
72
|
-
await agent.start();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
program
|
|
76
|
-
.command('reset')
|
|
77
|
-
.description('Reset connection and remove config from all IDEs')
|
|
78
|
-
.option('-i, --ide <ide>', 'IDE to reset (cursor, windsurf, vscode, all)', 'all')
|
|
79
|
-
.action(async (options: { ide: string }) => {
|
|
80
|
-
console.log('š Resetting MobileCoderMCP...\n');
|
|
81
|
-
|
|
82
|
-
const configs = {
|
|
83
|
-
cursor: path.join(os.homedir(), '.cursor', 'mcp.json'),
|
|
84
|
-
windsurf: path.join(os.homedir(), '.codeium', 'windsurf', 'mcp_config.json'),
|
|
85
|
-
vscode: path.join(os.homedir(), '.vscode', 'mcp.json'),
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const ide = options.ide.toLowerCase();
|
|
89
|
-
|
|
90
|
-
if (ide === 'all') {
|
|
91
|
-
for (const [name, configPath] of Object.entries(configs)) {
|
|
92
|
-
await removeFromConfig(configPath, 'mobile-coder');
|
|
93
|
-
}
|
|
94
|
-
} else if (configs[ide as keyof typeof configs]) {
|
|
95
|
-
await removeFromConfig(configs[ide as keyof typeof configs], 'mobile-coder');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
console.log('ā
Configuration reset complete\n');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
program.parse();
|
|
102
|
-
|
|
103
|
-
function generateConnectionCode(): string {
|
|
104
|
-
return crypto.randomBytes(3).toString('hex').toUpperCase();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function autoConfigureIDEs(code: string, signalingUrl: string) {
|
|
108
|
-
const configs = {
|
|
109
|
-
cursor: path.join(os.homedir(), '.cursor', 'mcp.json'),
|
|
110
|
-
windsurf: path.join(os.homedir(), '.codeium', 'windsurf', 'mcp_config.json'),
|
|
111
|
-
vscode: path.join(os.homedir(), '.vscode', 'mcp.json'),
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
for (const [name, configPath] of Object.entries(configs)) {
|
|
115
|
-
try {
|
|
116
|
-
await configureIDE(configPath, name, code, signalingUrl);
|
|
117
|
-
} catch (e) {
|
|
118
|
-
// Ignore if IDE config dir doesn't exist
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async function configureIDE(configPath: string, ideName: string, code: string, signalingUrl: string) {
|
|
124
|
-
const configDir = path.dirname(configPath);
|
|
125
|
-
if (!fs.existsSync(configDir)) {
|
|
126
|
-
return; // Skip if IDE is not installed/configured
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
let config: any = { mcpServers: {} };
|
|
130
|
-
if (fs.existsSync(configPath)) {
|
|
131
|
-
try {
|
|
132
|
-
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
133
|
-
} catch (e) {
|
|
134
|
-
console.warn(`ā ļø Could not read existing ${ideName} config, creating new one`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (!config.mcpServers) {
|
|
139
|
-
config.mcpServers = {};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// We assume the user has mobilecoder-mcp installed globally or via npx
|
|
143
|
-
// In npx context, we use the command name directly
|
|
144
|
-
config.mcpServers['mobile-coder'] = {
|
|
145
|
-
command: 'npx',
|
|
146
|
-
args: ['mobilecoder-mcp', 'start', '--code', code, '--signaling', signalingUrl],
|
|
147
|
-
env: {
|
|
148
|
-
MCP_CONNECTION_CODE: code,
|
|
149
|
-
MCP_SIGNALING_URL: signalingUrl
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
154
|
-
console.log(` ā
${ideName.charAt(0).toUpperCase() + ideName.slice(1)} linked.`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async function removeFromConfig(configPath: string, serverName: string) {
|
|
158
|
-
if (!fs.existsSync(configPath)) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
164
|
-
if (config.mcpServers && config.mcpServers[serverName]) {
|
|
165
|
-
delete config.mcpServers[serverName];
|
|
166
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
167
|
-
console.log(` ā
Removed from ${path.basename(configPath)}`);
|
|
168
|
-
}
|
|
169
|
-
} catch (e) {
|
|
170
|
-
console.warn(`ā ļø Could not update ${configPath}`);
|
|
171
|
-
}
|
|
172
|
-
}
|