electrobun-devtools
v0.2.4
Published
Dev-mode instrumentation lib for Electrobun apps. Drop into your `src/bun/index.ts` to expose runtime state to the electrobun-plugin MCP server (Claude Code). Read more at https://github.com/arijit-gogoi/electrobun-plugin
Maintainers
Readme
electrobun-devtools
Dev-mode instrumentation library for Electrobun apps. Companion to the electrobun-plugin Claude Code plugin — exposes your running app's state to the plugin's MCP server so Claude can read RPC traffic, watch FFI calls, eval in main process, inspect the updater, tail native logs, and more.
Dev only. Refuses to start when
NODE_ENV === "production". Do not ship in your production build.
Install
bun add -d electrobun-devtoolsUse
// src/bun/index.ts
import { BrowserWindow } from "electrobun/bun";
import { devtools } from "electrobun-devtools";
if (process.env.NODE_ENV !== "production") {
await devtools.start({ port: 9876 });
}
new BrowserWindow({ url: "views://mainview/index.html" });On first run, devtools.start():
- Generates a session token, prints it to stdout:
[electrobun-devtools] token: xyz123... - Writes the token to
.electrobun-devtools-tokenin your project dir (gitignored). - Listens on
localhost:9876for the MCP server to connect.
You paste the token into Claude Code once (see plugin instructions). Reuse across sessions.
To rotate the token: delete the file, OR call devtools.start({ forceToken: true }).
What the plugin gets access to
Once connected, the electrobun-plugin MCP exposes tools to Claude:
electrobun_list_windows()— enumerateBrowserWindowinstances.electrobun_rpc_log()— recent bun↔webview RPC traffic.electrobun_ffi_log()— recent native FFI calls.electrobun_bun_eval(code)— evaluate in the main process. Gated. RequiresallowEval: truein plugin user-config; off by default.electrobun_updater_state()— currentUpdaterstate.electrobun_app_log()— recent bun process console output.electrobun_native_log()— platform-native log tail. Currently Windows-only in this version.
Security model
- All tools require auth via the session token. No token in WS handshake = connection refused.
bun_evalrequires plugin user-configallowEval: trueopt-in. Default is off.- Token file
.electrobun-devtools-tokenis gitignored. Do not commit. - Listens on
localhostonly. Not reachable from network. - Refuses to start in production.
Version coupling
electrobun-devtools is version-locked with electrobun-plugin. Major.minor must match. If they don't, the plugin refuses to connect and prints an upgrade message. Bump both together.
License
MIT.
