Skip to main content
Glama
README.md
# MCP Gateway

> 统一 MCP 工具网关 — Agent 通过它访问 WebPilot 浏览器工具及其他后端能力
> 给 Agent 用的 Electron 托盘应用

## 快速开始

```bash
# 1. 安装依赖
cd "C:\Users\13952\Desktop\cursor 工作\mcp-gateway"
npm install

# 2. 启动 Electron 托盘应用
npm run electron
```

启动后:
- 系统托盘中出现 MCP Gateway 图标
- Agent 可通过 `http://127.0.0.1:9223/mcp` 连接
- 如果 WebPilot 项目已安装依赖,Gateway 会自动拉起它并暴露 79 个浏览器工具

## 架构

```
Agent (oh-agent-company 角色)
  │ MCP 协议 (tools/list, tools/call)
  ▼
MCP Gateway (:9223)
  ├── Registry (工具注册表)
  ├── WebPilot Bridge → WebPilot daemon (:9224 MCP / :9225 HTTP) → Chrome (:9222 CDP)
  └── [可插拔] 其他后端
```

## 端口

| 端口 | 服务 | 说明 |
|------|------|------|
| 9223 | Gateway MCP | Agent 连接端点 |
| 9224 | WebPilot MCP | WebPilot 内部 MCP (由 Gateway 管理) |
| 9225 | WebPilot HTTP | WebPilot HTTP API (由 Gateway 代理) |

## 目录结构

```
mcp-gateway/
├── package.json
├── electron/
│   └── main.cjs        # Electron 主进程 (单实例锁 + 托盘 + 启动 Gateway)
├── src/
│   ├── server.js        # MCP Gateway 核心 (StreamableHTTP Server)
│   ├── registry.js      # 工具注册表
│   └── webpilot-bridge.js # WebPilot 子进程管理 + 工具代理
└── resources/
```

## 健康检查

```bash
curl http://127.0.0.1:9223/health
# => { "status": "ok", "backends": [...], "toolCount": 79 }
```

## 开发

```bash
# 独立运行 (不带 Electron 托盘)
node src/server.js

# 环境变量
GATEWAY_PORT=9223       # Gateway 监听端口
```

## 前置要求

- Node.js >= 22
- WebPilot-v4.0.1-handoff 项目 (`npm install` 在该目录下也需执行)
- Chrome (需开启 `--remote-debugging-port=9222`)

## 与 oh-agent-company 的集成

已更新的角色 (可使用 WebPilot MCP 工具):

| 角色 | 事业部 | 用途 |
|------|--------|------|
| web-tester | 02-科技与工程 | 浏览器自动化测试 |
| qa-engineer | 02-科技与工程 | bug 复现、回归测试 |
| security-auditor | 02-科技与工程 | 客户端安全扫描 |
| market-researcher | 01-经济与产业 | 在线竞品调研 |
| deep-researcher | 13-基础学科与人类科学 | 多源在线检索 |
| academic-researcher | 03-教育与学术 | 学术数据库检索 |

详见 `../oh-agent-company/oh-agent-company/共享/场景模板/09-浏览器自动化测试.md`