@nebula-agents/electron-mcp
Embedded MCP server for Electron apps that exposes BrowserWindow surfaces and lets MCP clients drive renderers through Chrome DevTools Protocol.
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 beforestart().start()starts the loopback HTTP server.stop()stops the HTTP server and detaches CDP sessions.isRunningreports whether the server is active.urlis the bound MCP endpoint once running.
Bundled tools:
list_surfacesshow_surfacehide_surfacefocus_surfacereload_surfacescreenshotevaluateclicktype_textpress_keyhoverquery_domax_snapshotfill_formwait_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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。