Electron Desktop Automation MCP server

Automates Electron desktop applications through Chrome DevTools Protocol integration, enabling screenshot capture, JavaScript execution, console monitoring, and window management with intelligent project detection and debugging configuration.
Back to servers
Setup instructions
Provider
Halil Ural
Release date
Jul 24, 2025
Language
JavaScript
Stats
32 stars

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.

Installation

VS Code Integration (Recommended)

Add to your VS Code MCP settings:

{
  "mcp": {
    "servers": {
      "electron": {
        "command": "npx",
        "args": ["-y", "electron-mcp-server"]
      }
    }
  }
}

Claude Desktop Integration

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "electron": {
      "command": "npx",
      "args": ["-y", "electron-mcp-server"]
    }
  }
}

Global Installation

npm install -g electron-mcp-server

Available Tools

Launch Electron App

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 Electron Window Info

Get window and target information via Chrome DevTools Protocol:

{
  "includeChildren": true
}

Returns window IDs, titles, URLs, types, and process information.

Take Screenshot

Capture screenshots using Playwright and Chrome DevTools Protocol:

{
  "outputPath": "/path/to/screenshot.png",
  "windowTitle": "My App"
}

Send Command to Electron

Execute commands in the running Electron application via WebSocket.

⚠️ Critical: Argument Structure

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"
  }
}

Enhanced UI Interaction Commands

  • find_elements: Analyze all interactive UI elements
  • click_by_text: Click elements by their visible text
  • fill_input: Fill input fields by selector or placeholder text
  • select_option: Select dropdown options
  • get_page_structure: Get overview of all page elements
  • get_title: Get document title
  • get_url: Get current URL
  • get_body_text: Extract visible text content
  • click_button: Click buttons by CSS selector
  • console_log: Send console messages
  • eval: Execute custom JavaScript code

Command Argument Reference

Command 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

Recommended Workflow

  1. Inspect: Start with get_page_structure or debug_elements
  2. Target: Use specific selectors or text-based targeting
  3. Interact: Use the appropriate command with correct argument structure
  4. Verify: Take screenshots or check page state
// 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']"
  }
}

Security Features

The server offers configurable security levels to balance safety with functionality:

Security Levels

  • STRICT: Maximum security for production environments
  • BALANCED: Default security with safe UI interactions (recommended)
  • PERMISSIVE: More functionality for trusted environments
  • DEVELOPMENT: Minimal restrictions for development/testing

Secure UI Interaction Commands

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" }
}

Troubleshooting Common Issues

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

Target Application Setup

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.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later