@dynamicu/chromedebug-mcp 2.2.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.
Files changed (95) hide show
  1. package/CLAUDE.md +344 -0
  2. package/LICENSE +21 -0
  3. package/README.md +250 -0
  4. package/chrome-extension/README.md +41 -0
  5. package/chrome-extension/background.js +3917 -0
  6. package/chrome-extension/chrome-session-manager.js +706 -0
  7. package/chrome-extension/content.css +181 -0
  8. package/chrome-extension/content.js +3022 -0
  9. package/chrome-extension/data-buffer.js +435 -0
  10. package/chrome-extension/dom-tracker.js +411 -0
  11. package/chrome-extension/extension-config.js +78 -0
  12. package/chrome-extension/firebase-client.js +278 -0
  13. package/chrome-extension/firebase-config.js +32 -0
  14. package/chrome-extension/firebase-config.module.js +22 -0
  15. package/chrome-extension/firebase-config.module.template.js +27 -0
  16. package/chrome-extension/firebase-config.template.js +36 -0
  17. package/chrome-extension/frame-capture.js +407 -0
  18. package/chrome-extension/icon128.png +1 -0
  19. package/chrome-extension/icon16.png +1 -0
  20. package/chrome-extension/icon48.png +1 -0
  21. package/chrome-extension/license-helper.js +181 -0
  22. package/chrome-extension/logger.js +23 -0
  23. package/chrome-extension/manifest.json +73 -0
  24. package/chrome-extension/network-tracker.js +510 -0
  25. package/chrome-extension/offscreen.html +10 -0
  26. package/chrome-extension/options.html +203 -0
  27. package/chrome-extension/options.js +282 -0
  28. package/chrome-extension/pako.min.js +2 -0
  29. package/chrome-extension/performance-monitor.js +533 -0
  30. package/chrome-extension/pii-redactor.js +405 -0
  31. package/chrome-extension/popup.html +532 -0
  32. package/chrome-extension/popup.js +2446 -0
  33. package/chrome-extension/upload-manager.js +323 -0
  34. package/chrome-extension/web-vitals.iife.js +1 -0
  35. package/config/api-keys.json +11 -0
  36. package/config/chrome-pilot-config.json +45 -0
  37. package/package.json +126 -0
  38. package/scripts/cleanup-processes.js +109 -0
  39. package/scripts/config-manager.js +280 -0
  40. package/scripts/generate-extension-config.js +53 -0
  41. package/scripts/setup-security.js +64 -0
  42. package/src/capture/architecture.js +426 -0
  43. package/src/capture/error-handling-tests.md +38 -0
  44. package/src/capture/error-handling-types.ts +360 -0
  45. package/src/capture/index.js +508 -0
  46. package/src/capture/interfaces.js +625 -0
  47. package/src/capture/memory-manager.js +713 -0
  48. package/src/capture/types.js +342 -0
  49. package/src/chrome-controller.js +2658 -0
  50. package/src/cli.js +19 -0
  51. package/src/config-loader.js +303 -0
  52. package/src/database.js +2178 -0
  53. package/src/firebase-license-manager.js +462 -0
  54. package/src/firebase-privacy-guard.js +397 -0
  55. package/src/http-server.js +1516 -0
  56. package/src/index-direct.js +157 -0
  57. package/src/index-modular.js +219 -0
  58. package/src/index-monolithic-backup.js +2230 -0
  59. package/src/index.js +305 -0
  60. package/src/legacy/chrome-controller-old.js +1406 -0
  61. package/src/legacy/index-express.js +625 -0
  62. package/src/legacy/index-old.js +977 -0
  63. package/src/legacy/routes.js +260 -0
  64. package/src/legacy/shared-storage.js +101 -0
  65. package/src/logger.js +10 -0
  66. package/src/mcp/handlers/chrome-tool-handler.js +306 -0
  67. package/src/mcp/handlers/element-tool-handler.js +51 -0
  68. package/src/mcp/handlers/frame-tool-handler.js +957 -0
  69. package/src/mcp/handlers/request-handler.js +104 -0
  70. package/src/mcp/handlers/workflow-tool-handler.js +636 -0
  71. package/src/mcp/server.js +68 -0
  72. package/src/mcp/tools/index.js +701 -0
  73. package/src/middleware/auth.js +371 -0
  74. package/src/middleware/security.js +267 -0
  75. package/src/port-discovery.js +258 -0
  76. package/src/routes/admin.js +182 -0
  77. package/src/services/browser-daemon.js +494 -0
  78. package/src/services/chrome-service.js +375 -0
  79. package/src/services/failover-manager.js +412 -0
  80. package/src/services/git-safety-service.js +675 -0
  81. package/src/services/heartbeat-manager.js +200 -0
  82. package/src/services/http-client.js +195 -0
  83. package/src/services/process-manager.js +318 -0
  84. package/src/services/process-tracker.js +574 -0
  85. package/src/services/profile-manager.js +449 -0
  86. package/src/services/project-manager.js +415 -0
  87. package/src/services/session-manager.js +497 -0
  88. package/src/services/session-registry.js +491 -0
  89. package/src/services/unified-session-manager.js +678 -0
  90. package/src/shared-storage-old.js +267 -0
  91. package/src/standalone-server.js +53 -0
  92. package/src/utils/extension-path.js +145 -0
  93. package/src/utils.js +187 -0
  94. package/src/validation/log-transformer.js +125 -0
  95. package/src/validation/schemas.js +391 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,344 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ Chrome Debug is an MCP (Model Context Protocol) server that gives AI full control over a Chrome browser instance. It consists of:
8
+ - An MCP server for AI integration
9
+ - An HTTP API server for browser control
10
+ - A Chrome extension for visual element selection and screen recording
11
+ - A VS Code extension for IDE integration
12
+
13
+ ## Key Commands
14
+
15
+ ### Development
16
+ ```bash
17
+ npm install # Install dependencies
18
+ npm start # Start MCP server (cleans up processes first)
19
+ npm run go # Start in development mode with NODE_ENV=development
20
+ npm run dev # Start with --watch flag for development
21
+ npm run start-http # Start HTTP server directly (port 3000-4000)
22
+ npm run server # Run standalone server
23
+ npm run single-server # Run with --single-server flag
24
+ npm run cleanup # Clean up stale Chrome processes
25
+ npm run cleanup-force # Force cleanup of all Chrome processes
26
+ ```
27
+
28
+ ### Testing
29
+ ```bash
30
+ # Run all tests
31
+ npm test # Run all Jest tests
32
+ npm run test:watch # Run tests in watch mode
33
+ npm run test:coverage # Run tests with coverage report
34
+
35
+ # Run specific test suites
36
+ npm run test:unit # Run unit tests only (excludes integration tests)
37
+ npm run test:integration # Run integration tests only
38
+ npm run test:chrome # Test ChromeController functionality
39
+ npm run test:http # Test HTTP server
40
+ npm run test:db # Test database functionality
41
+ npm run test:mcp # Test MCP server functionality
42
+
43
+ # Recording system tests
44
+ npm run test:recording # Test comprehensive recording system
45
+ npm run test:extension # Test Chrome extension recording
46
+ npm run test:migration # Test dual ID migration
47
+ npm run test:regression # Test recording regression
48
+ npm run test:recording-all # Run all recording-related tests
49
+ ```
50
+
51
+ ### Configuration Management
52
+ ```bash
53
+ npm run config # Manage configuration
54
+ npm run config-show # Show current configuration
55
+ npm run config-ports # List configured ports
56
+ npm run update-extension-config # Update Chrome extension config
57
+ ```
58
+
59
+ ### Chrome Extension
60
+ ```bash
61
+ # Load extension in Chrome:
62
+ # 1. Open chrome://extensions/
63
+ # 2. Enable Developer mode
64
+ # 3. Click "Load unpacked"
65
+ # 4. Select chrome-extension/ directory
66
+ ```
67
+
68
+ ### VS Code Extension
69
+ ```bash
70
+ cd vscode-chrome-pilot
71
+ npm install
72
+ npm run compile
73
+ # Press F5 in VS Code to test
74
+ ```
75
+
76
+ ## Architecture
77
+
78
+ ### Core Components
79
+
80
+ 1. **MCP Server** (`src/index.js`)
81
+ - Entry point for AI integration via Model Context Protocol
82
+ - Exposes Chrome control tools to AI assistants
83
+ - Uses StdioServerTransport for communication
84
+
85
+ 2. **Chrome Controller** (`src/chrome-controller.js`)
86
+ - Central class managing Chrome browser instances
87
+ - Uses Puppeteer for browser automation
88
+ - Handles debugging protocol connections
89
+ - Manages element selection and screenshots
90
+ - Stores recordings in SQLite database
91
+
92
+ 3. **HTTP Server** (`src/http-server.js`)
93
+ - REST API on ports 3000-4000 (auto-finds available)
94
+ - WebSocket support for real-time element selection
95
+ - Handles screen recording uploads and workflow recording
96
+ - CORS-enabled for cross-origin requests
97
+
98
+ 4. **Database** (`src/database.js`)
99
+ - SQLite database for persistent storage
100
+ - Stores screen recordings and workflow data
101
+ - Located at `data/chrome-pilot.db`
102
+
103
+ 5. **Capture System** (`src/capture/`)
104
+ - Modular frame capture architecture
105
+ - Memory management for large video recordings
106
+ - TypeScript-style interfaces defined in `interfaces.js`
107
+ - Optimized for AI analysis and debugging workflows
108
+
109
+ ### Key Design Patterns
110
+
111
+ - **Single Chrome Instance**: Each server (MCP or HTTP) maintains one ChromeController instance
112
+ - **Per-Instance Chrome**: Each Chrome launch creates a unique user data directory
113
+ - **Automatic Cleanup**: Stale Chrome profiles are cleaned up on startup
114
+ - **Port Management**: Automatically finds available ports for debugging and HTTP server
115
+ - **Timeout Protection**: All async operations have configurable timeouts
116
+
117
+ ### Chrome Extension Features
118
+
119
+ - **Element Selection**: Click elements to select for AI manipulation
120
+ - **Screen Recording**: Capture video + console logs for debugging
121
+ - **Frame Capture**: Optimized frame capture for videos
122
+ - **WebRTC Override**: Redirects webcam to screen capture
123
+
124
+ ### MCP Tools Available
125
+
126
+ - `launch_chrome` - Start new Chrome instance
127
+ - `connect_to_existing_chrome` - Connect to existing Chrome with debugging enabled
128
+ - `navigate_to` - Navigate to URL
129
+ - `take_screenshot` - Capture page screenshot (AI-optimized by default)
130
+ - `get_page_content` - Extract page text, HTML, and DOM structure
131
+ - `evaluate_expression` - Execute JavaScript
132
+ - `get_selected_element` - Get currently selected element
133
+ - `apply_css_to_selected` - Apply CSS to selected element
134
+ - `execute_js_on_selected` - Run JS on selected element
135
+ - `clear_selected_element` - Clear current element selection
136
+ - `pause_execution` / `resume_execution` - Debugger control
137
+ - `step_over` - Step over in debugger
138
+ - `set_breakpoint` - Set debugging breakpoints
139
+ - `get_scopes` - Get scope variables from top call frame
140
+ - `get_logs` - Retrieve console logs
141
+ - `check_connection` - Check Chrome connection status
142
+ - `force_reset` - Force reset Chrome instance
143
+ - `get_websocket_info` - Get WebSocket server info for extension
144
+ - `get_workflow_recording` - Retrieve workflow recording with actions/logs (WARNING: Can be very large)
145
+ - `list_workflow_recordings` - List all workflow recordings
146
+ - `get_workflow_function_traces` - Get only function execution traces from a workflow
147
+ - `get_workflow_errors` - Get only error logs and error-related actions
148
+ - `get_workflow_summary` - Get a concise summary of a workflow recording
149
+ - `get_workflow_actions_filtered` - Get filtered workflow actions by type with pagination
150
+ - `save_restore_point` - Save browser state restore point
151
+ - `restore_from_point` - Restore browser to saved point
152
+ - `list_restore_points` - List restore points for workflow
153
+ - `chrome_pilot_show_frames` - Display frame recording info
154
+ - `get_frame_session_info` - Get frame capture session info
155
+ - `get_frame` - Get specific frame from recording
156
+ - `get_frame_screenshot` - Get screenshot image data for a specific frame as base64
157
+ - `search_frame_logs` - Search logs across all frames
158
+ - `get_frame_logs_paginated` - Get paginated frame logs
159
+ - `play_workflow_recording` - Replay a saved workflow recording
160
+ - `play_workflow_by_name` - Replay workflow by recording name
161
+
162
+ ## Important Files and Locations
163
+
164
+ - Chrome user data: Temporary directories in OS temp folder
165
+ - Database: `data/chrome-pilot.db` (SQLite)
166
+ - Chrome extension: `chrome-extension/` directory
167
+ - VS Code extension: `vscode-chrome-pilot/` directory
168
+ - HTTP server logs: `http-server.log`
169
+ - Configuration: `config/chrome-pilot-config.json`
170
+ - Test files: `test-*.js` in root directory
171
+
172
+ ## Screenshot Retrieval Feature
173
+
174
+ ### New MCP Tool: `get_frame_screenshot`
175
+ The `get_frame_screenshot` tool enables viewing of actual screenshots captured during frame recordings:
176
+
177
+ ```javascript
178
+ // Get screenshot for frame 0 with metadata
179
+ {
180
+ "name": "get_frame_screenshot",
181
+ "arguments": {
182
+ "sessionId": "frame_1756936437368_tsvn4ehi0",
183
+ "frameIndex": 0,
184
+ "includeMetadata": true
185
+ }
186
+ }
187
+ ```
188
+
189
+ Returns base64-encoded JPEG image data that can be displayed or saved:
190
+ - `imageData`: Base64 string of the screenshot
191
+ - `imageFormat`: Format (always 'jpeg' for Chrome Debug)
192
+ - `metadata`: Optional size, encoding, and capture time info
193
+ - Full error handling for invalid sessions/frames
194
+
195
+ ### Usage Examples
196
+ - **View specific moments**: Get screenshots from any frame in a recording
197
+ - **Debug visual issues**: See exactly what was displayed when an error occurred
198
+ - **Extract UI snapshots**: Save screenshots for documentation or analysis
199
+ - **Verify user interactions**: Visual confirmation of what users clicked
200
+
201
+ ## Common Workflows
202
+
203
+ ### Adding New MCP Tools
204
+ 1. Add tool definition to `tools` array in `src/index.js`
205
+ 2. Implement handler in the `CallToolRequestSchema` handler
206
+ 3. Add corresponding method in `ChromeController` class
207
+
208
+ ### Adding New HTTP Endpoints
209
+ 1. Add route in `src/http-server.js`
210
+ 2. Implement logic using `chromeController` instance
211
+ 3. Update README.md with endpoint documentation
212
+
213
+ ### Modifying Chrome Extension
214
+ 1. Edit files in `chrome-extension/` directory
215
+ 2. Reload extension in Chrome (chrome://extensions/)
216
+ 3. Test functionality before packaging
217
+
218
+ ## Error Handling
219
+
220
+ - All async operations use `withTimeout()` wrapper
221
+ - Chrome processes are tracked and killed on cleanup
222
+ - WebSocket connections are managed in a Set for cleanup
223
+ - Database operations use transactions for consistency
224
+
225
+ ## Security Considerations
226
+
227
+ - CORS enabled for cross-origin requests
228
+ - Request size limits: 50MB for JSON/URL-encoded
229
+ - Chrome runs with separate user data directories
230
+ - No persistent cookies between sessions
231
+
232
+ ## CLI Usage
233
+
234
+ Chrome Debug provides a CLI tool that can be used directly:
235
+ ```bash
236
+ chromedebug-mcp # Runs the MCP server (equivalent to npm start)
237
+ npx chromedebug-mcp # Run without global installation
238
+ ```
239
+
240
+ The package name is `chromedebug-mcp` but the project is commonly referred to as Chrome Debug.
241
+
242
+ ## Additional Architecture Notes
243
+
244
+ ### Port Discovery
245
+ - Server automatically finds available port from configured list (default: 3001, 3000, 3002, 3028)
246
+ - Port selection stored in `config/chrome-pilot-config.json`
247
+ - Extension automatically updated with current port via `npm run update-extension-config`
248
+
249
+ ### Frame Recording System
250
+ - Captures screenshots and console logs during browser sessions
251
+ - Stores frame data in SQLite with session IDs
252
+ - Supports searching logs across frames
253
+ - Optimized for AI analysis with low-res JPEG capture
254
+ - **NEW**: Screenshots can be retrieved as base64 data for viewing with `get_frame_screenshot`
255
+
256
+ ### Workflow Recording
257
+ - Records user actions and browser state
258
+ - Supports restore points for reverting to previous states
259
+ - Stores DOM snapshots, form values, storage, and cookies
260
+ - Enables replay and debugging of complex workflows
261
+
262
+ ### Testing Framework
263
+ - **Jest-based**: Uses Jest with ES modules support (`NODE_OPTIONS='--experimental-vm-modules'`)
264
+ - **Test Structure**: Tests located in `tests/` directory
265
+ - **Coverage**: Excludes legacy code and CLI from coverage reports
266
+ - **Specialized Test Suites**: Recording system, extension integration, database migration
267
+ - **Timeouts**: 30-second timeout for tests involving browser automation
268
+ - **Setup**: Custom test setup in `tests/setup.js`
269
+
270
+ ## Development Guidelines
271
+
272
+ ### Code Review Process
273
+ - **ALWAYS** run all plans by the second-opinion-analyst agent before implementation
274
+ - This applies to significant changes including:
275
+ - Architectural changes (adding/removing systems, modifying core patterns)
276
+ - Bug fixes that affect multiple components
277
+ - Performance optimizations that alter timing or execution flow
278
+ - State management changes (especially lease system, session management)
279
+ - Race condition fixes
280
+ - Error handling modifications
281
+
282
+ ### Why Second Opinion Matters
283
+ The second-opinion-analyst helps prevent:
284
+ - **Symptom fixes**: Addressing surface issues without fixing root causes
285
+ - **Cascade effects**: Changes that solve one problem but create others
286
+ - **Technical debt**: Quick fixes that make future maintenance harder
287
+ - **Defensive over-engineering**: Adding unnecessary complexity "just in case"
288
+
289
+ ### When to Skip Second Opinion
290
+ - Simple documentation updates
291
+ - Test additions (without changing behavior)
292
+ - Formatting/linting fixes
293
+ - Variable/function renaming
294
+
295
+ ### Example Process
296
+ 1. Identify the problem and proposed solution
297
+ 2. Use the second-opinion-analyst agent to review the approach
298
+ 3. Adjust based on feedback (addressing root causes, not symptoms)
299
+ 4. Implement the approved solution
300
+ 5. Test thoroughly to verify the fix
301
+
302
+ ---
303
+
304
+ ## Standard Operating Procedure for All Changes
305
+
306
+ ### Team-Based Development Process
307
+
308
+ **All significant changes MUST follow this workflow:**
309
+
310
+ 1. **Strategic Planning Phase**
311
+ - Work with the Strategic Project Manager agent to plan implementation
312
+ - Present plan to user for approval
313
+ - If plan changes during implementation, alert user before proceeding
314
+
315
+ 2. **Second Opinion Review**
316
+ - Second Opinion Agent MUST approve all plans and changes
317
+ - Review for unintended consequences and system-wide impacts
318
+ - Ensure root causes are addressed, not symptoms
319
+
320
+ 3. **TrustButVerify Integration**
321
+ - **Before Starting:** Use `trustbutverify.impact_predict` to identify affected areas
322
+ - **During Development:** After each major function, use `trustbutverify.microtest_generate_and_run`
323
+ - **After Completion:** Run `trustbutverify.verify_fix` with `includeReplay: true`
324
+ - **Quality Gate:** Only mark complete and proceed if risk score is below 0.3
325
+
326
+ 4. **Specialized Agent Assignment**
327
+ - Chrome Debug Agent: Handles all Chrome Debug codebase changes
328
+ - Use domain-specific agents for specialized work:
329
+ - Firebase Implementation Expert for Firebase changes
330
+ - React Optimization Expert for React/UI changes
331
+ - Android Platform Expert for Android work
332
+ - etc.
333
+
334
+ 5. **No TODO Lists for New Projects**
335
+ - Build functionality directly, don't create TODO items
336
+ - Complete implementation in single workflow
337
+ - Use TrustButVerify for validation instead of tracking
338
+
339
+ ### Quality Standards
340
+
341
+ - Risk score must be below 0.3 before proceeding
342
+ - All changes must pass microtest validation
343
+ - Impact prediction required before starting
344
+ - Replay verification required for completion
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 dynamicupgrade
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # ChromeDebug MCP
2
+
3
+ [![npm version](https://badge.fury.io/js/%40dynamicu%2Fchromedebug-mcp.svg)](https://www.npmjs.com/package/@dynamicu/chromedebug-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ ChromeDebug MCP is a Model Context Protocol (MCP) server that gives AI assistants like Claude Code full control over a Chrome browser instance. It provides comprehensive browser automation, debugging, and screen recording capabilities optimized for AI-assisted development.
7
+
8
+ ## Quick Start
9
+
10
+ ### Installation from npm
11
+
12
+ ```bash
13
+ # Install globally
14
+ npm install -g @dynamicu/chromedebug-mcp
15
+
16
+ # Or install locally in your project
17
+ npm install @dynamicu/chromedebug-mcp
18
+ ```
19
+
20
+ ### Development Installation
21
+
22
+ ```bash
23
+ # Clone and install from source
24
+ git clone https://github.com/dynamicupgrade/ChromePilot.git
25
+ cd ChromePilot
26
+ npm install
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### As MCP Server
32
+
33
+ To add Chrome Debug to your Claude desktop app:
34
+
35
+ ```bash
36
+ claude mcp add chromepilot -s user -- chrome-pilot
37
+ ```
38
+
39
+ ### Embedded HTTP Server
40
+
41
+ Chrome Debug automatically starts an embedded HTTP server for Chrome extension communication. The server uses ports configured in `config/chrome-pilot-config.json` (default: 3001, 3000, 3002, 3028). The server provides these REST API endpoints:
42
+
43
+ | Endpoint | Method | Description | Body |
44
+ |----------|--------|-------------|------|
45
+ | `/chrome-pilot/pause` | POST | Pause execution | - |
46
+ | `/chrome-pilot/resume` | POST | Resume execution | - |
47
+ | `/chrome-pilot/step-over` | POST | Step over | - |
48
+ | `/chrome-pilot/evaluate` | POST | Evaluate expression | `{ "expression": "window.user" }` |
49
+ | `/chrome-pilot/scopes` | GET | Get scope variables | - |
50
+ | `/chrome-pilot/set-breakpoint` | POST | Set breakpoint | `{ "url": "file.js", "lineNumber": 10 }` |
51
+ | `/chrome-pilot/logs` | GET | Get recent console logs | - |
52
+ | `/chrome-pilot/screenshot` | POST | Take screenshot | `{ "type": "jpeg", "fullPage": true, "path": "/path/to/save.jpg" }` |
53
+ | `/chrome-pilot/dom-intent` | POST | Process natural language DOM commands | `{ "selector": "#element", "instruction": "make it blue" }` |
54
+ | `/chrome-pilot/status` | GET | Check server and Chrome connection status | - |
55
+ | `/chrome-pilot/recording` | POST | Upload screen recording with logs | FormData with video file, logs JSON, and duration |
56
+ | `/chrome-pilot/recording/:id` | GET | Retrieve a recording by ID | - |
57
+ | `/chrome-pilot/workflow-recording` | POST | Save workflow recording | `{ "sessionId": "...", "actions": [...], "logs": [...] }` |
58
+ | `/chrome-pilot/workflow-recording/:id` | GET | Get workflow recording | - |
59
+ | `/chrome-pilot/restore-point` | POST | Save restore point | `{ "workflowId": "...", "domSnapshot": {...}, ... }` |
60
+ | `/chrome-pilot/restore-point/:id` | GET/DELETE | Get or delete restore point | - |
61
+ | `/chrome-pilot/restore-points/:workflowId` | GET | List restore points for workflow | - |
62
+
63
+ ### MCP Tools
64
+
65
+ When used as an MCP server, Chrome Debug exposes these tools:
66
+
67
+ - `launch_chrome` - Launch a Chrome browser instance
68
+ - `pause_execution` - Pause Chrome execution
69
+ - `resume_execution` - Resume Chrome execution
70
+ - `step_over` - Step over in debugger
71
+ - `evaluate_expression` - Evaluate JavaScript expression
72
+ - `get_scopes` - Get scope variables
73
+ - `set_breakpoint` - Set a breakpoint
74
+ - `get_logs` - Get console logs
75
+ - `take_screenshot` - Take a screenshot
76
+ - `get_page_content` - Get page content (text, HTML, and DOM structure)
77
+ - `check_connection` - Check Chrome connection status
78
+ - `force_reset` - Force reset Chrome instance
79
+ - `get_selected_element` - Get info about element selected via extension
80
+ - `apply_css_to_selected` - Apply CSS to the selected element
81
+ - `execute_js_on_selected` - Execute JavaScript on the selected element
82
+ - `clear_selected_element` - Clear the current selection
83
+ - `get_workflow_recording` - Get a workflow recording with actions and logs
84
+ - `list_workflow_recordings` - List all workflow recordings
85
+ - `save_restore_point` - Save a restore point for the current browser state
86
+ - `restore_from_point` - Restore browser to a saved restore point
87
+ - `list_restore_points` - List restore points for a workflow
88
+
89
+ ## Example
90
+
91
+ ```bash
92
+ # Start the server (automatically kills existing processes and finds available port)
93
+ npm start
94
+
95
+ # The server will display the port it's running on:
96
+ # 🚀 Starting Chrome Debug Server on port 3000...
97
+ # 📍 Extension should connect to: http://localhost:3000
98
+ # 🔧 MCP tools will use this port for API calls
99
+
100
+ # In another terminal, test the API (use the port shown in startup)
101
+ curl -X POST http://localhost:3000/chrome-pilot/pause
102
+ curl -X POST http://localhost:3000/chrome-pilot/evaluate \
103
+ -H "Content-Type: application/json" \
104
+ -d '{"expression": "document.title"}'
105
+ ```
106
+
107
+ ## Chrome Extension - Visual Element Selection
108
+
109
+ Chrome Debug includes a Chrome extension that enables visual element selection for MCP control:
110
+
111
+ ### Installing the Extension
112
+
113
+ 1. Open Chrome and navigate to `chrome://extensions/`
114
+ 2. Enable "Developer mode"
115
+ 3. Click "Load unpacked" and select the `chrome-extension` directory
116
+
117
+ ### Using the Extension
118
+
119
+ 1. **Element Selection**
120
+ - Click on any element on a webpage
121
+ - The element is sent to Chrome Debug and highlighted in pink
122
+ - Use Claude MCP tools to modify the selected element:
123
+ - `get_selected_element` - View the currently selected element
124
+ - `apply_css_to_selected` - Apply CSS styles to the element
125
+ - `execute_js_on_selected` - Execute JavaScript on the element
126
+ - `clear_selected_element` - Clear the selection
127
+
128
+ 2. **Workflow Recording**
129
+ - Click "Start Workflow Recording" to record user interactions
130
+ - All clicks, inputs, and drags are captured
131
+ - Console logs can be included in the recording
132
+ - Workflows can be replayed later for debugging
133
+
134
+ 3. **Restore Points** (NEW)
135
+ - During workflow recording, click "📍 Save Restore Point" to capture browser state
136
+ - Captures DOM, form values, storage, cookies, and scroll position
137
+ - Restore to any saved point to retry workflows from that state
138
+ - Perfect for debugging multi-step forms or complex interactions
139
+ - See [RESTORE_POINTS.md](RESTORE_POINTS.md) for details
140
+
141
+ ## Development
142
+
143
+ ```bash
144
+ npm run dev # Run with --watch flag
145
+ ```
146
+
147
+ ## Example Prompts for Claude
148
+
149
+ Once Chrome Debug is installed as an MCP server, you can use these prompts with Claude:
150
+
151
+ ### Basic Browser Control
152
+ - "Launch Chrome and navigate to https://example.com"
153
+ - "Evaluate document.title in the browser"
154
+ - "Get all the links on the current page"
155
+ - "Take a screenshot of the current page"
156
+
157
+ ### Debugging JavaScript
158
+ - "Set a breakpoint on line 42 of app.js and tell me what variables are in scope when it hits"
159
+ - "Pause execution and show me the current call stack"
160
+ - "Step through the code and watch how the 'counter' variable changes"
161
+ - "Evaluate localStorage.getItem('user') in the browser console"
162
+
163
+ ### Web Scraping & Automation
164
+ - "Navigate to https://news.ycombinator.com and get the titles of the top 5 stories"
165
+ - "Fill out the search form with 'JavaScript' and submit it"
166
+ - "Click the login button and enter username 'test' and password 'demo'"
167
+ - "Monitor the network requests and show me all API calls"
168
+
169
+ ### Debugging Web Apps
170
+ - "Show me all console errors on this page"
171
+ - "Watch for any uncaught exceptions and report them"
172
+ - "Profile the page load performance"
173
+ - "Check if there are any memory leaks by monitoring heap usage"
174
+
175
+ ### Advanced Debugging
176
+ - "Set conditional breakpoints when userId === 5"
177
+ - "Trace the execution flow of the checkout() function"
178
+ - "Show me all event listeners attached to the submit button"
179
+ - "Evaluate the current state of the Redux store"
180
+
181
+ ### Visual Element Modification
182
+ After selecting an element with the Chrome extension:
183
+ - "Show me what element is currently selected"
184
+ - "Make the selected element blue with rounded corners"
185
+ - "Apply CSS: background-color: #2196F3 !important; padding: 20px !important"
186
+ - "Hide the selected element"
187
+ - "Execute JavaScript to get the element's text content"
188
+ - "Click the selected element"
189
+ - "Clear the selected element"
190
+
191
+ ## Screen Recording Feature
192
+
193
+ Chrome Debug includes a powerful screen recording feature that captures video of the current tab along with synchronized console logs. This helps users explain issues more effectively by providing visual context with technical details.
194
+
195
+ ### How to Use Recording
196
+
197
+ 1. **Start Recording:**
198
+ - Click the Chrome Debug extension icon
199
+ - Click "Start Recording" button
200
+ - The browser will prompt for permission to capture the tab
201
+ - Recording starts immediately after permission is granted
202
+
203
+ 2. **During Recording:**
204
+ - The button changes to "Stop Recording" and pulses red
205
+ - A timer shows the recording duration
206
+ - All console logs (log, warn, error, info) are captured with timestamps
207
+ - Continue using the browser normally - all interactions are recorded
208
+
209
+ 3. **Stop Recording:**
210
+ - Click "Stop Recording" button
211
+ - The video and logs are automatically uploaded to the Chrome Debug server
212
+ - You'll receive a recording ID (e.g., `rec_1234567890_abc123`)
213
+
214
+ 4. **Share with Claude:**
215
+ - Tell Claude: "Get recording rec_1234567890_abc123"
216
+ - Claude will retrieve the video and synchronized console logs
217
+ - The logs show precise timing relative to the video
218
+
219
+ ### Recording Details
220
+
221
+ - **Video Format:** WebM with VP9 codec for efficient compression
222
+ - **Resolution:** Up to 1920x1080 (adapts to tab size)
223
+ - **Console Logs:** Captured with millisecond precision timestamps
224
+ - **User Interactions:** Mouse clicks, keyboard input, scrolling automatically captured
225
+ - **Storage:** Recordings are stored temporarily (last 10 recordings kept)
226
+ - **No Audio:** Audio is not captured to focus on visual debugging
227
+
228
+ ### Captured Interactions
229
+
230
+ Screen recordings now automatically capture all user interactions:
231
+
232
+ - **Clicks:** Position, element selector, XPath, and clicked text
233
+ - **Input:** Text entered into forms with field selectors
234
+ - **Keypresses:** Special keys like Enter, Escape, Tab
235
+ - **Scrolling:** Scroll positions throughout the recording
236
+
237
+ ### Example Use Cases
238
+
239
+ - **Bug Reports:** Record the exact steps to reproduce an issue
240
+ - **UI Problems:** Show visual glitches or unexpected behavior
241
+ - **Performance Issues:** Capture slow interactions with console timing
242
+ - **Complex Workflows:** Document multi-step processes that are hard to explain
243
+ - **User Testing:** Review exactly how users interact with your interface
244
+
245
+ ### MCP Tools for Recording
246
+
247
+ - `get_recording` - Retrieve a recording by ID to analyze video and logs
248
+ - `chrome_pilot_show_frames` - Display frame-by-frame recording with interactions and logs
249
+ - `get_frame` - Get specific frame with its interactions and console logs
250
+ - `get_screen_interactions` - Query specific interaction data from recordings
@@ -0,0 +1,41 @@
1
+ # Chrome Debug Assistant Extension
2
+
3
+ This Chrome extension enables visual element selection for the Chrome Debug MCP server.
4
+
5
+ ## Installation
6
+
7
+ 1. Open Chrome and navigate to `chrome://extensions/`
8
+ 2. Enable "Developer mode" (toggle in the top right)
9
+ 3. Click "Load unpacked"
10
+ 4. Select the `chrome-extension` directory
11
+
12
+ ## Usage
13
+
14
+ 1. Ensure the Chrome Debug MCP server is running (`npm start`)
15
+ 2. Navigate to any webpage
16
+ 3. Click on any element to select it
17
+ 4. The element will be:
18
+ - Highlighted with a pink outline
19
+ - Sent to Chrome Debug server
20
+ - Available for modification via Claude MCP tools
21
+
22
+ ## How it Works
23
+
24
+ 1. Click any element on the page
25
+ 2. The extension sends the element's selector to Chrome Debug
26
+ 3. Use Claude in your terminal to modify the selected element:
27
+ ```
28
+ "Show me what element is currently selected"
29
+ "Make the selected element blue"
30
+ "Apply CSS: padding: 20px !important; border-radius: 8px !important"
31
+ "Execute JavaScript to get the element's text content"
32
+ "Clear the selected element"
33
+ ```
34
+
35
+ ## Features
36
+
37
+ - Visual element selection with hover highlighting
38
+ - Automatic server detection (scans ports 3000-3025)
39
+ - Pink outline shows currently selected element
40
+ - Server connection status indicator
41
+ - One-click element selection