@debugelectron/debug-electron-mcp 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,116 @@
1
+ import { z } from 'zod';
2
+ export declare const CommandArgsSchema: z.ZodObject<{
3
+ selector: z.ZodOptional<z.ZodString>;
4
+ text: z.ZodOptional<z.ZodString>;
5
+ value: z.ZodOptional<z.ZodString>;
6
+ placeholder: z.ZodOptional<z.ZodString>;
7
+ message: z.ZodOptional<z.ZodString>;
8
+ code: z.ZodOptional<z.ZodString>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ value?: string | undefined;
11
+ code?: string | undefined;
12
+ message?: string | undefined;
13
+ text?: string | undefined;
14
+ selector?: string | undefined;
15
+ placeholder?: string | undefined;
16
+ }, {
17
+ value?: string | undefined;
18
+ code?: string | undefined;
19
+ message?: string | undefined;
20
+ text?: string | undefined;
21
+ selector?: string | undefined;
22
+ placeholder?: string | undefined;
23
+ }>;
24
+ export declare const SendCommandToElectronSchema: z.ZodObject<{
25
+ command: z.ZodString;
26
+ args: z.ZodOptional<z.ZodObject<{
27
+ selector: z.ZodOptional<z.ZodString>;
28
+ text: z.ZodOptional<z.ZodString>;
29
+ value: z.ZodOptional<z.ZodString>;
30
+ placeholder: z.ZodOptional<z.ZodString>;
31
+ message: z.ZodOptional<z.ZodString>;
32
+ code: z.ZodOptional<z.ZodString>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ value?: string | undefined;
35
+ code?: string | undefined;
36
+ message?: string | undefined;
37
+ text?: string | undefined;
38
+ selector?: string | undefined;
39
+ placeholder?: string | undefined;
40
+ }, {
41
+ value?: string | undefined;
42
+ code?: string | undefined;
43
+ message?: string | undefined;
44
+ text?: string | undefined;
45
+ selector?: string | undefined;
46
+ placeholder?: string | undefined;
47
+ }>>;
48
+ targetId: z.ZodOptional<z.ZodString>;
49
+ windowTitle: z.ZodOptional<z.ZodString>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ command: string;
52
+ windowTitle?: string | undefined;
53
+ args?: {
54
+ value?: string | undefined;
55
+ code?: string | undefined;
56
+ message?: string | undefined;
57
+ text?: string | undefined;
58
+ selector?: string | undefined;
59
+ placeholder?: string | undefined;
60
+ } | undefined;
61
+ targetId?: string | undefined;
62
+ }, {
63
+ command: string;
64
+ windowTitle?: string | undefined;
65
+ args?: {
66
+ value?: string | undefined;
67
+ code?: string | undefined;
68
+ message?: string | undefined;
69
+ text?: string | undefined;
70
+ selector?: string | undefined;
71
+ placeholder?: string | undefined;
72
+ } | undefined;
73
+ targetId?: string | undefined;
74
+ }>;
75
+ export declare const TakeScreenshotSchema: z.ZodObject<{
76
+ outputPath: z.ZodOptional<z.ZodString>;
77
+ windowTitle: z.ZodOptional<z.ZodString>;
78
+ }, "strip", z.ZodTypeAny, {
79
+ outputPath?: string | undefined;
80
+ windowTitle?: string | undefined;
81
+ }, {
82
+ outputPath?: string | undefined;
83
+ windowTitle?: string | undefined;
84
+ }>;
85
+ export declare const ReadElectronLogsSchema: z.ZodObject<{
86
+ logType: z.ZodOptional<z.ZodEnum<["console", "main", "renderer", "all"]>>;
87
+ lines: z.ZodOptional<z.ZodNumber>;
88
+ follow: z.ZodOptional<z.ZodBoolean>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ logType?: "console" | "main" | "renderer" | "all" | undefined;
91
+ lines?: number | undefined;
92
+ follow?: boolean | undefined;
93
+ }, {
94
+ logType?: "console" | "main" | "renderer" | "all" | undefined;
95
+ lines?: number | undefined;
96
+ follow?: boolean | undefined;
97
+ }>;
98
+ export declare const GetElectronWindowInfoSchema: z.ZodObject<{
99
+ includeChildren: z.ZodOptional<z.ZodBoolean>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ includeChildren?: boolean | undefined;
102
+ }, {
103
+ includeChildren?: boolean | undefined;
104
+ }>;
105
+ export declare const ListElectronWindowsSchema: z.ZodObject<{
106
+ includeDevTools: z.ZodOptional<z.ZodBoolean>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ includeDevTools?: boolean | undefined;
109
+ }, {
110
+ includeDevTools?: boolean | undefined;
111
+ }>;
112
+ export type ToolInput = {
113
+ type: 'object';
114
+ properties: Record<string, any>;
115
+ required?: string[];
116
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Take a screenshot of the running Electron application using Chrome DevTools Protocol
3
+ */
4
+ export declare function takeScreenshot(outputPath?: string, windowTitle?: string): Promise<{
5
+ filePath?: string;
6
+ base64: string;
7
+ data: string;
8
+ error?: string;
9
+ }>;
@@ -0,0 +1,13 @@
1
+ import { ToolInput } from './schemas';
2
+ export declare enum ToolName {
3
+ SEND_COMMAND_TO_ELECTRON = "send_command_to_electron",
4
+ TAKE_SCREENSHOT = "take_screenshot",
5
+ READ_ELECTRON_LOGS = "read_electron_logs",
6
+ GET_ELECTRON_WINDOW_INFO = "get_electron_window_info",
7
+ LIST_ELECTRON_WINDOWS = "list_electron_windows"
8
+ }
9
+ export declare const tools: {
10
+ name: ToolName;
11
+ description: string;
12
+ inputSchema: ToolInput;
13
+ }[];
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Enhanced Electron interaction commands for React-based applications
3
+ * Addresses common issues with form interactions, event handling, and state management
4
+ */
5
+ export interface ElementAnalysis {
6
+ element?: Element;
7
+ tag: string;
8
+ text: string;
9
+ id: string;
10
+ className: string;
11
+ name: string;
12
+ placeholder: string;
13
+ type: string;
14
+ value: string;
15
+ ariaLabel: string;
16
+ ariaRole: string;
17
+ title: string;
18
+ href: string;
19
+ src: string;
20
+ alt: string;
21
+ position: {
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ };
27
+ isVisible: boolean;
28
+ isInteractive: boolean;
29
+ zIndex: number;
30
+ backgroundColor: string;
31
+ color: string;
32
+ fontSize: string;
33
+ fontWeight: string;
34
+ cursor: string;
35
+ context: string;
36
+ selector: string;
37
+ xpath: string;
38
+ }
39
+ export interface PageAnalysis {
40
+ clickable: ElementAnalysis[];
41
+ inputs: ElementAnalysis[];
42
+ links: ElementAnalysis[];
43
+ images: ElementAnalysis[];
44
+ text: ElementAnalysis[];
45
+ containers: ElementAnalysis[];
46
+ metadata: {
47
+ totalElements: number;
48
+ visibleElements: number;
49
+ interactiveElements: number;
50
+ pageTitle: string;
51
+ pageUrl: string;
52
+ viewport: {
53
+ width: number;
54
+ height: number;
55
+ };
56
+ };
57
+ }
58
+ /**
59
+ * Generate the enhanced find_elements command with deep DOM analysis
60
+ */
61
+ export declare function generateFindElementsCommand(): string;
62
+ /**
63
+ * Generate the enhanced click_by_text command with improved element scoring
64
+ */
65
+ export declare function generateClickByTextCommand(text: string): string;
@@ -0,0 +1,39 @@
1
+ import WebSocket from 'ws';
2
+ export interface DevToolsTarget {
3
+ id: string;
4
+ title: string;
5
+ url: string;
6
+ webSocketDebuggerUrl: string;
7
+ type: string;
8
+ }
9
+ export interface CommandResult {
10
+ success: boolean;
11
+ result?: any;
12
+ error?: string;
13
+ message: string;
14
+ }
15
+ /** Options for targeting a specific Electron window */
16
+ export interface WindowTargetOptions {
17
+ /** CDP target ID (exact match) */
18
+ targetId?: string;
19
+ /** Window title (case-insensitive partial match) */
20
+ windowTitle?: string;
21
+ }
22
+ /**
23
+ * Find and connect to a running Electron application.
24
+ * @param options - Optional targeting options to select a specific window
25
+ * @returns The DevTools target matching the given options
26
+ * @example
27
+ * findElectronTarget() // first available main window
28
+ * findElectronTarget({ targetId: 'ABC123' }) // exact ID match
29
+ * findElectronTarget({ windowTitle: 'Settings' }) // partial title match
30
+ */
31
+ export declare function findElectronTarget(options?: WindowTargetOptions): Promise<DevToolsTarget>;
32
+ /**
33
+ * Execute JavaScript code in an Electron application via Chrome DevTools Protocol
34
+ */
35
+ export declare function executeInElectron(javascriptCode: string, target?: DevToolsTarget): Promise<string>;
36
+ /**
37
+ * Connect to Electron app for real-time log monitoring
38
+ */
39
+ export declare function connectForLogs(target?: DevToolsTarget, onLog?: (log: string) => void): Promise<WebSocket>;
@@ -0,0 +1,52 @@
1
+ export interface ElectronAppInfo {
2
+ port: number;
3
+ targets: any[];
4
+ }
5
+ export interface WindowInfo {
6
+ id: string;
7
+ title: string;
8
+ url: string;
9
+ type: string;
10
+ description: string;
11
+ webSocketDebuggerUrl: string;
12
+ }
13
+ /** Simplified window target info for the list_electron_windows tool */
14
+ export interface ElectronWindowTarget {
15
+ id: string;
16
+ title: string;
17
+ url: string;
18
+ port: number;
19
+ type: string;
20
+ }
21
+ export interface ElectronWindowResult {
22
+ platform: string;
23
+ devToolsPort?: number;
24
+ windows: WindowInfo[];
25
+ totalTargets: number;
26
+ electronTargets: number;
27
+ processInfo?: any;
28
+ message: string;
29
+ automationReady: boolean;
30
+ }
31
+ /**
32
+ * Scan for running Electron applications with DevTools enabled
33
+ */
34
+ export declare function scanForElectronApps(): Promise<ElectronAppInfo[]>;
35
+ /**
36
+ * Get detailed process information for running Electron applications
37
+ */
38
+ export declare function getElectronProcessInfo(): Promise<any>;
39
+ /**
40
+ * Find the main target from a list of targets
41
+ */
42
+ export declare function findMainTarget(targets: any[]): any | null;
43
+ /**
44
+ * List all available Electron window targets across all detected apps.
45
+ * @param includeDevTools - Whether to include DevTools windows (default: false)
46
+ * @returns Array of window targets with id, title, url, port, and type
47
+ */
48
+ export declare function listElectronWindows(includeDevTools?: boolean): Promise<ElectronWindowTarget[]>;
49
+ /**
50
+ * Get window information from any running Electron app
51
+ */
52
+ export declare function getElectronWindowInfo(includeChildren?: boolean): Promise<ElectronWindowResult>;
@@ -0,0 +1,51 @@
1
+ import { WindowTargetOptions } from './electron-connection';
2
+ export interface CommandArgs {
3
+ selector?: string;
4
+ text?: string;
5
+ value?: string;
6
+ placeholder?: string;
7
+ message?: string;
8
+ code?: string;
9
+ }
10
+ /**
11
+ * Enhanced command executor with improved React support.
12
+ * @param command - The command to execute
13
+ * @param args - Command-specific arguments
14
+ * @param windowOptions - Optional window targeting (targetId or windowTitle)
15
+ */
16
+ export declare function sendCommandToElectron(command: string, args?: CommandArgs, windowOptions?: WindowTargetOptions): Promise<string>;
17
+ /**
18
+ * Enhanced click function with better React support
19
+ */
20
+ export declare function clickByText(text: string): Promise<string>;
21
+ /**
22
+ * Enhanced input filling with React state management
23
+ */
24
+ export declare function fillInput(searchText: string, value: string, selector?: string): Promise<string>;
25
+ /**
26
+ * Enhanced select option with proper event handling
27
+ */
28
+ export declare function selectOption(value: string, selector?: string, text?: string): Promise<string>;
29
+ /**
30
+ * Get comprehensive page structure analysis
31
+ */
32
+ export declare function getPageStructure(): Promise<string>;
33
+ /**
34
+ * Get enhanced element analysis
35
+ */
36
+ export declare function findElements(): Promise<string>;
37
+ /**
38
+ * Execute custom JavaScript with error handling
39
+ */
40
+ export declare function executeCustomScript(code: string): Promise<string>;
41
+ /**
42
+ * Get debugging information about page elements
43
+ */
44
+ export declare function debugElements(): Promise<string>;
45
+ /**
46
+ * Verify current form state and validation
47
+ */
48
+ export declare function verifyFormState(): Promise<string>;
49
+ export declare function getTitle(): Promise<string>;
50
+ export declare function getUrl(): Promise<string>;
51
+ export declare function getBodyText(): Promise<string>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Enhanced input interaction commands for React-based Electron applications
3
+ * Focuses on proper event handling and React state management
4
+ */
5
+ /**
6
+ * Generate the enhanced fill_input command with React-aware event handling
7
+ */
8
+ export declare function generateFillInputCommand(selector: string, value: string, searchText: string): string;
9
+ /**
10
+ * Generate the enhanced select_option command
11
+ */
12
+ export declare function generateSelectOptionCommand(selector: string, value: string, text: string): string;
13
+ /**
14
+ * Generate page structure analysis command
15
+ */
16
+ export declare function generatePageStructureCommand(): string;
@@ -0,0 +1,11 @@
1
+ export type LogType = 'console' | 'main' | 'renderer' | 'all';
2
+ export interface LogEntry {
3
+ timestamp: string;
4
+ level: string;
5
+ message: string;
6
+ source: 'console' | 'system';
7
+ }
8
+ /**
9
+ * Read logs from running Electron applications
10
+ */
11
+ export declare function readElectronLogs(logType?: LogType, lines?: number, follow?: boolean): Promise<string>;
@@ -0,0 +1,27 @@
1
+ import { ChildProcess } from 'child_process';
2
+ export declare let electronProcess: ChildProcess | null;
3
+ export declare let electronLogs: string[];
4
+ /**
5
+ * Set the current Electron process reference
6
+ */
7
+ export declare function setElectronProcess(process: ChildProcess | null): void;
8
+ /**
9
+ * Get the current Electron process reference
10
+ */
11
+ export declare function getElectronProcess(): ChildProcess | null;
12
+ /**
13
+ * Add a log entry to the Electron logs
14
+ */
15
+ export declare function addElectronLog(log: string): void;
16
+ /**
17
+ * Get all Electron logs
18
+ */
19
+ export declare function getElectronLogs(): string[];
20
+ /**
21
+ * Clear all Electron logs
22
+ */
23
+ export declare function clearElectronLogs(): void;
24
+ /**
25
+ * Reset the Electron process state
26
+ */
27
+ export declare function resetElectronProcess(): void;
@@ -0,0 +1,19 @@
1
+ export declare enum LogLevel {
2
+ ERROR = 0,
3
+ WARN = 1,
4
+ INFO = 2,
5
+ DEBUG = 3
6
+ }
7
+ export declare class Logger {
8
+ private static instance;
9
+ private level;
10
+ constructor(level?: LogLevel);
11
+ static getInstance(): Logger;
12
+ setLevel(level: LogLevel): void;
13
+ error(message: string, ...args: any[]): void;
14
+ warn(message: string, ...args: any[]): void;
15
+ info(message: string, ...args: any[]): void;
16
+ debug(message: string, ...args: any[]): void;
17
+ isEnabled(level: LogLevel): boolean;
18
+ }
19
+ export declare const logger: Logger;
@@ -0,0 +1 @@
1
+ export declare function readElectronLogs(logType?: string, lines?: number): Promise<string[]>;
@@ -0,0 +1 @@
1
+ export declare function isElectronInstalled(appPath?: string): Promise<boolean>;
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@debugelectron/debug-electron-mcp",
3
+ "version": "1.6.7",
4
+ "description": "MCP server for Electron application automation and management. See MCP_USAGE_GUIDE.md for proper argument structure examples.",
5
+ "main": "dist/index.js",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "bin": {
10
+ "debug-electron-mcp": "dist/index.js"
11
+ },
12
+ "scripts": {
13
+ "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
14
+ "dev:inspect": "npm run build && npm run inspect",
15
+ "dev:hmr": "mcpmon -- npm run dev",
16
+ "build": "webpack --config webpack.config.ts --mode production",
17
+ "build:dev": "webpack --config webpack.config.ts --mode development",
18
+ "dev": "tsx src/index.ts",
19
+ "dev:watch": "tsx --watch src/index.ts",
20
+ "start": "node dist/index.js",
21
+ "watch": "webpack --config webpack.config.ts --mode development --watch",
22
+ "watch-and-serve": "webpack --config webpack.config.ts --mode development --watch & node --watch dist/index.js",
23
+ "prepare": "npm run build",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "test:ui": "vitest --ui",
27
+ "test:react": "cd tests/integration/react-compatibility && electron test-react-electron.cjs",
28
+ "test:coverage": "vitest run --coverage",
29
+ "test:security": "npm run build && node test/security-test.js",
30
+ "test:clean": "tsx -e \"import('./test/utils/cleanup.js').then(m => m.TestCleanup.cleanup())\"",
31
+ "lint": "eslint src/**/*.ts",
32
+ "lint:fix": "eslint src/**/*.ts --fix",
33
+ "format": "prettier --write \"src/**/*.{ts,js,json,md}\"",
34
+ "format:check": "prettier --check \"src/**/*.{ts,js,json,md}\"",
35
+ "code:check": "npm run lint && npm run format:check",
36
+ "code:fix": "npm run lint:fix && npm run format"
37
+ },
38
+ "keywords": [
39
+ "mcp",
40
+ "electron",
41
+ "automation",
42
+ "desktop",
43
+ "model-context-protocol",
44
+ "devtools",
45
+ "testing",
46
+ "ai",
47
+ "chrome-devtools-protocol",
48
+ "screenshot",
49
+ "electron-automation"
50
+ ],
51
+ "author": "DebugElectron",
52
+ "license": "MIT",
53
+ "dependencies": {
54
+ "@modelcontextprotocol/sdk": "^1.0.0",
55
+ "@types/ws": "^8.18.1",
56
+ "electron": "^28.0.0",
57
+ "playwright": "^1.54.1",
58
+ "ws": "^8.18.3",
59
+ "zod": "^3.22.4",
60
+ "zod-to-json-schema": "^3.22.4"
61
+ },
62
+ "devDependencies": {
63
+ "@eslint/js": "^9.32.0",
64
+ "@types/node": "^20.19.10",
65
+ "@types/webpack": "^5.28.5",
66
+ "@types/webpack-node-externals": "^3.0.4",
67
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
68
+ "@typescript-eslint/parser": "^8.38.0",
69
+ "@vitest/coverage-v8": "^3.2.4",
70
+ "@vitest/ui": "^3.2.4",
71
+ "eslint": "^9.32.0",
72
+ "globals": "^16.3.0",
73
+ "jest": "^29.0.0",
74
+ "jiti": "^2.5.1",
75
+ "prettier": "^3.6.2",
76
+ "ts-jest": "^29.0.0",
77
+ "ts-loader": "^9.5.2",
78
+ "ts-node": "^10.9.2",
79
+ "tsx": "^4.6.0",
80
+ "typescript": "^5.8.3",
81
+ "typescript-eslint": "^8.38.0",
82
+ "vitest": "^3.2.4",
83
+ "webpack": "^5.101.0",
84
+ "webpack-cli": "^6.0.1",
85
+ "webpack-node-externals": "^3.0.0"
86
+ },
87
+ "files": [
88
+ "dist",
89
+ "README.md",
90
+ "LICENSE"
91
+ ],
92
+ "engines": {
93
+ "node": ">=18.0.0"
94
+ },
95
+ "repository": {
96
+ "type": "git",
97
+ "url": "git+https://github.com/TheDarkSkyXD/debug-electron-mcp.git"
98
+ },
99
+ "bugs": {
100
+ "url": "https://github.com/TheDarkSkyXD/debug-electron-mcp/issues"
101
+ },
102
+ "homepage": "https://github.com/TheDarkSkyXD/debug-electron-mcp#readme"
103
+ }