electron-mcp-server

electron-mcp-server

6

Electron Debug MCP Server is a robust platform for debugging Electron applications using the Model Context Protocol (MCP). It offers deep integration with Chrome DevTools Protocol, enabling advanced debugging features. Users can start, monitor, and control Electron apps with ease.

šŸš€ Electron Debug MCP Server

TypeScript Electron Chrome DevTools Protocol Model Context Protocol

A powerful Model Context Protocol (MCP) server for debugging Electron applications with deep Chrome DevTools Protocol integration.

šŸ“‹ Table of Contents

šŸ” Overview

Electron Debug MCP Server provides a bridge between the Model Context Protocol (MCP) and Electron applications, enabling advanced debugging capabilities through a standardized API. It allows you to start, monitor, debug, and control Electron applications programmatically, with deep integration with Chrome DevTools Protocol for advanced debugging features.

✨ Features

šŸ”„ Core Functionality

  • Process Management
    • šŸš€ Start Electron applications with debugging enabled
    • šŸ›‘ Stop running Electron processes
    • šŸ“‹ List all active Electron processes
    • šŸ“Š Monitor process status and logs

šŸ” Debugging Capabilities

  • Chrome DevTools Protocol Integration
    • šŸŽÆ Discover and connect to debugging targets
    • 🧩 Execute CDP commands across domains
    • šŸ“ Evaluate JavaScript in the context of pages
    • šŸ”„ Reload pages or entire applications
    • āÆļø Pause and resume JavaScript execution

šŸ“” Resource Access

  • Structured Resource Endpoints
    • šŸ“Š Overview of all running Electron processes
    • šŸ“ Detailed debug information for specific processes
    • šŸ“œ Access to process logs
    • šŸŽÆ List of available debugging targets
    • šŸ” Direct CDP access for specific targets

šŸ“„ Installation

# Clone the repository
git clone https://github.com/yourusername/electron-mcp-server.git

# Navigate to the project directory
cd electron-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

šŸš€ Usage

Starting the Server

npm run start

This will start the MCP server using stdio for communication.

Connecting to the Server

The MCP server uses stdio for communication, so clients need to connect using the Model Context Protocol. You can:

  • Use an MCP client library
  • Connect directly via stdin/stdout
  • Use a tool that supports MCP

šŸ“” Resource Endpoints

The server exposes the following resource endpoints:

ResourceDescription
electron://infoOverview of all running Electron processes
electron://process/{id}Detailed debug info for a specific process
electron://logs/{id}Access to logs for a specific process
electron://targetsList of all available debug targets
electron://cdp/{processId}/{targetId}CDP access for a specific target
electron://operation/{operation}Operations to control Electron apps

Available Operations

OperationDescription
startStart an Electron application
stopStop a running Electron process
listList all running Electron processes
reloadReload a specific page or application
evaluateExecute JavaScript in a page context
pausePause JavaScript execution
resumeResume JavaScript execution

šŸ” Chrome DevTools Protocol Integration

The server integrates with Chrome DevTools Protocol to provide deep debugging capabilities:

Listing Available Targets

GET electron://targets

Returns all available debugging targets across all running Electron processes.

Inspecting a Specific Target

GET electron://cdp/{processId}/{targetId}

Provides information about the target and available CDP domains.

Executing CDP Commands

GET electron://cdp/{processId}/{targetId}/{domain}/{command}

Examples:

  • electron://cdp/electron-123456/page-1/Page/reload - Reload the page
  • electron://cdp/electron-123456/page-1/Runtime/evaluate - Evaluate JavaScript
  • electron://cdp/electron-123456/page-1/Debugger/pause - Pause execution

šŸ“ Examples

Starting an Electron App

// Example request (using an MCP client)
const response = await mcpClient.readResource({
  uri: "electron://operation/start",
  content: JSON.stringify({
    appPath: "C:\\path\\to\\your\\electron\\app",
    debugPort: 9222  // Optional debugging port
  })
});

Getting Debug Information

// Get detailed info about a specific app
const processId = "electron-1234567890";
const infoResponse = await mcpClient.readResource({
  uri: `electron://process/${processId}`
});

Executing JavaScript in a Page

// Execute JavaScript in a page
const evalResponse = await mcpClient.readResource({
  uri: `electron://cdp/electron-123456/page-1/Runtime/evaluate`,
  content: JSON.stringify({
    expression: "document.title",
    returnByValue: true
  })
});

šŸ› ļø Development

Project Structure

electron-mcp-server/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts         # Main server implementation
│   └── types/           # TypeScript type definitions
ā”œā”€ā”€ build/               # Compiled JavaScript output
ā”œā”€ā”€ package.json         # Project dependencies and scripts
└── tsconfig.json        # TypeScript configuration

Building the Project

npm run build

Running in Development Mode

npm run dev

šŸ¤ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

šŸ“„ License

This project is licensed under the ISC License - see the LICENSE file for details.


Built with ā¤ļø using TypeScript, Electron, and Chrome DevTools Protocol.