gemini-web-cdp
Provides a bridge to Gemini Web (gemini.google.com), enabling agents to start chats, ask prompts with attachments, manage multi-turn conversations, and export replies as Markdown via a Chrome extension or CDP fallback.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
gemini-web-cdp
Zero-prompt local bridge and stdio MCP server for Gemini Web (gemini.google.com), combining a lightweight Chrome MV3 extension (port 9335) with an automatic isolated CDP browser fallback (port 9333) and lossless DOM-to-Markdown conversion.
SKILL.md 提供可直接加载到 Agent 的技能规范;plugin-template/ 提供 MCP 插件配置模板。
解决什么问题
在本地 Agent / IDE 工作流中调用网页端 Gemini(如 Carbon / High Thinking / 网页历史多轮对话 / 文件上传)时,常规方案常遇到三类阻塞:
远程调试弹窗阻塞:直接连接日常 Chrome
DevToolsActivePort会反复触发「Allow remote debugging?」人工授权弹窗。后台标签冻结:Chrome 对非激活隐藏标签页会节流 Angular 变更检测与输入管线,导致点击发送后不响应。
长任务断流与重复发题:深度思考任务常耗时 5–10 分钟,普通一次性等待容易超时或盲目重发产生重复对话。
gemini-web-cdp 通过「本地扩展网关 + 独立自动化副窗口 + 20 秒启动确认兜底 + 状态机监控恢复」一次解决上述问题。
Related MCP server: Chrome Ops MCP
架构概览
Agent / CLI / MCP Client
│ (stdio JSON-RPC 2.0 / CLI)
▼
gemini_mcp_server.mjs ──托管──▶ 127.0.0.1:9335 Local Hub (Host/Origin/MIME 校验)
│ │
├─ Channel 1 (首选, 0 弹窗) ─────────┼── WebSocket (/gemini-ext) ──▶ Chrome MV3 扩展 (v1.3.1)
│ │ └─ 独立自动化副窗口 (focused: true)
│ │ 20s 启动确认 + 结束后自动清理标签
└─ Channel 2 (自动兜底) ─────────────┴──▶ 127.0.0.1:9333 独立 Chrome Profile (--headless=new / 离屏)
└─ 20s 未启动 / 扩展未连时无感接管核心特性
零额外第三方 Node 依赖:仅使用 Node.js 内置标准库(
http/net/crypto/child_process/readline)。双通道自动路由(
--mode auto):优先复用日常已登录 Chrome 的 MV3 扩展(
9335),不依赖chrome.debugger,无顶部黄条。若扩展未连线,自动无感使用独立 Profile(
9333)继续执行;点击发送后若 20 秒内未确认生成启动,则返回SUBMISSION_UNKNOWN并保留原页面供核对,绝不跨通道重复发题;仅在确认属于本工具管理的独立实例时才允许close关闭。
默认
Carbon + High与严格校验:默认切换carbon模型与high(高 / 超级详尽)思考等级(传keep可跳过切换);模型未匹配时直接报错并返回页面可用模型列表。4 级附件上传回退:依次尝试
existing_input->drop_xap(拖拽事件)->plus_menu_input(点击+菜单主/次输入框)->paste(剪贴板粘贴事件),单附件限制 20 MiB,适配 Gemini DOM 变动。60 秒心跳监测与防盲目重发状态机:
尚未生成
/app/<id>会话 ID 且 120 秒零输出时,停止并限量重发最多 1 次;一旦生成
/app/<id>,遇报错横幅或 240 秒停滞时优先刷新同一会话恢复(最多 2 次)或点击“重新生成”,绝不重复刷屏提问。
高保真 DOM -> Markdown:html_to_md.py 自动剥离思考折叠块、按钮与图标,提取代码块语言标签、保护行内/块级 LaTeX 公式(
$...$/$$...$$)、保留围栏代码块内部空行与 GFM 表格。本地网关双向密码学认证与安全边界:
127.0.0.1:9335在 HTTP 侧强制校验回环Host、拒绝任意跨站Origin、POST /ext-rpc精确限制application/json(并发上限8、50 MB请求体 /20 MiB单附件、30s读超时);客户端与网关通过0600/当前用户 ACL 保护的extension_hub_auth.json执行HMAC-SHA256双向挑战-响应与单次 Nonce 防重放(绝不向未验证监听者发送提示词或附件)。WebSocket
/gemini-ext启用 5 秒握手超时、最大帧/分片上限与 Chrome 扩展 ID 固定(GEMINI_WEB_EXTENSION_ID或首次连接自动 Pin),并通过一次性配对密钥(node scripts/gemini_cdp.mjs pair-key写入扩展选项页)做 WebCryptoHMAC-SHA256双向握手验证后才受理 RPC。独立 Chrome
close命令必须同时核对端口真实监听 PID、规范化独立 Profile 路径与状态文件归属;目标 URL 与页面 DOM 执行强制校验location.origin === "https://gemini.google.com",并内置busyTabIds防止同标签并发提交冲突。
环境要求
Node.js
>= 20.0.0(已通过v24.16.0验证)Python
>= 3.10+ 依赖库:pip install -r requirements.txtGoogle Chrome
>= 116(Windows 已实测;macOS / Linux 支持通过CHROME_EXE与PYTHON_EXE/GEMINI_CDP_PROFILE_DIR环境变量适配)
快速上手
1. 安装 Python 转换依赖与静态自检
pip install -r requirements.txt
npm run check2. 在日常 Chrome 加载并一次性配对扩展
生成本机一次配对密钥:
node scripts/gemini_cdp.mjs pair-key打开
chrome://extensions,开启右上角 开发者模式,点击 加载已解压的扩展程序,选择本仓库的extension/目录。点击该扩展卡片的 扩展程序选项(Details -> Extension options),粘贴第 1 步输出的
pairKey并点击 Save & Connect(密钥存于扩展本地存储,仅用于验证本地127.0.0.1:9335网关身份)。后续运行
mcp或hub时扩展每 20 秒自动重连本地127.0.0.1:9335;需要热更新代码时可执行node scripts/gemini_cdp.mjs reload-ext。
3. 配置原生 Stdio MCP Server(推荐)
在任意支持 MCP 的客户端(Antigravity / Claude Code / Codex / Cursor 等)配置中使用 plugin-template/mcp_config.example.json:
{
"mcpServers": {
"gemini-web-cdp": {
"command": "node",
"args": [
"<PATH_TO_REPO>/scripts/gemini_mcp_server.mjs"
]
}
}
}可用 MCP 工具包括:gemini_web_status、gemini_web_list、gemini_web_ask(支持 async: true 后台提交)、gemini_web_job_status、gemini_web_export、gemini_web_close。
4. CLI 直接调用示例
# 检查连接与登录状态
node scripts/gemini_cdp.mjs status --mode auto
# 列出最近会话
node scripts/gemini_cdp.mjs list --limit 10
# 发送提示词 + 附件,默认 Carbon + 高思考,结果写入 Markdown
node scripts/gemini_cdp.mjs ask --new-chat --attach ./context.md --prompt "请结合附件输出关键风险对比表。" --out-md ./reply.md
# 指定会话 URL 多轮追问(传入 --keep-tab 可保留自动化标签页)
node scripts/gemini_cdp.mjs ask --url https://gemini.google.com/app/<conversation_id> --prompt "请补充验证清单。"
# 导出整段会话为 Markdown
node scripts/gemini_cdp.mjs export --url https://gemini.google.com/app/<conversation_id> --out-md ./full_thread.md
# 若使用 9333 独立隔离兜底窗口:Windows 可运行 scripts/Start-GeminiChrome.cmd 手动登录,用完可执行
node scripts/gemini_cdp.mjs close --port 9333环境变量说明
变量名 | 用途 | 默认行为 |
| 自定义 Chrome 可执行文件路径 | 自动探测系统常见 Chrome 安装路径 |
| 自定义 | 系统应用数据目录下的 |
| 自定义 Python 解释器路径 | Windows 用 |
安全边界与免责声明
本项目仅在本地回环地址(
127.0.0.1)运行,不读取、导出或上传任何 Cookie、localStorage或账号密码;遇到accounts.google.com登录页或验证码时直接返回LOGIN_REQUIRED由人工处理。严禁在自动化提示词或附件中上传受控机密文件、API Key 或个人隐私信息;请自行遵守目标网站的服务条款。
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Build, run, debug, test and ship Chrome, Firefox, Edge and Safari extensions from your AI agent.
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Let AI agents use your real, signed-in Chrome: tabs, clicks, forms, screenshots and video.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to drive a logged-in ChatGPT web session over CDP, including managing projects and chats, sending messages with file attachments, and retrieving long Pro replies.124MIT
- AlicenseBqualityBmaintenanceEnables AI coding agents to inspect and operate Chrome as a developer, including reading DevTools console/network data, evaluating JavaScript, and managing unpacked extensions during an edit-test-debug loop.24MIT
- AlicenseNot gradedqualityCmaintenanceEnables local agents to send conversations and image-generation requests through user-authorized web chat and Flow Chrome tabs, poll or cancel jobs, and download generated images without API keys or remote debugging. Runs locally over stdio with explicit per-request confirmation and token-paired extension controls.MIT

corsen-browserofficial
AlicenseNot gradedqualityBmaintenanceEnables AI agents to use selected signed-in Chrome tabs as MCP tools for reading pages, performing trusted interactions, inspecting DevTools errors, capturing network APIs, and taking screenshots, while also providing local OpenAI- and Anthropic-compatible chat endpoints backed by signed-in web chat tabs.Apache 2.0