Electron Viewer

v1.1.0
io.github.acertijosapps/electron-viewer Checked 9 hours ago Published 27 days ago

Drive Electron apps over CDP: screenshots, clicks, drags, keys, JS in renderer and main, logs.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_windows List windows

Lists the running Electron apps (found on CDP ports 9222–9231, launched or attached) and their windows. main=true means the main process is reachable (evaluate_main, real window resizing). Includes the viewer URL to watch a window live in a browser pane.

launch_app Launch app

Starts the Electron project on free debugging ports, so both the renderer (CDP) and the main process (Node inspector) are reachable, and waits for the first window. It runs `electron .` with the project's own Electron, or the launch command configured with --launch-cmd (e.g. a dev server).

ParameterTypeDescription
projectstringProject folder (default: the folder the viewer or MCP was started in)

attach Attach to app

Attaches to an Electron app already running with --remote-debugging-port=<port> (and optionally --inspect=<inspect_port> for the main process). Apps on ports 9222–9231 are found without attaching.

ParameterTypeDescription
port *integerCDP port (--remote-debugging-port)
inspect_portintegerMain process inspector port (--inspect)

screenshot Screenshot

Captures the window content (PNG). For click, drag, hover and scroll use normalized coordinates: x = pixel_x / image width, y = pixel_y / image height. Native UI (title bar, menus, dialogs) is not included.

ParameterTypeDescription
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

click Click

Clicks a point of the window content (Input.dispatchMouseEvent). count=2 is a double click.

ParameterTypeDescription
x *numberx coordinate, normalized 0–1 over the screenshot
y *numbery coordinate, normalized 0–1 over the screenshot
buttonstringMouse button
countintegerClick count (2 = double click)
modifiersarrayModifier keys held during the action (meta = ⌘ on macOS)
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

drag Drag

Presses the left button at one point, moves to another with intermediate steps and releases (a real drag).

ParameterTypeDescription
x1 *numberStart x, normalized 0–1 over the screenshot
x2 *numberEnd x, normalized 0–1 over the screenshot
y1 *numberStart y, normalized 0–1 over the screenshot
y2 *numberEnd y, normalized 0–1 over the screenshot
duration_msintegerDrag duration in ms
modifiersarrayModifier keys held during the action (meta = ⌘ on macOS)
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

hover Hover

Moves the mouse to a point without clicking (hover effects, tooltips).

ParameterTypeDescription
x *numberx coordinate, normalized 0–1 over the screenshot
y *numbery coordinate, normalized 0–1 over the screenshot
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

tap Tap

Taps a point with one finger (Input.dispatchTouchEvent): the page gets touch and pointer events with pointerType "touch". The first touch action turns on touch emulation for the window (maxTouchPoints, pointer: coarse).

ParameterTypeDescription
x *numberx coordinate, normalized 0–1 over the screenshot
y *numbery coordinate, normalized 0–1 over the screenshot
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

swipe Swipe

Swipes one finger from one point to another (touch events; use drag for the mouse). Scrolls touch lists and drives swipe gestures.

ParameterTypeDescription
x1 *numberStart x, normalized 0–1 over the screenshot
x2 *numberEnd x, normalized 0–1 over the screenshot
y1 *numberStart y, normalized 0–1 over the screenshot
y2 *numberEnd y, normalized 0–1 over the screenshot
duration_msintegerGesture duration in ms
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

long_press Long press

Holds one finger on a point and releases it. Apps that time touchstart themselves see a long press; Chromium on desktop doesn't turn it into a context menu.

ParameterTypeDescription
x *numberx coordinate, normalized 0–1 over the screenshot
y *numbery coordinate, normalized 0–1 over the screenshot
duration_msintegerHow long the finger stays down, in ms
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

pinch Pinch

Two-finger pinch centered on a point: scale > 1 spreads the fingers (zoom in), scale < 1 brings them together.

ParameterTypeDescription
scale *numberFinal finger distance ÷ initial distance, e.g. 2 or 0.5
duration_msintegerGesture duration in ms
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.
xnumberCenter x, normalized 0–1 over the screenshot
ynumberCenter y, normalized 0–1 over the screenshot

scroll Scroll

Scrolls with the mouse wheel at a point. Positive delta_y scrolls down; deltas are in CSS pixels.

ParameterTypeDescription
delta_xnumberHorizontal delta in CSS px
delta_ynumberVertical delta in CSS px
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.
xnumberx coordinate, normalized 0–1 over the screenshot
ynumbery coordinate, normalized 0–1 over the screenshot

type_text Type text

Types text into the focused element (Input.insertText; any Unicode). Click the field first; for Enter or shortcuts use press_key.

ParameterTypeDescription
text *stringText to type
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

press_key Press key

Presses a key, optionally with modifiers (e.g. key "a" + ["meta"] selects all on macOS). Named keys: Enter, Tab, Backspace, Delete, Escape, Space, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown, Insert, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12; or any single character.

ParameterTypeDescription
key *stringKey name or single character
modifiersarrayModifier keys held during the action (meta = ⌘ on macOS)
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

resize_window Resize window

Sets the size of the window content area in CSS px. With the main process it resizes the real window; if the window cannot reach that size (smaller screen, kiosk, full screen), without the main process or with emulate=true, the page viewport is emulated at the exact size instead. Width and height 0 restore the window size.

ParameterTypeDescription
height *integerContent height in CSS px
width *integerContent width in CSS px
emulatebooleanEmulate the viewport without touching the real window
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

reload Reload

Reloads the page of the window (renderer only; the main process keeps running).

ParameterTypeDescription
ignore_cachebooleanBypass the cache
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

evaluate Evaluate in renderer

Evaluates a JavaScript expression in the window page (main world) and returns its JSON value. Promises are awaited.

ParameterTypeDescription
expression *stringJavaScript expression
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

evaluate_main Evaluate in main process

Evaluates a JavaScript expression in the app's main process (Node inspector) and returns its JSON value. `require` is available, e.g. require('electron').BrowserWindow.getAllWindows().map(w => w.getTitle()). Promises are awaited. Needs main=true in list_windows.

ParameterTypeDescription
expression *stringJavaScript expression
appstringApp: id (its CDP port) or name from list_windows. Optional with a single app.

get_accessibility_tree Accessibility tree

Returns the accessibility tree of the window as indented text (role "name" value [state]). Interactive elements carry @(x, y): their center, normalized like click coordinates.

ParameterTypeDescription
interactive_onlybooleanOnly interactive elements, as a flat list
windowstringWindow: target id from list_windows or part of its title. Optional when only one window is open.

get_console_logs Console logs

Console messages and uncaught exceptions of the app: renderer windows and main process (up to the last 1000). source "stdout" returns the raw output of an app started with launch_app.

ParameterTypeDescription
appstringApp: id (its CDP port) or name from list_windows. Optional with a single app.
levelstringComma-separated levels to keep: log, info, warn, error, debug
limitintegerMost recent entries to return
sourcestringWhere the messages come from
windowstringOnly this window (plus the main process)