Electron debugging
Attach to and debug Electron applications over the DevTools Protocol.
The flows on this page are derived from the tools’ documented capabilities. Unlike Troubleshooting, they are not covered by tests in this repository and were not executed for this revision. The MCP tool names used here are a moving surface — see How cdp works.
Electron apps have two process types that use different protocols:
- Renderer (Chromium): Use
cdp --mcpwith--connect-existing --debug-port - Main process (Node.js): Use
ndp --mcpwith--node-port
Finding the ports
Renderer (Chrome DevTools Protocol)
Launch Electron with remote debugging enabled:
electron --remote-debugging-port=9222 your-app/
Main process (V8 Inspector)
Launch Electron with Node.js inspector enabled:
electron --inspect=9229 your-app/
# or break on first line:
electron --inspect-brk=9229 your-app/
Both at once
electron --remote-debugging-port=9222 --inspect=9229 your-app/
MCP configuration
Add both servers to .mcp.json for full Electron debugging:
{
"mcpServers": {
"electron-renderer": {
"command": "cdp",
"args": ["--mcp", "--connect-existing", "--debug-port", "9222", "--headless=false"]
},
"electron-main": {
"command": "ndp",
"args": ["--mcp", "--node-port", "9229"]
}
}
}
What each server provides
cdp (renderer)
- Page navigation, screenshots, DOM interaction
- Network interception and HAR recording
- CSS/JS coverage for frontend code — returns nothing on pages with little or no JavaScript, see Known issues
- Extension management — does not work for DevTools-only extensions, see Known issues
- Sourcemap analysis for bundled frontend code
ndp (main process)
- JavaScript evaluation in Node.js context
- Source listing and reading (all loaded modules)
- Console and error capture
- CPU profiling and heap snapshots
- Code coverage for backend code
- Sourcemap analysis for bundled server code
detect_electrontool to identify Electron environment
Detecting Electron
The detect_electron tool on the ndp server checks for Electron-specific
globals and reports the Electron version, process type, app name, and path.
This helps agents understand the debugging context.
Common patterns
Debug a renderer crash
- Connect cdp to renderer port
- Use
screenshotandpage_snapshotto see current state - Use
get_consoleandget_errorsfor error context - Use
evaluateto inspect DOM/JS state
Debug main process hang
- Connect ndp to inspector port
- Use
start_cpu_profile/stop_cpu_profileto find hot code - Use
evaluateto inspect process state - Use
get_consolefor logged output
Trace IPC between processes
- Connect both servers
- In ndp:
evaluatewithprocess.on('message', ...)or Electron IPC listeners - In cdp:
evaluatewithipcRenderer.on(...)watchers - Use
get_consoleon both sides to see message flow
Next steps
- Use cdp as an MCP server — the MCP setup this depends on.
- Troubleshooting — attach failures and browser discovery.