使用说明
电子mcp服务器
MCP(模型上下文协议)服务器,用于通过Chrome DevTools协议(CDP)实现Electron应用程序自动化。与Cursor、Claude Desktop或任何MCP客户端一起使用。
使用MCP时的要求
- Node.js:需要运行MCP服务器(npx或全局安装时的Node环境)。
- Electron远程调试:将应用程序
--remote-debugging-port=<port>运行时才能连接。推荐端口: 9222 (单个应用程序),如果是多个应用程序 9229, 9230 等(服务器按9229→9230→9222→…顺序扫描)。
许可证
MIT© 哈哈
用法(光标)
-
安装 (如果使用npx,则可选):
npm install -g @ohah/electron-mcp-server或使用
npx无需安装(见步骤2)。 -
在游标中添加MCP服务器
- 打开 光标设置 → 主控程序 (或编辑
.cursor/mcp.json在你的项目中)。 - 添加:
{ "mcpServers": { "electron-mcp": { "command": "npx", "args": ["-y", "@ohah/electron-mcp-server"] } } } - 打开 光标设置 → 主控程序 (或编辑
-
运行您的Electron应用程序 通过远程调试:
electron . --remote-debugging-port=9222 -
重新启动游标(或重新加载MCP)。这
electron-mcp当应用程序连接时,工具将可用。
用法(克劳德桌面)
在Claude桌面配置中(例如。 ~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"electron-mcp": {
"command": "npx",
"args": ["-y", "@ohah/electron-mcp-server"]
}
}
}
然后使用以下命令运行您的Electron应用程序 --remote-debugging-port=9222 并重新启动克劳德桌面。
发展
- 工具: 布置 (参见
.mise.toml),oxlint/oxfmt表示皮棉和格式。 - 脚本:
bun run build,bun run mcp(运行MCP服务器),bun run start(运行示例Electron应用程序)。