Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:AI QL Tuui Electron Main Process

From Leeroopedia
Knowledge Sources
Domains Electron, Node.js, Desktop
Last Updated 2026-10-24 20:38 GMT

Overview

Node.js runtime environment for the Electron main process, providing system-level access to IPC, file system, child processes, and platform automation.

Description

The Electron main process runs in Node.js and has full access to the operating system. In tuui it manages window creation (splash, main, error), IPC handler registration, MCP server lifecycle (stdio client spawning), config file loading with file watching, system tray, global shortcut registration, and platform automation (nut-js, AppleScript, VBScript). It uses the electron npm package (>= 42.0.1) and Node.js >= 22.12.0.

Usage

Use this environment for all code running in src/main/. Any implementation that imports from electron, spawns child processes, accesses the file system directly, or registers IPC handlers requires this environment.

System Requirements

Category Requirement Notes
OS macOS, Windows, or Linux Platform-specific automators dispatch at runtime
Runtime Node.js >= 22.12.0 Specified in engines field of package.json
Disk 500MB SSD For electron binary, dependencies, and bundled assets
Memory 512MB RAM minimum MCP server child processes add overhead

Dependencies

NPM Packages

  • `electron` >= 42.0.1
  • `@modelcontextprotocol/sdk` >= 1.29.0
  • `@anthropic-ai/mcpb` >= 2.1.2
  • `@nut-tree-fork/nut-js` >= 4.2.6
  • `applescript` >= 1.0.0 (macOS only, dynamic import)
  • `@el3um4s/run-vbs` >= 1.1.2 (Windows only)
  • `uuid` >= 14.0.0
  • `lodash` >= 4.17.x (debounce utility)

System Packages

Credentials

No credentials required for the main process itself. MCP server configs may define environment variables per-server via the env field in mcp.json.

Quick Install

npm install electron@^42.0.1 @modelcontextprotocol/sdk@^1.29.0 @anthropic-ai/mcpb@^2.1.2 @nut-tree-fork/nut-js@^4.2.6 uuid@^14.0.0 lodash

Code Evidence

Node.js engine constraint from `package.json:46-48`:

"engines": {
  "node": ">=22.12.0"
}

Platform detection from `src/main/utils/Constants.ts:44`:

static IS_MAC = process.platform === 'darwin'

Electron app lifecycle from `src/main/index.ts:59-70`:

app.on('ready', async () => {
  createWindow()
  registerShortcuts()
})

Common Errors

Error Message Cause Solution
`Unknown ipc channel name` Channel not whitelisted in preload Add channel to mainAvailChannels or rendererAvailChannels in preload
`Failed to connect to MCP server` Server command not found or crashed Check mcp.json command/args paths
`Nut Automator cannot be initiated` nut-js native module missing Run npm install to rebuild native deps

Compatibility Notes

  • macOS: Uses AppleScript for window management and nut-js for keyboard simulation. Mac App Store (MAS) builds disable automation (shows dialog instead).
  • Windows: Uses VBScript (@el3um4s/run-vbs) for app activation and nut-js for keyboard simulation.
  • Linux: Uses nut-js only; getForemostApp not implemented (returns null).
  • MAS builds: process.mas is checked in Commander to disable the command picker.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment