npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nebula-agents/electron-mcp

v0.1.0

Published

Embedded MCP server for Electron apps.

Downloads

309

Readme

@nebula-agents/electron-mcp

Embedded MCP server for Electron apps. It runs inside your Electron main process, exposes the BrowserWindow surfaces you choose, and lets MCP clients drive those renderers through Chrome DevTools Protocol.

Embedded vs External Attach

This package is for apps that want MCP automation as an opt-in feature of the app itself. Your main process decides when the server starts, which windows are reachable, and which custom tools are registered.

External-attach servers connect to an already-running Electron app through a remote debugging port. That can be useful for local debugging, but it does not let the app own surface naming, gating, or app-specific tools. If you want that external model, this package is probably not the right fit.

Quickstart

import { app, BrowserWindow } from "electron";
import {
  createElectronMcpServer,
  recommendedGuards,
} from "@nebula-agents/electron-mcp";

let mainWindow: BrowserWindow | null = null;

const mcp = createElectronMcpServer({
  getSurfaces: () => ({ main: mainWindow }),
});

app.whenReady().then(async () => {
  mainWindow = new BrowserWindow();

  if (recommendedGuards({ app, envVar: "MY_APP_MCP" })) {
    await mcp.start();
    console.log(`MCP listening at ${mcp.url}`);
  }
});

app.on("before-quit", () => {
  void mcp.stop();
});

Connect an MCP client to the logged HTTP URL. The default is http://127.0.0.1:9229/mcp.

API

const mcp = createElectronMcpServer({
  getSurfaces: () => ({ main: mainWindow, settings: settingsWindow }),
  port: 9229,
  host: "127.0.0.1",
  path: "/mcp",
  instructions: "Optional client-facing instructions.",
});

createElectronMcpServer(config) returns a synchronous handle:

  • addTool(toolDef) registers a custom tool. Call it before start().
  • start() starts the loopback HTTP server.
  • stop() stops the HTTP server and detaches CDP sessions.
  • isRunning reports whether the server is active.
  • url is the bound MCP endpoint once running.

Bundled tools:

  • list_surfaces
  • show_surface
  • hide_surface
  • focus_surface
  • reload_surface
  • screenshot
  • evaluate
  • click
  • type_text
  • press_key
  • hover
  • query_dom
  • ax_snapshot
  • fill_form
  • wait_for_load

Public types are available from the root export and from @nebula-agents/electron-mcp/types.

Custom Tools

import { z } from "zod";
import type { ToolDef } from "@nebula-agents/electron-mcp/types";

const resetStateTool: ToolDef = {
  name: "reset_state",
  config: {
    title: "Reset State",
    description: "Reset the app's local demo state.",
    inputSchema: { profile: z.enum(["empty", "demo"]) },
  },
  handler: async ({ profile }) => {
    await resetLocalState(profile);
    return { content: [{ type: "text", text: "ok" }] };
  },
};

mcp.addTool(resetStateTool);

Tools must be registered before start(). Dynamic tool registration and tools/list_changed are intentionally out of scope for 0.x.

Security Model

The server binds to loopback only by default: 127.0.0.1. Attempts to bind a non-loopback host throw. There is no authentication layer in 0.1.0; if your threat model requires more than loopback isolation, wrap this package in your own gate or do not start it.

Recommended production guard:

import { recommendedGuards } from "@nebula-agents/electron-mcp";

if (recommendedGuards({ app, envVar: "MY_APP_MCP" })) {
  await mcp.start();
}

The helper returns true only when the app is not packaged and the selected environment variable is set to "1". It throws if neither app.isPackaged nor isPackaged is provided.

Maintenance

This is open code with no support SLA. Agent Labs reviews issues and PRs on a best-effort basis. 0.x versions may change API shape based on real usage.

License

MIT.