Electron MCP Server

io.github.YawLabs由 GitHub 帳號 YawLabs 發布v1.7.1更新於 Oct 31, 2026

Electron.js MCP server — IPC scaffolding, security auditing, build tooling for AI assistants

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

Electron 開發輔助伺服器:產生 IPC、preload 橋接與專案設定,稽核安全性與效能,並解說特定版本的 Electron 行為。

可以做什麼
  • 產生 IPC 通道、preload 橋接、視窗管理器與完整專案範本
  • 依 Electron 安全建議稽核程式碼、檢查危險寫法並審查 IPC 安全性
  • 產生 CSP、fuses、自動更新與深層連結設定
  • 依 electron-builder、forge 或 packager 的輸出診斷建置與封裝錯誤
  • 規劃版本遷移並掃描已棄用或已移除的 API
  • 解說 Electron 概念並回報內建知識涵蓋的 Electron 版本
適用情境
適合在開發或強化 Electron 桌面應用時,讓助理產出正確且符合版本的樣板程式碼與安全建議,而非泛泛之談。也適合審查現有的主行程與 preload 程式碼、規劃 Electron 大版本升級,或排查封裝失敗。
執行需求
需要能啟動 stdio 伺服器的本機 MCP 用戶端,以及 Node.js 20.11 以上版本,以便透過 npx 執行該 npm 套件。不需要 API 金鑰或環境變數。Windows 上須以 cmd /c 包裝啟動指令。另有選用的沙箱變數 ELECTRON_MCP_SANDBOX 與 ELECTRON_MCP_RUNTIME,但非必要。
安裝前請注意
工具被描述為唯讀,僅就傳入的參數進行計算,因此你提供的程式碼、設定與建置日誌會作為工具輸入送給助理。產生的範本與設定僅屬建議,使用前應自行審查;內建知識有驗證日期,可能落後於較新的 Electron 大版本。選用的沙箱設定若未將 ELECTRON_MCP_RUNTIME 設為 oam,可能默默退回無沙箱執行。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Electron MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@yawlabs/electron-mcp

[Add to Yaw MCP]

One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Or install manually below.

[npm version] [License: MIT] [GitHub stars]

Make your AI assistant actually good at Electron. 18 tools for the stuff AI models hallucinate about: context isolation, preload bridges, fuses, CSP, signing, auto-updates, breaking changes between majors, and the 20 official security recommendations.

This is not a runtime debugger. It is a development-intelligence layer that turns "write me some Electron code" from hit-or-miss into correct-on-the-first-try.

Built and maintained by Yaw Labs.

Why this one?

Other Electron MCP servers give your model a shell and hope. This one doesn't.

  • IPC that isn't a security hole — electron_scaffold_ipc_channel generates main handler + typed preload bridge + contextBridge exposure + renderer usage in one call. No nodeIntegration: true, no direct ipcRenderer on window.
  • The official security recommendations, enforced — electron_audit_security checks your BrowserWindow config, preload scripts, and CSP against 19 of the 20 items from electronjs.org/docs/latest/tutorial/security that can be verified from static inputs. (The 20th, session permission handling, needs runtime context and is flagged in the report footer.) Not a vibe check.
  • Version-aware migration — electron_migrate_version knows the breaking changes from v28 through v41 and tells you exactly what will break when you bump. electron_check_deprecated_apis scans your code for APIs that were removed.
  • Build errors, explained — electron_diagnose_build_error parses electron-builder/forge output and identifies root causes: Apple signing, Windows code signing, native module rebuilds, ASAR packaging, entitlements, path quoting.
  • Modern production hardening — electron_configure_fuses generates the @electron/fuses block for disabling unused runtime features (cookie encryption, Node CLI flags, legacy load behaviour). electron_configure_csp generates a CSP that actually works with your bundler and framework instead of blocking your own assets.
  • Knowledge freshness is declared, not assumed — every response includes a _Knowledge last verified YYYY-MM-DD (Electron vN stable)_ footer. Call electron_knowledge_version to get the metadata directly. If your Electron is newer than the footer, the tool tells you.
  • Read-only, no side effects — every tool declares readOnlyHint, destructiveHint: false, idempotentHint: true, so MCP clients can skip confirmation. The tools never touch your filesystem, never run code, never call exec.
  • Zero runtime dependencies — ships as a single bundled file. No 5-minute node_modules install, no electron or electron-builder installed as dependencies to inflate your project. The published package's dependencies is {}; Dependabot alerts on this repo are against devDependencies. Most of that surface (the MCP SDK's HTTP transport: hono, express, ip-address, qs) is not in the bundle — this server uses stdio only — but fast-uri, which the SDK's default JSON Schema validator (ajv) needs, is inlined into dist/index.js, so an advisory against it is cleared by a new release, not by reinstalling.

Quick start

No API keys. No environment variables required. Just install it.

1. Create .mcp.json in your project root

macOS / Linux / WSL:

json
{  "mcpServers": {    "electron": {      "command": "npx",      "args": ["-y", "@yawlabs/electron-mcp@latest"]    }  }}

Windows:

json
{  "mcpServers": {    "electron": {      "command": "cmd",      "args": ["/c", "npx", "-y", "@yawlabs/electron-mcp@latest"]    }  }}

Why the extra step on Windows? Since Node 20, child_process.spawn cannot directly execute .cmd files (that's what npx is on Windows). Wrapping with cmd /c is the standard workaround.

2. Restart and approve

Restart Claude Code (or your MCP client) and approve the Electron MCP server when prompted.

That's it. Now ask your AI assistant:

"Add a file picker to my Electron app"

"Audit my BrowserWindow config for security issues"

"My electron-builder is failing with a signing error — here's the output"

"Generate a CSP for my Vite + React renderer"

"What breaks if I upgrade from Electron 32 to 41?"

Alternate MCP clients

ClientConfig file
Claude Code.mcp.json (project root) or ~/.claude.json (global)
Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
Cursor~/.cursor/mcp.json
Windsurf~/.codeium/windsurf/mcp_config.json
VS Code.vscode/mcp.json

Use the same JSON block shown above in any of these.

Runtime and sandbox

The launcher prefers the oam runtime when a current one (0.19.1 or newer) is installed, and falls back to the Node that is already running it. Nothing to configure; both serve the same server.

Opt-in sandbox. With oam, the server can run under --permission with no grants at all: no filesystem, no child processes, no network, no environment. This server needs none of them (every tool computes over its arguments and returns markdown), so the sandbox costs no capability and turns anything the server merely happens not to use into a runtime refusal. Add an env block to whichever config block you used above (npx on macOS / Linux / WSL, cmd /c npx on Windows):

json
"env": { "ELECTRON_MCP_SANDBOX": "1", "ELECTRON_MCP_RUNTIME": "oam" }

The second variable is what makes the sandbox required: it needs a freshly spawned oam (0.19.1 or newer) to apply it, and with ELECTRON_MCP_RUNTIME=oam a missing or unusable oam is a startup error instead of an unsandboxed server. Under the default ELECTRON_MCP_RUNTIME=auto the launcher still serves in that case, without --permission, and prints a line on stderr saying so and how to fix it. Use auto when you want the sandbox where available; use oam when you want to be sure.

How to tell it took: every path that serves without the sandbox after it was asked for prints an electron-mcp: line on stderr containing runs WITHOUT --permission, plus how to fix it (most MCP clients show server stderr in their logs). When the sandbox is applied there is no such line. To confirm from a shell:

sh
ELECTRON_MCP_SANDBOX=1 ELECTRON_MCP_RUNTIME=oam npx -y @yawlabs/electron-mcp@latest --version

The version on stdout, exit 0, and no WITHOUT --permission line means a sandboxed oam served it; with ELECTRON_MCP_RUNTIME=oam set, a missing oam is an error instead.

It is off by default because it is a behaviour change: a future version that legitimately needs a capability should fail in review, not in your session. Two more things to know:

  • If the launcher itself is already running under oam (Yaw MCP does this), the sandbox spawns a second oam (the host's own binary, if nothing newer is installed), because only a fresh one can apply a process-level flag. That adds one runtime boot to startup, plus a --version probe per oam binary the launcher finds.
  • Request the sandbox through the variable, not by putting --permission on the host command: a launcher running under bare --permission cannot read its environment, so every ELECTRON_MCP_* setting would be ignored. A host that also grants --allow-env (with --allow-child-process) does let them through; then a handoff to Node (ELECTRON_MCP_RUNTIME=node, or a host oam below the floor) runs node --permission with no grants, because oam otherwise copies the host's --permission / --allow-* flags into Node's NODE_OPTIONS and Node refuses oam-only ones such as --allow-env= (exit 9, nothing served); the launcher prints one electron-mcp: line saying so. (The direct, no-launcher form is oam --permission run <path>/dist/index.js.)
VariableEffect
ELECTRON_MCP_RUNTIME=autonewest usable oam, else Node (default)
ELECTRON_MCP_RUNTIME=oamnewest usable oam, else exit with an error
ELECTRON_MCP_RUNTIME=nodealways Node (the sandbox is not applied, and the launcher says so)
ELECTRON_MCP_SANDBOX=1run oam under --permission with no grants; true / yes / on also enable it, 0 / false / no / off disable it
OAM_BIN=/path/to/oamuse this oam when it is usable, before discovery
OAM_INSTALL_DIR=/diroam's own install-target variable; when set, <dir>/oam is searched before the default install locations and PATH

Both values are case-insensitive and trimmed. A value the launcher does not recognise is never a silent no-op: it is treated as the default (auto; sandbox off) and named on stderr, so a typo cannot quietly turn "sandbox required" into "sandbox if convenient".

Tools (18)

IPC & process architecture (5)

  • electron_scaffold_ipc_channel — Generate a complete IPC round-trip: main handler, preload bridge, contextBridge exposure, TypeScript types, renderer usage.
  • electron_generate_preload_bridge — Generate a secure preload.ts with contextBridge for multiple API methods.
  • electron_audit_ipc_security — Analyze preload/main/renderer code for IPC security issues (direct ipcRenderer, missing sender validation, channel injection).
  • electron_generate_window_manager — Multi-window management with lifecycle tracking and inter-window communication.
  • electron_explain_process_model — Version-aware explanation of Electron's multi-process architecture (main vs renderer vs utility, what lives where).

Security (4)

  • electron_audit_security — Audit against 19 of the 20 official security recommendations that can be detected from static inputs: BrowserWindow, preload, CSP, remote content, sandbox. (Session permission handling is the 20th; it needs runtime context and is flagged in the report footer.)
  • electron_configure_fuses — Generate @electron/fuses config for production hardening (disable cookie encryption fallback, Node CLI flags, legacy load behaviour).
  • electron_configure_csp — Generate a Content Security Policy aware of your bundler (Vite/webpack/Parcel) and framework (React/Vue/Svelte).
  • electron_lint_security — Static analysis for dangerous patterns: shell.openExternal with untrusted input, @electron/remote, enableBlinkFeatures, etc.

Build & distribution (4)

  • electron_diagnose_build_error — Parse electron-builder/forge errors and identify root causes: code signing, native modules, ASAR, entitlements, path quoting.
  • electron_configure_auto_update — Generate complete electron-updater setup with events and platform-specific signing concerns.
  • electron_configure_deep_linking — Custom protocol registration across Windows/macOS/Linux.
  • electron_scaffold_project — Generate a secure, modern Electron project scaffold (contextIsolation: true, sandbox: true, preload, TypeScript, chosen framework).

Migration & compatibility (2)

  • electron_migrate_version — Migration checklist between Electron versions with breaking changes, deprecated APIs, platform support changes.
  • electron_check_deprecated_apis — Scan source for APIs deprecated or removed in the target Electron version.

Performance (1)

  • electron_audit_performance — Detect the 7 official Electron performance anti-patterns (sync I/O on main, eager loading of heavy modules, etc).

Reference (2)

  • electron_explain_concept — Authoritative explainer for 8 topics: process model, context isolation, sandbox, IPC, ASAR, fuses, code signing, build tools.
  • electron_knowledge_version — Metadata about the embedded knowledge: last-verified date, Electron stable at verification, supported version range. Call this if an agent is unsure whether advice is current.

Knowledge freshness

Tools that depend on embedded Electron knowledge (breaking changes, deprecated APIs, security recommendations, anti-patterns, concept explanations) append a footer like:

_Knowledge last verified 2026-04-13 (Electron v41 stable). For anything newer, check https://releases.electronjs.org._

Call electron_knowledge_version to get the metadata directly. When a new Electron major releases, KNOWLEDGE.md documents the update process.

Examples

Add a file picker the safe way

> "Add a file picker that lets the renderer read the selected file's contents"→ electron_scaffold_ipc_channel({    direction: "renderer-to-main",    channel: "open-file",    returns: "string"  })  # Generates: main handler (dialog.showOpenDialog + fs.readFile),  # preload bridge (contextBridge.exposeInMainWorld),  # TypeScript types for window.api.openFile,  # renderer usage example

Audit an existing app's security

> "Check my Electron app for security issues — here's my main.ts and preload.ts"→ electron_audit_security({ mainCode: "...", preloadCode: "..." })  # Returns a graded report against 19 of 20 recommendations  # (session permissions needs runtime context),  # flagging nodeIntegration, missing contextIsolation,  # unsandboxed renderers, loose CSP, and more.

Diagnose a failing signing step

> "electron-builder is exiting with: errSecInternalComponent — help"→ electron_diagnose_build_error({ output: "..." })  # Identifies macOS Keychain Access issue with code signing,  # returns specific `security` CLI fix and CI reconfiguration.

Plan an Electron major bump

> "We're on Electron 32. What breaks if we jump to 41?"→ electron_migrate_version({ from: 32, to: 41, sourceCode: "..." })  # Returns breaking changes across each major (33, 34, 35, ...),  # deprecated APIs found in your code,  # platform support changes,  # recommended test plan.

Generate a real CSP

> "Generate a CSP for my Vite + React renderer that actually works"→ electron_configure_csp({    bundler: "vite",    framework: "react",    allowedOrigins: ["https://api.mycompany.com"]  })  # Returns a CSP that accounts for Vite's dev-mode WebSocket,  # React's inline runtime, and blocks everything else.

Troubleshooting

"Tool output is cut off / too long"

  • A few scaffolders produce >10KB of generated code. Ask the assistant to regenerate with a narrower scope (single channel vs multi-channel bridge; one framework scaffold vs comparison).

"The advice is wrong for my Electron version"

  • Check electron_knowledge_version. If Electron has shipped a new major since the verified date, cross-check with the official breaking-changes page linked there.
  • File an issue on the repo with the specific tool + version + expected vs actual. Knowledge updates ship in minor versions.

"Windows: MCP server doesn't start"

  • Use the cmd /c npx ... pattern from the Quick start section. Node 20+ can't spawn .cmd files directly.

Requirements

  • Node.js 20.11+
  • No runtime dependencies

Contributing

bash
git clone https://github.com/YawLabs/electron-mcp.gitcd electron-mcpnpm installnpm run lint       # Biome checknpm run lint:fix   # Auto-fixnpm run build      # tsc + esbuild bundlenpm test           # node --test

See CONTRIBUTING.md for the full workflow, including release process.

License

MIT

[Follow @YawLabs on X]

來源:README.md,提交 380010e

工具

18

electron_scaffold_ipc_channel

Scaffold IPC channel

Generate complete IPC boilerplate for a new feature: ipcMain handler in the main process, preload bridge function with contextBridge, TypeScript type declarations, and renderer-side usage example. Produces all the files needed for a secure, type-safe IPC channel.

輸入參數argsdirection必填returnTypechannelName必填description必填apiNamespace

electron_generate_preload_bridge

Generate preload bridge

Generate a complete, secure preload.ts with contextBridge.exposeInMainWorld for multiple API methods. Produces the preload script, TypeScript declarations for window.electronAPI, and security best practices. Use this when you need to expose several main-process APIs to the renderer at once.

輸入參數methods必填namespace

electron_audit_ipc_security

Audit IPC security

Analyze preload script and main process IPC code for security issues. Checks for: raw ipcRenderer exposure, missing sender validation, synchronous IPC usage, listener memory leaks, prototype pollution via contextBridge, and insecure channel patterns. Provide the actual code content to analyze.

輸入參數mainCodepreloadCoderendererCode

electron_generate_window_manager

Generate window manager

Generate multi-window management boilerplate for Electron apps. Creates a WindowManager class that handles window lifecycle, inter-window communication, window state persistence, and proper cleanup. Supports common patterns like main + child windows, modal dialogs, and detached panels.

輸入參數windows必填persistState

electron_explain_process_model

Explain Electron process model

Get a clear, version-aware explanation of Electron's multi-process architecture. Covers the main process, renderer processes, preload scripts, utility processes, contextBridge, and how they interact. Useful for understanding the mental model before building features.

輸入參數topic必填electronVersion

electron_audit_security

Audit app security

Audit an Electron app against the official security checklist. Covers 19 of the items that can be detected from static inputs (BrowserWindow configuration, main process code, package.json, preload, HTML): HTTPS-only content, nodeIntegration, contextIsolation, sandbox, webSecurity, CSP, allowRunningInsecureContent, experimentalFeatures, enableBlinkFeatures, raw ipcRenderer exposure, direct window assignment, @electron/remote, supported Electron version, shell.openExternal validation, file:// usage, <webview> tag, will-navigate handler, setWindowOpenHandler, and IPC sender validation. The remaining checklist items (session permissions, fuse configuration) require runtime / packaging context and are flagged in the report's footer.

輸入參數mainCodehtmlContentpackageJsonpreloadCodeelectronVersionbrowserWindowConfig

electron_configure_fuses

Configure Electron fuses

Generate @electron/fuses configuration to harden your Electron app. Fuses are compile-time toggles that disable dangerous Electron features (like ELECTRON_RUN_AS_NODE, NODE_OPTIONS) and cannot be re-enabled by end users. Essential for production apps.

輸入參數level必填customFuses

electron_configure_csp

Configure Content Security Policy

Generate a Content Security Policy for an Electron app. Accounts for the bundler (Vite, webpack), framework (React, Vue, Svelte), and whether dev-mode exceptions are needed. Returns both meta-tag and session.webRequest approaches.

輸入參數bundlerneedsEvalexternalImagesneedsInlineStylesexternalConnections

electron_lint_security

Lint for security issues

Static analysis of Electron code for dangerous patterns: shell.openExternal with user input, @electron/remote usage, disabled webSecurity, missing navigation restrictions, unrestricted window creation, and other OWASP-style vulnerabilities specific to Electron.

輸入參數code必填fileType

electron_diagnose_build_error

Diagnose build error

Diagnose Electron build/packaging errors from electron-builder, electron-forge, or electron-packager output. Identifies common failures: code signing errors, native module rebuild issues, ASAR packaging problems, missing platform-specific configuration, and __dirname path resolution bugs.

輸入參數platformbuildToolerrorOutput必填

electron_configure_auto_update

Configure auto-update

Generate complete auto-update configuration using electron-updater. Produces main process setup, update event handling, renderer notification UI code, and platform-specific signing requirements. Supports GitHub releases, S3, and generic HTTP update servers.

輸入參數provider必填s3BucketgenericUrlgithubRepogithubOwnerautoDownloadautoInstallOnQuit

electron_configure_deep_linking

Configure deep linking

Generate complete custom protocol / deep linking setup for Electron. Produces protocol registration, URL handling in both single-instance and multi-instance modes, platform-specific configuration (macOS Info.plist, Windows registry, Linux .desktop), and electron-builder/forge config.

輸入參數routesprotocol必填singleInstance

electron_scaffold_project

Scaffold Electron project

Generate a complete, secure, modern Electron project scaffold. Includes proper process separation, TypeScript configuration, framework integration, build tooling, security defaults, and an example IPC channel. Produces a full project structure ready to develop.

輸入參數name必填featuresbuildToolframework

electron_migrate_version

Migrate Electron version

Generate a migration checklist for upgrading between Electron versions. Lists all breaking changes, deprecated APIs, and required code modifications between the current and target versions.

輸入參數targetVersion必填currentVersion必填

electron_check_deprecated_apis

Check for deprecated APIs

Scan code for usage of deprecated or removed Electron APIs. Returns a list of deprecated APIs found with their replacements and the version they were deprecated/removed in.

輸入參數code必填electronVersion

electron_audit_performance

Audit performance

Analyze Electron app code for 7 official performance anti-patterns: eager module loading, synchronous main-process operations, excessive BrowserWindows at startup, unnecessary polyfills, CDN-loaded assets, heavy preload scripts, and unbundled dependencies. Returns specific fixes.

輸入參數mainCodepackageJsonpreloadCoderendererCode

electron_explain_concept

Explain Electron concept

Get a clear, authoritative explanation of an Electron concept. Counters outdated tutorial content with accurate, version-aware information. Covers: process model, context isolation, sandbox, IPC, ASAR, fuses, code signing, and build tool comparison.

輸入參數concept必填

electron_knowledge_version

Get embedded-knowledge version

Return metadata about the embedded Electron knowledge used by this MCP's analysis tools -- the date it was last verified against official Electron docs, the current Electron stable version at that time, and the supported version range for migration/deprecation checks. Call this when you need to know whether the advice from other tools is current.

無需輸入參數。

版本歷史

6
  1. v1.7.1最新Oct 31, 2026
  2. v1.7.0Oct 9, 2026
  3. v1.6.5Oct 7, 2026
  4. v1.6.4Oct 6, 2026
  5. v1.6.3Sep 30, 2026
  6. v1.6.2Sep 16, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分