The Electron MCP Server provides comprehensive automation, debugging, and observability capabilities for Electron applications through Model Context Protocol integration, allowing AI-powered control of your desktop applications without modifying their code.
Add to your VS Code MCP settings:
{
"mcp": {
"servers": {
"electron": {
"command": "npx",
"args": ["-y", "electron-mcp-server"]
}
}
}
}
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"electron": {
"command": "npx",
"args": ["-y", "electron-mcp-server"]
}
}
}
npm install -g electron-mcp-server
Launch an Electron application with debugging capabilities:
{
"appPath": "/path/to/electron-app",
"devMode": true,
"args": ["--enable-logging", "--dev"]
}
Returns process ID and launch confirmation.
Get window and target information via Chrome DevTools Protocol:
{
"includeChildren": true
}
Returns window IDs, titles, URLs, types, and process information.
Capture screenshots using Playwright and Chrome DevTools Protocol:
{
"outputPath": "/path/to/screenshot.png",
"windowTitle": "My App"
}
Execute commands in the running Electron application via WebSocket.
The most common mistake is incorrect argument structure:
❌ Wrong (causes "selector is empty" errors):
{
"command": "click_by_selector",
"args": "button.submit-btn"
}
✅ Correct:
{
"command": "click_by_selector",
"args": {
"selector": "button.submit-btn"
}
}
find_elements
: Analyze all interactive UI elementsclick_by_text
: Click elements by their visible textfill_input
: Fill input fields by selector or placeholder textselect_option
: Select dropdown optionsget_page_structure
: Get overview of all page elementsget_title
: Get document titleget_url
: Get current URLget_body_text
: Extract visible text contentclick_button
: Click buttons by CSS selectorconsole_log
: Send console messageseval
: Execute custom JavaScript codeCommand | Required Args | Example |
---|---|---|
click_by_selector | {"selector": "css-selector"} | {"selector": "button.primary"} |
click_by_text | {"text": "button text"} | {"text": "Submit"} |
fill_input | {"value": "text", "selector": "..."} or {"value": "text", "placeholder": "..."} | {"placeholder": "Enter name", "value": "John"} |
send_keyboard_shortcut | {"text": "key combination"} | {"text": "Ctrl+N"} |
eval | {"code": "javascript"} | {"code": "document.title"} |
get_title, get_url, get_body_text | No args needed | {} or omit args |
// Step 1: Understand the page
{
"command": "get_page_structure"
}
// Step 2: Click button using text (most reliable)
{
"command": "click_by_text",
"args": {
"text": "Create New Encyclopedia"
}
}
// Step 3: Fill form field
{
"command": "fill_input",
"args": {
"placeholder": "Enter encyclopedia name",
"value": "AI and Machine Learning"
}
}
// Step 4: Submit with selector
{
"command": "click_by_selector",
"args": {
"selector": "button[type='submit']"
}
}
The server offers configurable security levels to balance safety with functionality:
Instead of raw JavaScript eval, use these secure commands:
// ✅ Secure button clicking
{
"command": "click_by_text",
"args": { "text": "Create New Encyclopedia" }
}
// ✅ Secure element selection
{
"command": "click_by_selector",
"args": { "selector": "button[title='Create']" }
}
// ✅ Secure keyboard shortcuts
{
"command": "send_keyboard_shortcut",
"args": { "text": "Ctrl+N" }
}
// ✅ Secure navigation
{
"command": "navigate_to_hash",
"args": { "text": "create" }
}
Error | Cause | Solution |
---|---|---|
"The provided selector is empty" | Passing string instead of object | Use {"selector": "..."} |
"Element not found" | Wrong selector | Use get_page_structure first |
"Command blocked" | Security restriction | Check security level settings |
"Click prevented - too soon" | Rapid consecutive clicks | Wait before retrying |
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:
app.commandLine.appendSwitch('remote-debugging-port', '9222');
The MCP server automatically scans ports 9222-9225 to detect running Electron applications with remote debugging enabled.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "electron" '{"command":"npx","args":["-y","electron-mcp-server"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"electron": {
"command": "npx",
"args": [
"-y",
"electron-mcp-server"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"electron": {
"command": "npx",
"args": [
"-y",
"electron-mcp-server"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect