@dynamicu/chromedebug-mcp 2.4.3 → 2.4.4
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/package.json +2 -2
- package/src/standalone-server.js +0 -0
- package/src/cli-http.js +0 -310
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamicu/chromedebug-mcp",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "ChromeDebug MCP - MCP server that provides full control over a Chrome browser instance for debugging and automation with AI assistants like Claude Code",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"chromedebug-mcp": "./src/cli.js",
|
|
9
|
-
"chromedebug-mcp-server": "./src/
|
|
9
|
+
"chromedebug-mcp-server": "./src/standalone-server.js"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
package/src/standalone-server.js
CHANGED
|
File without changes
|
package/src/cli-http.js
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ChromeDebug HTTP Server CLI
|
|
5
|
-
* Standalone HTTP server for Chrome extension integration
|
|
6
|
-
* Does not start MCP stdio server - only HTTP API server
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { ChromeController } from './chrome-controller.js';
|
|
10
|
-
import { ChromeService } from './services/chrome-service.js';
|
|
11
|
-
import { ProcessManager } from './services/process-manager.js';
|
|
12
|
-
import {
|
|
13
|
-
initializeSessionManager,
|
|
14
|
-
getSessionInfo,
|
|
15
|
-
registerProcess
|
|
16
|
-
} from './services/unified-session-manager.js';
|
|
17
|
-
import logger from './utils/logger.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Standalone HTTP Server Application
|
|
21
|
-
* Provides Chrome extension API without MCP stdio interface
|
|
22
|
-
*/
|
|
23
|
-
class ChromeDebugHttpServer {
|
|
24
|
-
constructor() {
|
|
25
|
-
this.chromeController = null;
|
|
26
|
-
this.chromeService = null;
|
|
27
|
-
this.processManager = null;
|
|
28
|
-
this.sessionManager = null;
|
|
29
|
-
this.initialized = false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Initializes HTTP server components
|
|
34
|
-
* @param {Object} options - Initialization options
|
|
35
|
-
*/
|
|
36
|
-
async initialize(options = {}) {
|
|
37
|
-
try {
|
|
38
|
-
// Parse command line arguments
|
|
39
|
-
const args = this.parseArguments();
|
|
40
|
-
const finalOptions = { ...options, ...args };
|
|
41
|
-
|
|
42
|
-
logger.info('🚀 Starting ChromeDebug HTTP Server (Extension API)...');
|
|
43
|
-
|
|
44
|
-
// Create Chrome controller instance
|
|
45
|
-
this.chromeController = new ChromeController();
|
|
46
|
-
|
|
47
|
-
// Create Chrome service wrapper with process management
|
|
48
|
-
this.chromeService = new ChromeService(this.chromeController);
|
|
49
|
-
this.processManager = this.chromeService.getProcessManager();
|
|
50
|
-
|
|
51
|
-
// Initialize Chrome service with HTTP server REQUIRED
|
|
52
|
-
const serviceResult = await this.chromeService.initialize({
|
|
53
|
-
...finalOptions,
|
|
54
|
-
startHttp: true, // Force HTTP server on
|
|
55
|
-
singleServer: false, // Ensure HTTP starts
|
|
56
|
-
sessionManager: this.sessionManager
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (serviceResult.httpServer) {
|
|
60
|
-
logger.info(`✅ HTTP Server Started Successfully`);
|
|
61
|
-
logger.info(` Port: ${serviceResult.httpServer.port}`);
|
|
62
|
-
logger.info(` Status: ${serviceResult.httpServer.status}`);
|
|
63
|
-
logger.info('');
|
|
64
|
-
logger.info('📍 Chrome Extension Connection:');
|
|
65
|
-
logger.info(` Use port ${serviceResult.httpServer.port} in extension settings`);
|
|
66
|
-
logger.info('');
|
|
67
|
-
logger.info('💡 Server is ready for Chrome extension connections');
|
|
68
|
-
} else {
|
|
69
|
-
logger.error('❌ HTTP Server Failed to Start');
|
|
70
|
-
if (serviceResult.httpServer?.error) {
|
|
71
|
-
logger.error(` Error: ${serviceResult.httpServer.error}`);
|
|
72
|
-
}
|
|
73
|
-
throw new Error('HTTP server initialization failed');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.initialized = true;
|
|
77
|
-
return {
|
|
78
|
-
status: 'initialized',
|
|
79
|
-
options: finalOptions,
|
|
80
|
-
serviceResult
|
|
81
|
-
};
|
|
82
|
-
} catch (error) {
|
|
83
|
-
logger.error('Failed to initialize ChromeDebug HTTP Server:', error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Starts the HTTP server and keeps it running
|
|
90
|
-
*/
|
|
91
|
-
async start() {
|
|
92
|
-
if (!this.initialized) {
|
|
93
|
-
await this.initialize();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
// Clean up any existing ChromeDebug processes (optional, controlled by flag)
|
|
98
|
-
const args = this.parseArguments();
|
|
99
|
-
if (!args.noCleanup) {
|
|
100
|
-
const cleanupResult = await this.processManager.cleanupChromePilotProcesses();
|
|
101
|
-
if (cleanupResult.total > 0) {
|
|
102
|
-
logger.debug(`Cleaned up ${cleanupResult.killed.length} existing processes`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Keep the server alive
|
|
107
|
-
logger.info('🔄 HTTP Server is running. Press Ctrl+C to stop.');
|
|
108
|
-
|
|
109
|
-
// Prevent process from exiting
|
|
110
|
-
process.stdin.resume();
|
|
111
|
-
|
|
112
|
-
} catch (error) {
|
|
113
|
-
logger.error('Failed to start ChromeDebug HTTP Server:', error);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Parses command line arguments
|
|
120
|
-
* @returns {Object} Parsed arguments
|
|
121
|
-
*/
|
|
122
|
-
parseArguments() {
|
|
123
|
-
const args = {
|
|
124
|
-
debug: false,
|
|
125
|
-
sessionId: null,
|
|
126
|
-
noCleanup: false,
|
|
127
|
-
verbose: false,
|
|
128
|
-
port: null
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const argv = process.argv.slice(2);
|
|
132
|
-
for (let i = 0; i < argv.length; i++) {
|
|
133
|
-
const arg = argv[i];
|
|
134
|
-
|
|
135
|
-
switch (arg) {
|
|
136
|
-
case '--debug':
|
|
137
|
-
args.debug = true;
|
|
138
|
-
break;
|
|
139
|
-
case '--session-id':
|
|
140
|
-
if (i + 1 < argv.length) {
|
|
141
|
-
args.sessionId = argv[++i];
|
|
142
|
-
} else {
|
|
143
|
-
logger.error('--session-id requires a value');
|
|
144
|
-
process.exit(1);
|
|
145
|
-
}
|
|
146
|
-
break;
|
|
147
|
-
case '--no-cleanup':
|
|
148
|
-
args.noCleanup = true;
|
|
149
|
-
break;
|
|
150
|
-
case '--verbose':
|
|
151
|
-
args.verbose = true;
|
|
152
|
-
break;
|
|
153
|
-
case '--port':
|
|
154
|
-
if (i + 1 < argv.length) {
|
|
155
|
-
args.port = parseInt(argv[++i], 10);
|
|
156
|
-
} else {
|
|
157
|
-
logger.error('--port requires a value');
|
|
158
|
-
process.exit(1);
|
|
159
|
-
}
|
|
160
|
-
break;
|
|
161
|
-
case '--help':
|
|
162
|
-
this.showHelp();
|
|
163
|
-
process.exit(0);
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
if (arg.startsWith('--session-id=')) {
|
|
167
|
-
args.sessionId = arg.split('=')[1];
|
|
168
|
-
} else if (arg.startsWith('--port=')) {
|
|
169
|
-
args.port = parseInt(arg.split('=')[1], 10);
|
|
170
|
-
} else if (arg.startsWith('--')) {
|
|
171
|
-
logger.error(`Unknown argument: ${arg}`);
|
|
172
|
-
this.showHelp();
|
|
173
|
-
process.exit(1);
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return args;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Shows help information
|
|
184
|
-
*/
|
|
185
|
-
showHelp() {
|
|
186
|
-
console.log(`
|
|
187
|
-
ChromeDebug HTTP Server - Standalone Chrome Extension API
|
|
188
|
-
|
|
189
|
-
This server provides HTTP endpoints for Chrome extension integration.
|
|
190
|
-
It does NOT start the MCP stdio server for Claude Code.
|
|
191
|
-
|
|
192
|
-
Usage: chromedebug-mcp-server [options]
|
|
193
|
-
|
|
194
|
-
Options:
|
|
195
|
-
--debug Enable debug logging
|
|
196
|
-
--session-id ID Set custom session ID for resource isolation
|
|
197
|
-
--no-cleanup Skip cleanup of dead processes on startup
|
|
198
|
-
--verbose Enable verbose logging including session info
|
|
199
|
-
--port PORT Specify HTTP server port (optional, auto-discovers if not set)
|
|
200
|
-
--help Show this help message
|
|
201
|
-
|
|
202
|
-
Examples:
|
|
203
|
-
chromedebug-mcp-server
|
|
204
|
-
chromedebug-mcp-server --verbose --no-cleanup
|
|
205
|
-
chromedebug-mcp-server --port 3000
|
|
206
|
-
chromedebug-mcp-server --session-id extension-session-1
|
|
207
|
-
|
|
208
|
-
Environment Variables:
|
|
209
|
-
NODE_ENV Set to 'development' for debug mode
|
|
210
|
-
CHROME_PILOT_PORT Configure HTTP server port
|
|
211
|
-
|
|
212
|
-
What this server does:
|
|
213
|
-
✓ Starts HTTP REST API for Chrome extension
|
|
214
|
-
✓ Provides endpoints for screen recording uploads
|
|
215
|
-
✓ Handles workflow recording and playback
|
|
216
|
-
✓ Manages Chrome browser instances for extension
|
|
217
|
-
|
|
218
|
-
What this server does NOT do:
|
|
219
|
-
✗ Start MCP stdio server for Claude Code
|
|
220
|
-
✗ Provide AI assistant integration
|
|
221
|
-
|
|
222
|
-
For MCP integration, use: chromedebug-mcp
|
|
223
|
-
|
|
224
|
-
For more information, see the documentation in README.md
|
|
225
|
-
`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Graceful shutdown
|
|
230
|
-
*/
|
|
231
|
-
async shutdown() {
|
|
232
|
-
logger.info('Shutting down ChromeDebug HTTP Server...');
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
if (this.chromeService) {
|
|
236
|
-
await this.chromeService.cleanup();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (this.processManager) {
|
|
240
|
-
await this.processManager.killAllManagedProcesses();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
logger.info('HTTP Server shutdown complete');
|
|
244
|
-
} catch (error) {
|
|
245
|
-
logger.error('Error during shutdown:', error);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Main entry point
|
|
252
|
-
*/
|
|
253
|
-
async function main() {
|
|
254
|
-
const app = new ChromeDebugHttpServer();
|
|
255
|
-
|
|
256
|
-
// Parse arguments first to get session settings
|
|
257
|
-
const args = app.parseArguments();
|
|
258
|
-
|
|
259
|
-
try {
|
|
260
|
-
// Initialize unified session manager with options
|
|
261
|
-
const sessionManager = await initializeSessionManager({
|
|
262
|
-
sessionId: args.sessionId || 'http-server',
|
|
263
|
-
skipCleanup: args.noCleanup,
|
|
264
|
-
verbose: args.verbose
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
// Register this process for tracking
|
|
268
|
-
await registerProcess(process.pid, 'http-server');
|
|
269
|
-
|
|
270
|
-
// Log session information if verbose
|
|
271
|
-
if (args.verbose) {
|
|
272
|
-
const sessionInfo = getSessionInfo();
|
|
273
|
-
logger.debug('Session Information:');
|
|
274
|
-
logger.debug(` Session ID: ${sessionInfo.sessionId}`);
|
|
275
|
-
logger.debug(` PID: ${sessionInfo.pid}`);
|
|
276
|
-
logger.debug(` Port: ${sessionInfo.port}`);
|
|
277
|
-
logger.debug(` Session File: ${sessionInfo.sessionFile}`);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Pass session manager to app
|
|
281
|
-
app.sessionManager = sessionManager;
|
|
282
|
-
|
|
283
|
-
await app.start();
|
|
284
|
-
} catch (error) {
|
|
285
|
-
logger.error('Fatal error starting ChromeDebug HTTP Server:', error);
|
|
286
|
-
process.exit(1);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Handle graceful shutdown
|
|
291
|
-
process.on('SIGINT', async () => {
|
|
292
|
-
logger.info('Received SIGINT, shutting down gracefully...');
|
|
293
|
-
process.exit(0);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
process.on('SIGTERM', async () => {
|
|
297
|
-
logger.info('Received SIGTERM, shutting down gracefully...');
|
|
298
|
-
process.exit(0);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// Export for testing
|
|
302
|
-
export { ChromeDebugHttpServer };
|
|
303
|
-
|
|
304
|
-
// Run if this is the main module
|
|
305
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
306
|
-
main().catch((error) => {
|
|
307
|
-
logger.error('Unhandled error:', error);
|
|
308
|
-
process.exit(1);
|
|
309
|
-
});
|
|
310
|
-
}
|