electron-test-mcp
Allows testing Electron applications by connecting to a running app via CDP or launching a new instance, with tools for interaction (click, fill, type, hover, press, drag, selectOption), inspection (screenshot, snapshot, getText, getAttribute, isVisible, count), and advanced operations (wait, evaluate, evaluateMain in launch mode).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@electron-test-mcp Take a screenshot of the Electron app and list all interactive elements"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Electron Test MCP
MCP (Model Context Protocol) server for testing Electron applications using Playwright. Enables AI models like Claude to interact with and test your Electron apps.
🚀 Quick Start
# Run directly with npx
npx electron-test-mcp
# Or install globally
npm install -g electron-test-mcp
electron-test-mcpRelated MCP server: electron-mcp-server
Features
Two Connection Modes
CDP Mode: Connect to a running Electron app via Chrome DevTools Protocol
Launch Mode: Launch a fresh Electron app instance for testing
Full Playwright API: screenshot, click, fill, type, hover, press, wait, evaluate, and more
Accessibility Snapshots: Get the accessibility tree for element discovery
Main Process Access: Execute code in Electron's main process (launch mode only)
How It Works
User <--> AI Model (Claude) <--> MCP Protocol <--> electron-test-mcp <--> Electron AppUser: "Click the login button and fill in the email field"
AI Model: Determines which MCP tools to use
MCP Protocol: Standardized communication
electron-test-mcp: Executes Playwright commands on the Electron app
Electron App: Actions are performed in the actual application
Configuration
Claude Desktop / MCP Clients
Add to your MCP configuration file:
{
"mcpServers": {
"electron-test": {
"command": "npx",
"args": ["electron-test-mcp"]
}
}
}OpenCode
{
"mcp": {
"electron-test": {
"type": "local",
"command": ["npx", "electron-test-mcp"],
"enabled": true
}
}
}Connection Modes
CDP Mode (Recommended for Development)
Connect to an already running Electron app with remote debugging enabled:
# Start your Electron app with debugging port
electron your-app --remote-debugging-port=9222
# Or with electron-vite
electron-vite dev -- --remote-debugging-port=9222Then use the connect tool:
connect({ port: 9222 })Advantages:
Works with your existing dev workflow
App state preserved between tests
Hot reload still works
Launch Mode
Launch a fresh Electron app instance:
launch({ appPath: "./out/main/index.js" })
# With headless mode for CI
launch({ appPath: "./out/main/index.js", headless: true })Advantages:
Clean state for each test
Access to main process via
evaluateMainCan pass custom environment variables
Supports headless mode for CI/automation
Headless Mode (CI/Automation)
Launch Mode
Pass headless: true to run without a visible window:
launch({ appPath: "./out/main/index.js", headless: true })CDP Mode
Start your Electron app with headless flags before connecting:
# Option 1: Electron headless flag (Electron 28+)
electron your-app --headless=new --remote-debugging-port=9222
# Option 2: xvfb (Linux) - virtual framebuffer
xvfb-run electron your-app --remote-debugging-port=9222
# Option 3: xvfb with specific display (CI environments)
Xvfb :99 -screen 0 1920x1080x24 &
DISPLAY=:99 electron your-app --remote-debugging-port=9222Then connect normally:
connect({ port: 9222 })Available Tools
Connection
Tool | Description |
| Connect to running app via CDP |
| Disconnect from CDP (app keeps running) |
| Launch new Electron app instance |
| Close launched app |
Interaction
Tool | Description |
| Click an element |
| Fill text into input (clears first) |
| Type text character by character |
| Hover over an element |
| Press keyboard key |
| Drag and drop |
| Select from dropdown |
Inspection
Tool | Description |
| Take screenshot (returns base64 image) |
| Get accessibility tree |
| Get element text content |
| Get element attribute |
| Check if element is visible |
| Count matching elements |
Advanced
Tool | Description |
| Wait for element state |
| Run JS in renderer process |
| Run code in main process (launch mode only) |
Selectors
Supports all Playwright selectors:
# CSS selectors
[data-testid="submit-btn"]
.my-class
#my-id
# Text selectors
text=Submit
text="Exact Match"
# Role selectors
role=button[name="Submit"]
# Combining
.form >> text=SubmitUsage Examples
Basic Test Flow
1. connect({ port: 9222 })
2. snapshot() // See the page structure
3. click('[data-testid="login-btn"]')
4. fill('[data-testid="email"]', 'test@example.com')
5. fill('[data-testid="password"]', 'password123')
6. click('text=Sign In')
7. wait({ selector: '[data-testid="dashboard"]' })
8. screenshot()Main Process Access (Launch Mode)
// Get app version
evaluateMain({
script: "({ app }) => app.getVersion()",
});
// Show dialog
evaluateMain({
script: "({ dialog }) => dialog.showMessageBox({ message: 'Hello!' })",
});With AI Assistant
You can ask Claude or other AI assistants to test your Electron app:
Connect to my Electron app running on port 9222 and:
1. Take a screenshot of the current state
2. Click the "Settings" button in the sidebar
3. Change the theme to dark mode
4. Verify the theme changed by checking the background colorTips for Testable Electron Apps
Add
data-testidattributes to important elementsEnable remote debugging in development:
--remote-debugging-port=9222Use semantic HTML for better accessibility snapshots
Keep selectors stable - prefer
data-testidover classes
Development
# Clone repository
git clone https://github.com/lazy-dinosaur/electron-test-mcp.git
cd electron-test-mcp
# Install dependencies
npm install
# Build
npm run build
# Run locally
node dist/index.js🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
Distributed under the MIT License. See LICENSE file for more information.
❤️ Support
If you find this project useful, please consider giving it a ⭐️ on GitHub!
Available Tools
28 toolsclickC
Click an element
Inputs: selector (required).
closeA
Close the Electron app (only works with launch, not connect)
Inputs: no named parameters.
connectB
Connect to already running Electron app via CDP (e.g., bun run dev:local with --remote-debugging-port)
Inputs: port.
countC
Count elements matching selector
Inputs: selector (required).
dblclickC
Double-click an element
Inputs: selector (required).
disconnectA
Disconnect from CDP (does not close the app)
Inputs: no named parameters.
dragC
Drag and drop from source to target element
Inputs: source (required), target (required).
evaluateC
Execute JavaScript in the renderer process
Inputs: script (required).
evaluateMainC
Execute code in the Electron main process
Inputs: script (required).
fillC
Fill text into an input field
Inputs: text (required), selector (required).
getAttributeC
Get attribute value of an element
Inputs: selector (required), attribute (required).
getTextC
Get text content of an element
Inputs: selector (required).
hoverC
Hover over an element
Inputs: selector (required).
isVisibleC
Check if element is visible
Inputs: selector (required).
launchB
Launch Electron app for testing (builds and runs fresh instance)
Inputs: env, appPath, headless.
mouseClickC
Click at specific coordinates (without selector)
Inputs: x (required), y (required), button, clickCount.
mouseDownC
Press mouse button down
Inputs: button.
mouseMoveC
Move mouse cursor to specific coordinates
Inputs: x (required), y (required), steps.
mouseUpC
Release mouse button
Inputs: button.
pressC
Press a keyboard key
Inputs: key (required).
screenshotC
Take a screenshot of the current window
Inputs: fullPage.
scrollC
Scroll the page using mouse wheel
Inputs: deltaX, deltaY.
scrollIntoViewC
Scroll element into view
Inputs: selector (required).
scrollToC
Scroll to absolute position on the page
Inputs: x, y, behavior.
selectOptionC
Select option(s) from a dropdown
Inputs: value (required), selector (required).
snapshotB
Get accessibility tree snapshot of the page (for finding elements)
Inputs: no named parameters.
typeA
Type text character by character (triggers key events)
Inputs: text (required), selector (required).
waitC
Wait for an element or condition
Inputs: selector (required), state, timeout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Most tools target clearly distinct actions (click vs fill vs hover vs drag), and the lifecycle tools connect/launch/close/disconnect are well separated. However, there is real overlap among scroll, scrollTo, and scrollIntoView, and click vs mouseClick vs dblclick, which could cause misselection without careful reading.
The set mixes snake_case-adjacent single words (connect, launch, screenshot, click, fill) with camelCase (getText, selectOption, getAttribute, isVisible, scrollIntoView, mouseMove, mouseClick) and an odd unseparated 'dblclick'. No single predictable verb_noun or verbNoun convention holds throughout.
28 tools is heavy for the scope and includes highly granular primitives (mouseMove, mouseDown, mouseUp, mouseClick, scroll/scrollTo/scrollIntoView) that could be consolidated. It is defensible for a full automation harness but sits at the cumbersome end.
Covers the lifecycle (connect/launch/close/disconnect), inspection (screenshot, snapshot, getText, getAttribute, isVisible, count), and rich interaction plus JS evaluation in both renderer and main process. Minor gaps like file upload, navigation/wait-for-navigation, and iframe handling exist but are workaroundable.
Maintenance
Related MCP Connectors
Approved test intent, reviewed Playwright automation and run evidence, inside your editor.
Playwright browser automation — navigate, click, fill forms, extract, screenshot — 17 agent tools.
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables Model Context Protocol tools for automating web browsers and Electron desktop applications using Playwright's accessibility tree snapshots. It supports window management and JavaScript execution in the main process, providing deterministic automation through structured data.313 npm17Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables Electron app automation via Chrome DevTools Protocol (CDP), allowing MCP clients like Cursor or Claude Desktop to interact with Electron apps.4MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI-powered automation, debugging, and observability of Electron applications through Chrome DevTools Protocol integration, providing real-time UI interaction and inspection capabilities.65 npm27MIT
- AlicenseCqualityDmaintenanceEnables AI coding tools to interact with Electron applications for automated testing, including app lifecycle, element interaction, and visual testing.489 npm1MIT