@debugelectron/debug-electron-mcp 1.6.10 → 1.7.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/README.md +242 -699
- package/dist/86.index.js +1077 -0
- package/dist/86.index.js.map +1 -0
- package/dist/create-server.d.ts +7 -0
- package/dist/handlers.d.ts +1 -0
- package/dist/index.js +6672 -5994
- package/dist/index.js.map +1 -1
- package/dist/project-registry.d.ts +24 -0
- package/dist/schemas.d.ts +36 -0
- package/dist/screenshot.d.ts +2 -0
- package/dist/serve.d.ts +6 -0
- package/dist/tools.d.ts +4 -1
- package/dist/utils/electron-connection.d.ts +2 -0
- package/dist/utils/electron-discovery.d.ts +8 -3
- package/dist/utils/electron-logs.d.ts +5 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,63 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
# Debug Electron MCP
|
|
2
2
|
|
|
3
|
-
[](LICENSE)
|
|
4
3
|
[](https://www.npmjs.com/package/@debugelectron/debug-electron-mcp)
|
|
4
|
+
[](LICENSE)
|
|
5
5
|
[](https://modelcontextprotocol.io)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**The ultimate Model Context Protocol (MCP) server for automating, debugging, and testing Electron applications.**
|
|
8
|
+
|
|
9
|
+
Use the power of AI to interact with ANY Electron application. Inspect the DOM, click buttons by text, fill forms, capture screenshots, and read console logs—all through a standardized protocol compatible with Claude Code, Claude Desktop, Cursor, and other MCP clients.
|
|
10
|
+
|
|
11
|
+
Install it once globally — it auto-detects which project you're in and scopes itself. Works with multiple Electron apps across multiple sessions with zero extra config.
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
---
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
- [Features](#features)
|
|
18
|
+
- [Quick Start](#quick-start)
|
|
19
|
+
- [How Multi-Project Works](#how-multi-project-works)
|
|
20
|
+
- [Enabling Remote Debugging (Required)](#enabling-remote-debugging-required)
|
|
21
|
+
- [Usage Guide](#usage-guide)
|
|
22
|
+
- [Core Workflow](#core-workflow)
|
|
23
|
+
- [Tool Reference](#tool-reference)
|
|
24
|
+
- [Project Management Tools](#project-management-tools)
|
|
25
|
+
- [Interaction Commands](#interaction-commands)
|
|
26
|
+
- [Advanced: HTTP Server Mode](#advanced-http-server-mode)
|
|
27
|
+
- [Development](#development)
|
|
28
|
+
- [Troubleshooting](#troubleshooting)
|
|
29
|
+
- [License](#license)
|
|
12
30
|
|
|
13
|
-
|
|
14
|
-
- **📸 Visual Debugging**: Take screenshots and capture application state without interrupting development
|
|
15
|
-
- **🔍 Deep Inspection**: Extract DOM elements, application data, and performance metrics in real-time
|
|
16
|
-
- **⚡ DevTools Protocol Integration**: Universal compatibility with any Electron app - no modifications required
|
|
17
|
-
- **🚀 Development Observability**: Monitor logs, system info, and application behavior seamlessly
|
|
31
|
+
---
|
|
18
32
|
|
|
19
|
-
##
|
|
33
|
+
## Features
|
|
20
34
|
|
|
21
|
-
###
|
|
35
|
+
### Universal Compatibility
|
|
36
|
+
- **Works with ANY Electron app**: No source code modifications required.
|
|
37
|
+
- **Zero-setup integration**: Connects purely via Chrome DevTools Protocol (CDP).
|
|
38
|
+
- **Cross-platform**: Supports Windows, macOS, and Linux.
|
|
22
39
|
|
|
23
|
-
-
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
40
|
+
### Auto-Detect & Multi-Project
|
|
41
|
+
- **Automatic project detection**: Reads your `package.json` name or folder name — each project gets its own port automatically.
|
|
42
|
+
- **No config per project**: Install the MCP once globally. Open Claude Code in any Electron project and it just works.
|
|
43
|
+
- **Multiple apps, no conflicts**: App A on port 9222, App B on port 9223 — each Claude Code session only talks to its own app.
|
|
44
|
+
- **Shared registry on disk**: `~/.debug-electron-mcp.json` persists port assignments across sessions and restarts.
|
|
27
45
|
|
|
28
|
-
###
|
|
46
|
+
### Smart UI Automation
|
|
47
|
+
- **Semantic Interaction**: specific `click_by_text` and `fill_input` commands that "just work."
|
|
48
|
+
- **Visual Intelligence**: Take screenshots of specific windows to verify state.
|
|
49
|
+
- **Robust Actions**: Advanced `drag`, `hover`, `type`, and `wait` commands for complex workflows.
|
|
29
50
|
|
|
30
|
-
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
51
|
+
### Deep Observability
|
|
52
|
+
- **DOM Inspection**: `get_page_structure` gives AI a clean copy of the interactive operational map.
|
|
53
|
+
- **Log Streaming**: Read main process, renderer, and console logs in real-time.
|
|
54
|
+
- **Performance**: Monitor memory, timing, and system metrics.
|
|
34
55
|
|
|
35
|
-
|
|
56
|
+
---
|
|
36
57
|
|
|
37
|
-
|
|
38
|
-
- **DevTools Integration**: Leverage Chrome DevTools Protocol for powerful debugging capabilities
|
|
39
|
-
- **Build Automation**: Cross-platform building for Windows, macOS, and Linux
|
|
40
|
-
- **Environment Management**: Clean environment handling and debugging port configuration
|
|
58
|
+
## Quick Start
|
|
41
59
|
|
|
42
|
-
|
|
60
|
+
### Step 1: Add to your MCP config (one time)
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
#### Claude Code (Global — recommended)
|
|
45
63
|
|
|
46
|
-
|
|
64
|
+
Add to `~/.claude/settings.json`:
|
|
47
65
|
```json
|
|
48
66
|
{
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"args": ["-y", "@debugelectron/debug-electron-mcp@latest"]
|
|
54
|
-
}
|
|
67
|
+
"mcpServers": {
|
|
68
|
+
"debug-electron-mcp": {
|
|
69
|
+
"command": "npx",
|
|
70
|
+
"args": ["-y", "@debugelectron/debug-electron-mcp@latest"]
|
|
55
71
|
}
|
|
56
72
|
}
|
|
57
73
|
}
|
|
58
74
|
```
|
|
59
75
|
|
|
60
|
-
|
|
76
|
+
Done. Every Claude Code session now has the Electron tools available.
|
|
77
|
+
|
|
78
|
+
#### VS Code / Cursor
|
|
79
|
+
|
|
61
80
|
```json
|
|
62
81
|
{
|
|
63
82
|
"mcpServers": {
|
|
@@ -69,7 +88,8 @@ Transform your Electron development experience with **AI-powered automation**:
|
|
|
69
88
|
}
|
|
70
89
|
```
|
|
71
90
|
|
|
72
|
-
|
|
91
|
+
#### Claude Desktop
|
|
92
|
+
|
|
73
93
|
```json
|
|
74
94
|
{
|
|
75
95
|
"mcpServers": {
|
|
@@ -81,763 +101,286 @@ Transform your Electron development experience with **AI-powered automation**:
|
|
|
81
101
|
}
|
|
82
102
|
```
|
|
83
103
|
|
|
84
|
-
|
|
104
|
+
### Step 2: Start your Electron app with remote debugging
|
|
85
105
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
See [Quick Start](#-quick-start) above for MCP configuration. For global installation:
|
|
106
|
+
The first time you use the MCP in a project, it auto-registers the project and assigns a port. Check `list_projects()` to see your assigned port, then start your app:
|
|
89
107
|
|
|
90
108
|
```bash
|
|
91
|
-
npm install -g @debugelectron/debug-electron-mcp
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Demo
|
|
95
|
-
|
|
96
|
-
See the Electron MCP Server in action:
|
|
97
|
-
|
|
98
|
-
[](https://vimeo.com/1104937830)
|
|
99
|
-
|
|
100
|
-
**[🎬 Watch Full Demo on Vimeo](https://vimeo.com/1104937830)**
|
|
101
|
-
|
|
102
|
-
*Watch how easy it is to automate Electron applications with AI-powered MCP commands.*
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
## ⚡ Enabling Remote Debugging (Required)
|
|
106
|
-
|
|
107
|
-
**CRITICAL**: For the Electron MCP Server to communicate with your Electron application, the app **MUST** be started with Chrome DevTools Protocol (CDP) remote debugging enabled on port 9222. Without this, the MCP server cannot connect to or control the application.
|
|
108
|
-
|
|
109
|
-
### 🔍 How It Works
|
|
110
|
-
|
|
111
|
-
The Electron MCP Server uses the Chrome DevTools Protocol (CDP) to:
|
|
112
|
-
- Connect to your Electron app via WebSocket
|
|
113
|
-
- Execute JavaScript in the renderer process
|
|
114
|
-
- Capture screenshots and inspect the DOM
|
|
115
|
-
- Automate UI interactions (clicks, form fills, etc.)
|
|
116
|
-
|
|
117
|
-
The server automatically scans ports **9222-9225** to find running Electron apps with debugging enabled.
|
|
118
|
-
|
|
119
|
-
### 📋 Configuration Methods
|
|
120
|
-
|
|
121
|
-
Choose **ONE** of the following methods to enable remote debugging:
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
#### Method 1: Command Line Flag (Recommended for Quick Testing)
|
|
126
|
-
|
|
127
|
-
Start your Electron app with the `--remote-debugging-port` flag:
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# Using electron directly
|
|
131
109
|
electron . --remote-debugging-port=9222
|
|
132
|
-
|
|
133
|
-
# Using npx
|
|
134
|
-
npx electron . --remote-debugging-port=9222
|
|
135
|
-
|
|
136
|
-
# Via npm script
|
|
137
|
-
npm start -- --remote-debugging-port=9222
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
#### Method 2: Modify package.json Scripts (Recommended for Projects)
|
|
143
|
-
|
|
144
|
-
This is the most reliable method. It creates a dedicated command for launching your app with AI capabilities enabled.
|
|
145
|
-
|
|
146
|
-
**Step 1: Open your `package.json` file**
|
|
147
|
-
Locate the file in the root of your project.
|
|
148
|
-
|
|
149
|
-
**Step 2: Find the `"scripts"` section**
|
|
150
|
-
It usually looks like this:
|
|
151
|
-
```json
|
|
152
|
-
"scripts": {
|
|
153
|
-
"start": "electron .",
|
|
154
|
-
"build": "electron-builder"
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**Step 3: Add the debug script**
|
|
159
|
-
Add a new script (e.g., `"dev"`) that includes the `--remote-debugging-port=9222` flag.
|
|
160
|
-
*Make sure to add a comma (`,`) to the end of the previous line!*
|
|
161
|
-
|
|
162
|
-
```json
|
|
163
|
-
"scripts": {
|
|
164
|
-
"start": "electron .", <-- Add comma here if needed
|
|
165
|
-
"build": "electron-builder", <-- Add comma here
|
|
166
|
-
"dev": "electron . --remote-debugging-port=9222" <-- ADD THIS LINE
|
|
167
|
-
}
|
|
168
110
|
```
|
|
169
111
|
|
|
170
|
-
|
|
171
|
-
- If you use **Electron Forge**: `"dev": "electron-forge start -- -- --remote-debugging-port=9222"`
|
|
172
|
-
- If you use **Electron Builder**: `"dev": "electron-builder start -- --remote-debugging-port=9222"`
|
|
173
|
-
- Generally, append the flag after your usual start command.
|
|
174
|
-
|
|
175
|
-
**Step 4: Run the script**
|
|
176
|
-
Execute the command in your terminal:
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
npm run dev
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Your app will launch with port 9222 open, ready for the MCP server to connect.
|
|
112
|
+
That's it. The MCP auto-detects your project and scopes all commands to it.
|
|
183
113
|
|
|
184
114
|
---
|
|
185
115
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
Add this code to your Electron app's **main process** file (usually `main.js` or `main.ts`):
|
|
189
|
-
|
|
190
|
-
```javascript
|
|
191
|
-
const { app } = require('electron');
|
|
192
|
-
|
|
193
|
-
// Enable remote debugging based on environment or command line args
|
|
194
|
-
const enableRemoteDebugging =
|
|
195
|
-
process.env.NODE_ENV === 'development' ||
|
|
196
|
-
process.env.ELECTRON_MCP_DEBUG === 'true' ||
|
|
197
|
-
process.argv.includes('--dev') ||
|
|
198
|
-
process.argv.includes('--remote-debugging-port=9222');
|
|
199
|
-
|
|
200
|
-
if (enableRemoteDebugging) {
|
|
201
|
-
// IMPORTANT: This must be called BEFORE app.whenReady()
|
|
202
|
-
app.commandLine.appendSwitch('remote-debugging-port', '9222');
|
|
203
|
-
console.log('🔧 Remote debugging enabled on port 9222');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Rest of your app initialization...
|
|
207
|
-
app.whenReady().then(() => {
|
|
208
|
-
// Create windows, etc.
|
|
209
|
-
});
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
**TypeScript version:**
|
|
213
|
-
|
|
214
|
-
```typescript
|
|
215
|
-
import { app } from 'electron';
|
|
116
|
+
## How Multi-Project Works
|
|
216
117
|
|
|
217
|
-
|
|
218
|
-
process.env.NODE_ENV === 'development' ||
|
|
219
|
-
process.env.ELECTRON_MCP_DEBUG === 'true' ||
|
|
220
|
-
process.argv.includes('--dev');
|
|
118
|
+
The MCP automatically detects which project it's running in — no flags, no `projectName` in every call, no per-project config.
|
|
221
119
|
|
|
222
|
-
|
|
223
|
-
app.commandLine.appendSwitch('remote-debugging-port', '9222');
|
|
224
|
-
console.log('🔧 Remote debugging enabled on port 9222');
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
---
|
|
120
|
+
### What happens when Claude Code opens in your project:
|
|
229
121
|
|
|
230
|
-
|
|
122
|
+
1. Claude Code spawns the MCP server from your project directory
|
|
123
|
+
2. The MCP reads your `package.json` name (or uses the folder name)
|
|
124
|
+
3. If the project is already registered, it uses the existing port
|
|
125
|
+
4. If it's new, it auto-registers and assigns the next free port
|
|
126
|
+
5. All tool calls are automatically scoped to that project's port
|
|
231
127
|
|
|
232
|
-
|
|
128
|
+
### Example: Two apps, two sessions
|
|
233
129
|
|
|
234
|
-
**Windows (PowerShell):**
|
|
235
|
-
```powershell
|
|
236
|
-
$env:ELECTRON_MCP_DEBUG = "true"
|
|
237
|
-
npm start
|
|
238
130
|
```
|
|
131
|
+
# Session A: Claude Code in ~/projects/music-app/
|
|
132
|
+
# MCP auto-detects "music-app" → port 9222
|
|
133
|
+
take_screenshot() # only sees music-app
|
|
239
134
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
135
|
+
# Session B: Claude Code in ~/projects/todo-app/
|
|
136
|
+
# MCP auto-detects "todo-app" → port 9223
|
|
137
|
+
take_screenshot() # only sees todo-app
|
|
243
138
|
```
|
|
244
139
|
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
ELECTRON_MCP_DEBUG=true npm start
|
|
248
|
-
```
|
|
140
|
+
No cross-talk. No manual setup. Each session knows its app.
|
|
249
141
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
---
|
|
142
|
+
### Check your assigned port
|
|
253
143
|
|
|
254
|
-
|
|
144
|
+
Use `list_projects()` from any session to see all registered projects and their ports:
|
|
255
145
|
|
|
256
|
-
When remote debugging is properly enabled, you'll see a message like this in your console:
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
DevTools listening on ws://127.0.0.1:9222/devtools/browser/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
You can also verify by opening this URL in a browser:
|
|
263
146
|
```
|
|
264
|
-
|
|
147
|
+
list_projects()
|
|
148
|
+
# -> Registered projects (2):
|
|
149
|
+
# - music-app: port 9222 [connected (1 window(s))]
|
|
150
|
+
# - todo-app: port 9223 [not connected]
|
|
265
151
|
```
|
|
266
152
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
### 🚨 Common Issues
|
|
270
|
-
|
|
271
|
-
| Issue | Cause | Solution |
|
|
272
|
-
|-------|-------|----------|
|
|
273
|
-
| "No running Electron application found" | App not started with debugging | Use `--remote-debugging-port=9222` flag |
|
|
274
|
-
| Port 9222 already in use | Another debugger or Electron app is running | Close other apps or use a different port (9223-9225) |
|
|
275
|
-
| Connection refused | Firewall blocking localhost | Check firewall settings for port 9222 |
|
|
276
|
-
| `app.commandLine.appendSwitch` not working | Called after `app.whenReady()` | Move the call to the top of main.js, before any async code |
|
|
277
|
-
|
|
278
|
-
### 🤖 For AI Assistants
|
|
279
|
-
|
|
280
|
-
When configuring an Electron app for MCP Server:
|
|
153
|
+
### Registry persistence
|
|
281
154
|
|
|
282
|
-
|
|
283
|
-
2. **Preferred method**: Modify `package.json` to add a `dev` or `debug` script with `--remote-debugging-port=9222`
|
|
284
|
-
3. **Always verify**: After starting the app, use `get_electron_window_info` or `list_electron_windows` to confirm connection
|
|
285
|
-
4. **Port range**: The MCP server scans ports 9222-9225, so any of these ports will work
|
|
155
|
+
Port assignments are saved to `~/.debug-electron-mcp.json` and shared across all sessions:
|
|
286
156
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
### ⚠️ Critical: Argument Structure
|
|
290
|
-
|
|
291
|
-
**The most common mistake** when using this MCP server is incorrect argument structure for the `send_command_to_electron` tool.
|
|
292
|
-
|
|
293
|
-
#### ❌ Wrong (causes "selector is empty" errors):
|
|
294
|
-
|
|
295
|
-
```javascript
|
|
296
|
-
{
|
|
297
|
-
"command": "click_by_selector",
|
|
298
|
-
"args": "button.submit-btn" // ❌ Raw string - WRONG!
|
|
299
|
-
}
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
#### ✅ Correct:
|
|
303
|
-
|
|
304
|
-
```javascript
|
|
157
|
+
```json
|
|
305
158
|
{
|
|
306
|
-
"
|
|
307
|
-
"
|
|
308
|
-
"
|
|
159
|
+
"portRange": [9222, 9322],
|
|
160
|
+
"projects": {
|
|
161
|
+
"music-app": { "port": 9222 },
|
|
162
|
+
"todo-app": { "port": 9223 }
|
|
309
163
|
}
|
|
310
164
|
}
|
|
311
165
|
```
|
|
312
166
|
|
|
313
|
-
###
|
|
314
|
-
|
|
315
|
-
| Command | Required Args | Example |
|
|
316
|
-
| --------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
317
|
-
| `click_by_selector` | `{"selector": "css-selector"}` | `{"selector": "button.primary"}` |
|
|
318
|
-
| `click_by_text` | `{"text": "button text"}` | `{"text": "Submit"}` |
|
|
319
|
-
| `hover` | `{"selector": "css-selector"}` | `{"selector": "#menu-item"}` |
|
|
320
|
-
| `drag` | `{"startSelector": "source", "endSelector": "target"}` | `{"startSelector": "#item", "endSelector": "#zone"}` |
|
|
321
|
-
| `wait` | `{"duration": 1000}` or `{"selector": "..."}` or `{"text": "..."}` | `{"selector": "#loaded-content"}` |
|
|
322
|
-
| `type` | `{"selector": "...", "text": "..."}` | `{"selector": "#search", "text": "hello"}` |
|
|
323
|
-
| `fill_input` | `{"value": "text", "selector": "..."}` or `{"value": "text", "placeholder": "..."}` | `{"placeholder": "Enter name", "value": "John"}` |
|
|
324
|
-
| `get_attribute` | `{"selector": "...", "attribute": "..."}` | `{"selector": "img", "attribute": "src"}` |
|
|
325
|
-
| `is_visible` | `{"selector": "..."}` | `{"selector": "#error-message"}` |
|
|
326
|
-
| `count` | `{"selector": "..."}` | `{"selector": ".list-item"}` |
|
|
327
|
-
| `send_keyboard_shortcut` | `{"text": "key combination"}` | `{"text": "Ctrl+N"}` |
|
|
328
|
-
| `eval` | `{"code": "javascript"}` | `{"code": "document.title"}` |
|
|
329
|
-
| `get_title`, `get_url`, `get_body_text` | No args needed | `{}` or omit args |
|
|
330
|
-
|
|
331
|
-
### 🔄 Recommended Workflow
|
|
332
|
-
|
|
333
|
-
1. **Inspect**: Start with `get_page_structure` or `debug_elements`
|
|
334
|
-
2. **Target**: Use specific selectors or text-based targeting
|
|
335
|
-
3. **Interact**: Use the appropriate command with correct argument structure
|
|
336
|
-
4. **Verify**: Take screenshots or check page state
|
|
167
|
+
### Manual project management
|
|
337
168
|
|
|
338
|
-
|
|
339
|
-
// Step 1: Understand the page
|
|
340
|
-
{
|
|
341
|
-
"command": "get_page_structure"
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Step 2: Click button using text (most reliable)
|
|
345
|
-
{
|
|
346
|
-
"command": "click_by_text",
|
|
347
|
-
"args": {
|
|
348
|
-
"text": "Create New Encyclopedia"
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Step 3: Fill form field
|
|
353
|
-
{
|
|
354
|
-
"command": "fill_input",
|
|
355
|
-
"args": {
|
|
356
|
-
"placeholder": "Enter encyclopedia name",
|
|
357
|
-
"value": "AI and Machine Learning"
|
|
358
|
-
}
|
|
359
|
-
}
|
|
169
|
+
You can also manage projects explicitly with the built-in tools:
|
|
360
170
|
|
|
361
|
-
// Step 4: Submit with selector
|
|
362
|
-
{
|
|
363
|
-
"command": "click_by_selector",
|
|
364
|
-
"args": {
|
|
365
|
-
"selector": "button[type='submit']"
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
171
|
```
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
| -------------------------------- | -------------------------------- | ------------------------------ |
|
|
374
|
-
| "The provided selector is empty" | Passing string instead of object | Use `{"selector": "..."}` |
|
|
375
|
-
| "Element not found" | Wrong selector | Use `get_page_structure` first |
|
|
376
|
-
| "Click prevented - too soon" | Rapid consecutive clicks | Wait before retrying |
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
## 🔧 Available Tools
|
|
384
|
-
|
|
385
|
-
### `launch_electron_app`
|
|
386
|
-
|
|
387
|
-
Launch an Electron application with debugging capabilities.
|
|
388
|
-
|
|
389
|
-
```javascript
|
|
390
|
-
{
|
|
391
|
-
"appPath": "/path/to/electron-app",
|
|
392
|
-
"devMode": true, // Enables Chrome DevTools Protocol on port 9222
|
|
393
|
-
"args": ["--enable-logging", "--dev"]
|
|
394
|
-
}
|
|
172
|
+
register_project({ projectName: "my-app" }) # register with auto-assigned port
|
|
173
|
+
register_project({ projectName: "my-app", port: 9250 }) # register with specific port
|
|
174
|
+
unregister_project({ projectName: "old-app" }) # free a port
|
|
175
|
+
list_projects() # see all projects
|
|
395
176
|
```
|
|
396
177
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
### `get_electron_window_info`
|
|
178
|
+
### Override with projectName
|
|
400
179
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
```javascript
|
|
404
|
-
{
|
|
405
|
-
"includeChildren": true // Include child windows and DevTools instances
|
|
406
|
-
}
|
|
180
|
+
If you need to target a different project from the current session, pass `projectName` explicitly:
|
|
407
181
|
```
|
|
408
|
-
|
|
409
|
-
**Returns**:
|
|
410
|
-
|
|
411
|
-
- Window IDs, titles, URLs, and types
|
|
412
|
-
- DevTools Protocol target information
|
|
413
|
-
- Platform details and process information
|
|
414
|
-
|
|
415
|
-
### `take_screenshot`
|
|
416
|
-
|
|
417
|
-
Capture high-quality screenshots using Playwright and Chrome DevTools Protocol.
|
|
418
|
-
|
|
419
|
-
```javascript
|
|
420
|
-
{
|
|
421
|
-
"outputPath": "/path/to/screenshot.png", // Optional: defaults to temp directory
|
|
422
|
-
"windowTitle": "My App" // Optional: target specific window
|
|
423
|
-
}
|
|
182
|
+
take_screenshot({ projectName: "other-app" })
|
|
424
183
|
```
|
|
425
184
|
|
|
426
|
-
|
|
185
|
+
---
|
|
427
186
|
|
|
428
|
-
|
|
429
|
-
- Works with any Electron app
|
|
430
|
-
- Fallback to platform-specific tools if needed
|
|
187
|
+
## Enabling Remote Debugging (Required)
|
|
431
188
|
|
|
432
|
-
|
|
189
|
+
Your Electron app **must be running with remote debugging enabled** on the port assigned to your project.
|
|
433
190
|
|
|
434
|
-
|
|
191
|
+
Use `list_projects()` to check your assigned port, then start your app with that port.
|
|
435
192
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
"args": {
|
|
440
|
-
"code": "document.querySelector('button').click(); 'Button clicked!'"
|
|
441
|
-
}
|
|
442
|
-
}
|
|
193
|
+
### Method 1: Command Line Flag (Easiest)
|
|
194
|
+
```bash
|
|
195
|
+
electron . --remote-debugging-port=9222
|
|
443
196
|
```
|
|
444
197
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
- `select_option`: Select dropdown options by value or visible text
|
|
451
|
-
- `hover`: Hover over elements (simulates mouseenter/mouseover)
|
|
452
|
-
- `drag`: Drag elements from one location to another (supports dataTransfer)
|
|
453
|
-
- `wait`: Wait for duration, element selector, or text presence
|
|
454
|
-
- `type`: Type text character-by-character into inputs
|
|
455
|
-
- `get_attribute`: Get value of any element attribute
|
|
456
|
-
- `is_visible`: Check if element exists and is visible in viewport
|
|
457
|
-
- `count`: Count elements matching a selector (total and visible)
|
|
458
|
-
- `get_page_structure`: Get organized overview of all page elements (buttons, inputs, selects, links)
|
|
459
|
-
- `get_title`: Get document title
|
|
460
|
-
- `get_url`: Get current URL
|
|
461
|
-
- `get_body_text`: Extract visible text content
|
|
462
|
-
- `click_button`: Click buttons by CSS selector (basic method)
|
|
463
|
-
- `console_log`: Send console messages
|
|
464
|
-
- `eval`: Execute custom JavaScript code
|
|
465
|
-
|
|
466
|
-
**Recommended workflow**: Use `get_page_structure` first to understand available elements, then use specific interaction commands like `click_by_text` or `fill_input`.
|
|
467
|
-
|
|
468
|
-
### `read_electron_logs`
|
|
469
|
-
|
|
470
|
-
Stream application logs from main process, renderer, and console.
|
|
471
|
-
|
|
472
|
-
```javascript
|
|
473
|
-
{
|
|
474
|
-
"logType": "all", // Options: "all", "main", "renderer", "console"
|
|
475
|
-
"lines": 50, // Number of recent lines
|
|
476
|
-
"follow": false // Stream live logs
|
|
198
|
+
### Method 2: package.json (Persistent)
|
|
199
|
+
```json
|
|
200
|
+
"scripts": {
|
|
201
|
+
"start": "electron .",
|
|
202
|
+
"dev:debug": "electron . --remote-debugging-port=9222"
|
|
477
203
|
}
|
|
478
204
|
```
|
|
205
|
+
Then run `npm run dev:debug`.
|
|
479
206
|
|
|
480
|
-
###
|
|
481
|
-
|
|
482
|
-
Gracefully close the Electron application.
|
|
483
|
-
|
|
207
|
+
### Method 3: Programmatic (Best for Codebase)
|
|
484
208
|
```javascript
|
|
485
|
-
{
|
|
486
|
-
"force": false // Force kill if unresponsive
|
|
487
|
-
}
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
### `build_electron_app`
|
|
491
|
-
|
|
492
|
-
Build Electron applications for distribution.
|
|
209
|
+
const { app } = require('electron');
|
|
493
210
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
"arch": "x64", // x64, arm64, ia32
|
|
499
|
-
"debug": false
|
|
211
|
+
if (process.env.NODE_ENV === 'development' || process.argv.includes('--dev')) {
|
|
212
|
+
const port = process.env.DEBUG_PORT || '9222';
|
|
213
|
+
app.commandLine.appendSwitch('remote-debugging-port', port);
|
|
214
|
+
console.log(`Remote debugging enabled on port ${port}`);
|
|
500
215
|
}
|
|
501
216
|
```
|
|
502
217
|
|
|
503
|
-
|
|
218
|
+
### Verification
|
|
219
|
+
Open `http://localhost:<port>/json` in your browser. If you see a JSON list of targets, you are ready.
|
|
504
220
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
```bash
|
|
508
|
-
cd examples/demo-app
|
|
509
|
-
npm install
|
|
510
|
-
npm run dev
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
The demo app includes:
|
|
514
|
-
- **Interactive UI Elements**: Buttons, forms, dropdowns, checkboxes
|
|
515
|
-
- **Real-time Event Logging**: Monitor all interactions
|
|
516
|
-
- **MCP Command Examples**: Built-in usage guide
|
|
517
|
-
- **DevTools Integration**: Automatically enabled on port 9222
|
|
221
|
+
---
|
|
518
222
|
|
|
519
|
-
|
|
223
|
+
## Usage Guide
|
|
224
|
+
|
|
225
|
+
### Core Workflow
|
|
226
|
+
|
|
227
|
+
1. **Inspect**: Use `get_page_structure` to see what buttons and inputs are available.
|
|
228
|
+
2. **Target**: Identify the element you want (e.g., a button with text "Login").
|
|
229
|
+
3. **Act**: Send a command like `click_by_text` or `fill_input`.
|
|
230
|
+
4. **Verify**: Use `take_screenshot` or `get_title` to confirm the action succeeded.
|
|
231
|
+
|
|
232
|
+
### Tool Reference
|
|
233
|
+
|
|
234
|
+
| Tool | Description |
|
|
235
|
+
|------|-------------|
|
|
236
|
+
| `get_electron_window_info` | Lists all open windows, their titles, and connection IDs. |
|
|
237
|
+
| `list_electron_windows` | Lists all available window targets across applications. |
|
|
238
|
+
| `take_screenshot` | Captures a screenshot of a specific window or the active one. |
|
|
239
|
+
| `read_electron_logs` | Streams console logs from the app (great for debugging errors). |
|
|
240
|
+
| **`send_command_to_electron`** | **The main tool.** Executes specific actions inside the app. |
|
|
241
|
+
|
|
242
|
+
### Project Management Tools
|
|
243
|
+
|
|
244
|
+
| Tool | Description |
|
|
245
|
+
|------|-------------|
|
|
246
|
+
| `register_project` | Register a project name, auto-assigns a debugging port. |
|
|
247
|
+
| `unregister_project` | Remove a project, free its port. |
|
|
248
|
+
| `list_projects` | Show all registered projects with ports and connection status. |
|
|
249
|
+
|
|
250
|
+
### Interaction Commands
|
|
251
|
+
|
|
252
|
+
Use these inside `send_command_to_electron`:
|
|
253
|
+
|
|
254
|
+
#### Clicking & Selection
|
|
255
|
+
| Command | Description |
|
|
256
|
+
|---------|-------------|
|
|
257
|
+
| **`click_by_text`** | *Best for buttons/links.* Usage: `{"text": "Submit"}` |
|
|
258
|
+
| **`click_by_selector`** | *Precise control.* Usage: `{"selector": ".submit-btn"}` |
|
|
259
|
+
| **`click_button`** | *Legacy click command.* Usage: `{"selector": "#btn"}` |
|
|
260
|
+
| **`select_option`** | *For dropdowns.* Usage: `{"text": "Category", "value": "Books"}` |
|
|
261
|
+
| **`hover`** | *Hover over elements.* Usage: `{"selector": ".tooltip-trigger"}` |
|
|
262
|
+
| **`drag`** | *Drag and drop.* Usage: `{"startSelector": "#item", "endSelector": "#cart"}` |
|
|
263
|
+
|
|
264
|
+
#### Input & Forms
|
|
265
|
+
| Command | Description |
|
|
266
|
+
|---------|-------------|
|
|
267
|
+
| **`fill_input`** | *Smart filling.* Usage: `{"placeholder": "Username", "value": "admin"}` |
|
|
268
|
+
| **`type`** | *Simulates real typing.* Usage: `{"text": "Hello World", "slowly": true}` |
|
|
269
|
+
| **`verify_form_state`** | *Checks validity of all forms.* |
|
|
270
|
+
| **`send_keyboard_shortcut`** | *Send key combinations.* Usage: `{"text": "Ctrl+S"}` |
|
|
271
|
+
|
|
272
|
+
#### Observation
|
|
273
|
+
| Command | Description |
|
|
274
|
+
|---------|-------------|
|
|
275
|
+
| **`get_page_structure`** | *Returns a simplified JSON map of the UI.* |
|
|
276
|
+
| **`find_elements`** | *Detailed list of all interactive elements.* |
|
|
277
|
+
| **`is_visible`** | *Checks visibility.* Usage: `{"selector": "#error-modal"}` |
|
|
278
|
+
| **`get_attribute`** | *Get attributes.* Usage: `{"selector": "img", "attribute": "src"}` |
|
|
279
|
+
| **`count`** | *Count matching elements.* Usage: `{"selector": "li.item"}` |
|
|
280
|
+
| **`debug_elements`** | *Get detailed debug info for buttons and inputs.* |
|
|
281
|
+
| **`get_title`** | *Get the document title.* |
|
|
282
|
+
| **`get_url`** | *Get the current URL.* |
|
|
283
|
+
| **`get_body_text`** | *Get the visible body text.* |
|
|
284
|
+
|
|
285
|
+
#### Advanced
|
|
286
|
+
| Command | Description |
|
|
287
|
+
|---------|-------------|
|
|
288
|
+
| **`wait`** | *Wait for element/time.* Usage: `{"duration": 1000}` or `{"text": "Loading"}` |
|
|
289
|
+
| **`navigate_to_hash`** | *Navigate to hash routes.* Usage: `{"text": "settings"}` |
|
|
290
|
+
| **`eval`** | *Execute custom JavaScript.* Usage: `{"code": "alert('Hello')"}` |
|
|
291
|
+
| **`console_log`** | *Write to app console.* Usage: `{"message": "Hello"}` |
|
|
520
292
|
|
|
521
|
-
|
|
293
|
+
---
|
|
522
294
|
|
|
523
|
-
|
|
295
|
+
## Advanced: HTTP Server Mode
|
|
524
296
|
|
|
525
|
-
|
|
526
|
-
// 1. First, understand the page structure
|
|
527
|
-
await send_command_to_electron({
|
|
528
|
-
command: 'get_page_structure',
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
// 2. Click a button by its text (much more reliable than selectors)
|
|
532
|
-
await send_command_to_electron({
|
|
533
|
-
command: 'click_by_text',
|
|
534
|
-
args: {
|
|
535
|
-
text: 'Login', // Finds buttons containing "Login" in text, aria-label, or title
|
|
536
|
-
},
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
// 3. Fill inputs by their label or placeholder text
|
|
540
|
-
await send_command_to_electron({
|
|
541
|
-
command: 'fill_input',
|
|
542
|
-
args: {
|
|
543
|
-
text: 'username', // Finds input with label "Username" or placeholder "Enter username"
|
|
544
|
-
value: 'john.doe@example.com',
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
await send_command_to_electron({
|
|
549
|
-
command: 'fill_input',
|
|
550
|
-
args: {
|
|
551
|
-
text: 'password',
|
|
552
|
-
value: 'secretpassword',
|
|
553
|
-
},
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
// 4. Select dropdown options by visible text
|
|
557
|
-
await send_command_to_electron({
|
|
558
|
-
command: 'select_option',
|
|
559
|
-
args: {
|
|
560
|
-
text: 'country', // Finds select with label containing "country"
|
|
561
|
-
value: 'United States', // Selects option with this text
|
|
562
|
-
},
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
// 5. Take a screenshot to verify the result
|
|
566
|
-
await take_screenshot();
|
|
567
|
-
```
|
|
297
|
+
For advanced use cases where you want a single long-lived server that multiple AI clients share, you can run the server in HTTP mode.
|
|
568
298
|
|
|
569
|
-
|
|
299
|
+
> **Note:** Most users don't need this. The standard setup auto-detects projects and handles multiple apps with zero extra config.
|
|
570
300
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
// This returns detailed info about every clickable element and input:
|
|
578
|
-
// {
|
|
579
|
-
// "type": "clickable",
|
|
580
|
-
// "text": "Submit Form",
|
|
581
|
-
// "id": "submit-btn",
|
|
582
|
-
// "className": "btn btn-primary",
|
|
583
|
-
// "ariaLabel": "Submit the registration form",
|
|
584
|
-
// "position": { "x": 100, "y": 200, "width": 120, "height": 40 },
|
|
585
|
-
// "visible": true
|
|
586
|
-
// }
|
|
301
|
+
**Step 1:** Start the server:
|
|
302
|
+
```bash
|
|
303
|
+
npx @debugelectron/debug-electron-mcp@latest serve
|
|
304
|
+
npx @debugelectron/debug-electron-mcp@latest serve --port 4000
|
|
587
305
|
```
|
|
588
306
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// Take a screenshot
|
|
599
|
-
await take_screenshot();
|
|
600
|
-
|
|
601
|
-
// Click a button programmatically
|
|
602
|
-
await send_command_to_electron({
|
|
603
|
-
command: 'eval',
|
|
604
|
-
args: {
|
|
605
|
-
code: "document.querySelector('#submit-btn').click()",
|
|
606
|
-
},
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
// Verify the result
|
|
610
|
-
await send_command_to_electron({
|
|
611
|
-
command: 'get_title',
|
|
612
|
-
});
|
|
307
|
+
**Step 2:** Point your MCP config to the URL:
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"mcpServers": {
|
|
311
|
+
"debug-electron-mcp": {
|
|
312
|
+
"url": "http://localhost:3100/mcp"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
613
316
|
```
|
|
614
317
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
```javascript
|
|
618
|
-
// Get window information
|
|
619
|
-
const windowInfo = await get_electron_window_info();
|
|
620
|
-
|
|
621
|
-
// Extract application data
|
|
622
|
-
await send_command_to_electron({
|
|
623
|
-
command: 'eval',
|
|
624
|
-
args: {
|
|
625
|
-
code: 'JSON.stringify(window.appState, null, 2)',
|
|
626
|
-
},
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
// Monitor logs
|
|
630
|
-
await read_electron_logs({
|
|
631
|
-
logType: 'all',
|
|
632
|
-
lines: 100,
|
|
633
|
-
});
|
|
318
|
+
**Step 3:** Pass `projectName` in tool calls (no auto-detect in HTTP mode):
|
|
634
319
|
```
|
|
635
|
-
|
|
636
|
-
### Performance Monitoring
|
|
637
|
-
|
|
638
|
-
```javascript
|
|
639
|
-
// Get system information
|
|
640
|
-
await send_command_to_electron({
|
|
641
|
-
command: 'eval',
|
|
642
|
-
args: {
|
|
643
|
-
code: '({memory: performance.memory, timing: performance.timing})',
|
|
644
|
-
},
|
|
645
|
-
});
|
|
646
|
-
|
|
647
|
-
// Take periodic screenshots for visual regression testing
|
|
648
|
-
await take_screenshot({
|
|
649
|
-
outputPath: '/tests/screenshots/current.png',
|
|
650
|
-
});
|
|
320
|
+
send_command_to_electron({ projectName: "music-app", command: "get_title" })
|
|
651
321
|
```
|
|
652
322
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
### Chrome DevTools Protocol Integration
|
|
656
|
-
|
|
657
|
-
- **Universal Compatibility**: Works with any Electron app that has remote debugging enabled
|
|
658
|
-
- **Real-time Communication**: WebSocket-based command execution with the renderer process
|
|
659
|
-
- **No App Modifications**: Zero changes required to target applications
|
|
660
|
-
|
|
661
|
-
### Process Management
|
|
662
|
-
|
|
663
|
-
- **Clean Environment**: Handles `ELECTRON_RUN_AS_NODE` and other environment variables
|
|
664
|
-
- **Resource Tracking**: Monitors PIDs, memory usage, and application lifecycle
|
|
665
|
-
- **Graceful Shutdown**: Proper cleanup and process termination
|
|
666
|
-
|
|
667
|
-
### Cross-Platform Support
|
|
323
|
+
**Health check:** `http://localhost:3100/health`
|
|
668
324
|
|
|
669
|
-
|
|
670
|
-
- **Windows**: PowerShell-based window detection and capture
|
|
671
|
-
- **Linux**: X11 window management (planned)
|
|
325
|
+
---
|
|
672
326
|
|
|
673
|
-
##
|
|
327
|
+
## Development
|
|
674
328
|
|
|
675
329
|
### Prerequisites
|
|
676
|
-
|
|
677
330
|
- Node.js 18+
|
|
678
|
-
-
|
|
679
|
-
- **Electron** - Required for running and testing Electron applications
|
|
680
|
-
|
|
681
|
-
```bash
|
|
682
|
-
# Install Electron globally (recommended)
|
|
683
|
-
npm install -g electron
|
|
684
|
-
|
|
685
|
-
# Or install locally in your project
|
|
686
|
-
npm install electron --save-dev
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
### Target Application Setup
|
|
690
|
-
|
|
691
|
-
For the MCP server to work with your Electron application, you need to enable remote debugging. Add this code to your Electron app's main process:
|
|
692
|
-
|
|
693
|
-
```javascript
|
|
694
|
-
const { app } = require('electron');
|
|
695
|
-
const isDev = process.env.NODE_ENV === 'development' || process.argv.includes('--dev');
|
|
696
|
-
|
|
697
|
-
// Enable remote debugging in development mode
|
|
698
|
-
if (isDev) {
|
|
699
|
-
app.commandLine.appendSwitch('remote-debugging-port', '9222');
|
|
700
|
-
}
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
**Alternative approaches:**
|
|
704
|
-
|
|
705
|
-
```bash
|
|
706
|
-
# Launch your app with debugging enabled
|
|
707
|
-
electron . --remote-debugging-port=9222
|
|
708
|
-
|
|
709
|
-
# Or via npm script
|
|
710
|
-
npm run dev -- --remote-debugging-port=9222
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
**Note:** The MCP server automatically scans ports 9222-9225 to detect running Electron applications with remote debugging enabled.
|
|
331
|
+
- npm or pnpm
|
|
714
332
|
|
|
715
333
|
### Setup
|
|
716
|
-
|
|
717
334
|
```bash
|
|
718
335
|
git clone https://github.com/TheDarkSkyXD/debug-electron-mcp.git
|
|
719
336
|
cd debug-electron-mcp
|
|
720
|
-
|
|
721
337
|
npm install
|
|
722
338
|
npm run build
|
|
723
|
-
|
|
724
|
-
# Run tests
|
|
725
|
-
npm test
|
|
726
|
-
|
|
727
|
-
# Development mode with auto-rebuild
|
|
728
|
-
npm run dev
|
|
729
339
|
```
|
|
730
340
|
|
|
731
|
-
###
|
|
732
|
-
|
|
733
|
-
The project includes comprehensive test files for React compatibility:
|
|
734
|
-
|
|
341
|
+
### Running Locally
|
|
735
342
|
```bash
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
343
|
+
npm run dev # stdio mode
|
|
344
|
+
npx tsx src/index.ts --project my-app # explicit project scope
|
|
345
|
+
npx tsx src/index.ts serve # HTTP mode
|
|
739
346
|
```
|
|
740
347
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
This MCP server has been thoroughly tested with React applications and handles common React patterns correctly:
|
|
746
|
-
|
|
747
|
-
- **✅ React Event Handling**: Properly handles `preventDefault()` in click handlers
|
|
748
|
-
- **✅ Form Input Detection**: Advanced scoring algorithm works with React-rendered inputs
|
|
749
|
-
- **✅ Component Interaction**: Compatible with React components, hooks, and state management
|
|
750
|
-
|
|
751
|
-
### Project Structure
|
|
752
|
-
|
|
753
|
-
```
|
|
754
|
-
src/
|
|
755
|
-
├── handlers.ts # MCP tool handlers
|
|
756
|
-
├── index.ts # Server entry point
|
|
757
|
-
├── tools.ts # Tool definitions
|
|
758
|
-
├── screenshot.ts # Screenshot functionality
|
|
759
|
-
├── utils/
|
|
760
|
-
│ ├── process.ts # Process management & DevTools Protocol
|
|
761
|
-
│ ├── logs.ts # Log management
|
|
762
|
-
│ └── project.ts # Project scaffolding
|
|
763
|
-
└── schemas/ # JSON schemas for validation
|
|
348
|
+
### Testing
|
|
349
|
+
```bash
|
|
350
|
+
npm test # unit tests
|
|
351
|
+
npm run test:react # integration tests
|
|
764
352
|
```
|
|
765
353
|
|
|
766
|
-
## 🔐 Security & Best Practices
|
|
767
|
-
|
|
768
|
-
- **Sandboxed Execution**: All JavaScript execution is contained within the target Electron app
|
|
769
|
-
- **Path Validation**: Only operates on explicitly provided application paths
|
|
770
|
-
- **Process Isolation**: Each launched app runs in its own process space
|
|
771
|
-
- **No Persistent Access**: No permanent modifications to target applications
|
|
772
|
-
|
|
773
|
-
## 🤝 Contributing
|
|
774
|
-
|
|
775
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
776
|
-
|
|
777
|
-
**Before reporting issues**: Please use the standardized [`ISSUE_TEMPLATE.md`](ISSUE_TEMPLATE.md) for proper bug reporting format. For React compatibility problems or similar technical issues, also review [`REACT_COMPATIBILITY_ISSUES.md`](REACT_COMPATIBILITY_ISSUES.md) for detailed debugging examples, including proper command examples, error outputs, and reproduction steps.
|
|
778
|
-
|
|
779
|
-
1. Fork the repository
|
|
780
|
-
2. Create a feature branch (`git checkout -b feature/awesome-feature`)
|
|
781
|
-
3. Commit your changes (`git commit -m 'Add awesome feature'`)
|
|
782
|
-
4. Push to the branch (`git push origin feature/awesome-feature`)
|
|
783
|
-
5. Open a Pull Request
|
|
784
|
-
|
|
785
|
-
## 📄 License
|
|
786
|
-
|
|
787
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
788
|
-
|
|
789
|
-
## 🙌 Credits & Attribution
|
|
790
|
-
|
|
791
|
-
**Original Author**: [Halil Ural](https://github.com/halilural)
|
|
792
|
-
|
|
793
|
-
This project is a fork of [halilural/electron-mcp-server](https://github.com/halilural/electron-mcp-server) with enhancements for **Cursor IDE compatibility** and improved stability.
|
|
794
|
-
|
|
795
|
-
### Forked & Maintained By
|
|
796
|
-
|
|
797
|
-
- [Antigravity](https://github.com/TheDarkSkyXD) - Cursor IDE integration improvements, bug fixes, and ongoing maintenance
|
|
798
|
-
|
|
799
|
-
### Key Improvements in This Fork
|
|
800
|
-
|
|
801
|
-
- ✅ **Cursor IDE Compatibility**: Full integration with Cursor IDE for seamless AI-powered Electron automation
|
|
802
|
-
- ✅ **Enhanced Stability**: Improved error handling and reliability
|
|
803
|
-
- ✅ **Better Documentation**: Added comprehensive guides for local development and troubleshooting
|
|
804
|
-
- ✅ **Scoped Package**: Published as `@debugelectron/electron-mcp-server` on npm
|
|
805
|
-
|
|
806
|
-
### Contributing to This Fork
|
|
807
|
-
|
|
808
|
-
We welcome contributions! If you have improvements or bug fixes, please feel free to:
|
|
809
|
-
1. Fork this repository
|
|
810
|
-
2. Create a feature branch
|
|
811
|
-
3. Submit a pull request with your improvements
|
|
812
|
-
|
|
813
354
|
---
|
|
814
355
|
|
|
815
|
-
##
|
|
356
|
+
## Troubleshooting
|
|
816
357
|
|
|
817
|
-
|
|
358
|
+
**"Target not found" / "No running Electron application"**
|
|
359
|
+
- Check your assigned port with `list_projects()`.
|
|
360
|
+
- Start your Electron app with `--remote-debugging-port=<port>`.
|
|
361
|
+
- Verify: open `http://localhost:<port>/json` in your browser.
|
|
818
362
|
|
|
819
|
-
|
|
363
|
+
**"Project 'xyz' is not registered"**
|
|
364
|
+
- This shouldn't happen with auto-detect. If it does, run `register_project({ projectName: "xyz" })`.
|
|
365
|
+
- Check `list_projects()` to see registered projects.
|
|
820
366
|
|
|
821
|
-
|
|
367
|
+
**Wrong project detected**
|
|
368
|
+
- The MCP uses your `package.json` name, or the folder name if no package.json exists.
|
|
369
|
+
- To override, use `--project` flag: `"args": ["-y", "@debugelectron/debug-electron-mcp@latest", "--project", "correct-name"]`
|
|
822
370
|
|
|
823
|
-
|
|
371
|
+
**"No free ports available"**
|
|
372
|
+
- Default range is 9222-9322 (100 ports).
|
|
373
|
+
- Free unused ports: `unregister_project({ projectName: "old-app" })`.
|
|
824
374
|
|
|
825
|
-
|
|
826
|
-
- **
|
|
827
|
-
- **
|
|
828
|
-
- **[Electron](https://electronjs.org)** - Cross-platform desktop applications
|
|
375
|
+
**"Selector is empty" error**
|
|
376
|
+
- **Wrong:** `{"command": "click_by_selector", "args": ".btn"}`
|
|
377
|
+
- **Correct:** `{"command": "click_by_selector", "args": {"selector": ".btn"}}`
|
|
829
378
|
|
|
830
|
-
|
|
379
|
+
---
|
|
831
380
|
|
|
832
|
-
|
|
833
|
-
- **[NPM Package](https://www.npmjs.com/package/@debugelectron/electron-mcp-server)**
|
|
834
|
-
- **[Original Repository](https://github.com/halilural/electron-mcp-server)** - Original project by Halil Ural
|
|
835
|
-
- **[Model Context Protocol](https://modelcontextprotocol.io)**
|
|
836
|
-
- **[Chrome DevTools Protocol Docs](https://chromedevtools.github.io/devtools-protocol/)**
|
|
837
|
-
- **[Cursor IDE Setup Guide](./CURSOR_SETUP.md)** - Complete setup guide for Cursor IDE integration
|
|
838
|
-
- **[Issue Template](./ISSUE_TEMPLATE.md)** - Standardized bug reporting format
|
|
839
|
-
- **[React Compatibility Issues Documentation](./REACT_COMPATIBILITY_ISSUES.md)** - Technical debugging guide for React applications
|
|
381
|
+
## License
|
|
840
382
|
|
|
841
|
-
|
|
383
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
842
384
|
|
|
843
|
-
|
|
385
|
+
### Credits
|
|
386
|
+
Forked and maintained by [Antigravity](https://github.com/TheDarkSkyXD), originally based on work by [halilural](https://github.com/halilural).
|