browser-control-tencent-cloud
This MCP server lets you control your locally running, already-logged-in Microsoft Edge browser to automate Tencent Cloud console tasks (DNSPod DNS records and CVM/Lighthouse security group rules) via CDP, without handling credentials.
Connect to Edge:
connect_edgeattaches to a local Edge browser over CDP (default port 9222), returning browser version and all tab URLs/titles with login-status preflight.Take screenshots:
take_screenshotcaptures the active tab (or a specific tab viapageUrlContains) as Base64 PNG, with full-page option and auto-downgrade for large pages.Navigate Tencent Cloud console:
navigate_tencent_consolequickly opens DNSPod, CVM, Lighthouse, or a custom URL, auto-detecting login/verification needs and attaching screenshots when human intervention is required.Interact with page elements:
interact_elementperforms clicks, fills, waits, hovers, selects, presses keys, types real keyboard events (for xterm/Canvas terminals like OrcaTerm), reads text, and reloads; supports CSS/text/xpath selectors and iframe targeting.Manage DNS records:
add_dns_recordadds or updates DNSPod records (A/AAAA/CNAME/MX/TXT/etc.) with auto or forced create/update modes, then verifies by reading back the table.Configure security groups/firewall rules:
configure_security_groupadds or lists inbound/outbound rules for CVM or Lighthouse instances (supports single/multiple/range ports, TCP/UDP/ICMP/ALL, ACCEPT/DROP, source CIDR), with risk warnings for high-risk ports.Coordinate human authentication:
wait_for_user_authdetects, waits for, or confirms login/verification completion (QR code, slider, etc.), returning screenshots and page state to hand off to the user.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@browser-control-tencent-cloud Add an A record for blog.example.com to 1.2.3.4 in DNSPod"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
腾讯云浏览器控制 MCP Server
让 LLM 替你点腾讯云控制台。 通过 CDP(Chrome DevTools Protocol)接管你本机已登录的 Microsoft Edge,完成 DNSPod 域名解析 与 CVM / 轻量应用服务器(Lighthouse)安全组 / 防火墙规则 的配置。
项目 | 值 |
协议内自报名( |
|
传输方式 | stdio( |
运行时 | Node.js ≥ 18.18(实测 Node 24.x / Edge 153 / Playwright 1.63 / MCP SDK 1.30) |
浏览器接管方式 |
|
工具数量 | 7 |
0. 它解决什么问题
腾讯云控制台是重登录态的 React 单页应用:微信扫码、短信验证、滑块验证层层叠加,LLM 无法自己登录;而直接用云 API 又需要 SecretId / SecretKey,意味着把长期凭据交给模型。
本项目走第三条路:借用你浏览器里已经存在的登录态。
┌──────────────┐ stdio / JSON-RPC ┌─────────────────────┐ CDP ┌──────────────────┐
│ MCP Client │ ◄──────────────────► │ 本 MCP Server │ ◄──────► │ 你的 Edge 窗口 │
│ (Claude / │ 7 个 Tool │ (dist/index.js) │ 9222 │ (已登录腾讯云) │
│ Cursor/DSH) │ │ 无凭据、无 Cookie │ │ 登录态天然存在 │
└──────────────┘ └─────────────────────┘ └──────────────────┘设计原则(先看这一节,能避免 90% 的误解)
不碰账号密码。 本 Server 从不读取、不保存、也不代填任何腾讯云账号密码、短信验证码或扫码凭据。它只是"借用"你浏览器里已经存在的登录态。遇到登录 / 验证码时会主动停下来,提示你人工处理。
不启动、也不关闭浏览器。 它只通过 CDP 附加 到你手动启动的 Edge 上。即使本 Server 退出,你的 Edge 窗口和标签页也不会被关闭(代码里刻意不调用
browser.close())。只连本机回环地址。 所有 CDP 连接都是
http://127.0.0.1:<port>,不对外网暴露。每一步都可追溯。 每个工具的返回值里都带
steps(做了什么、成功还是跳过、耗时多久);失败时自动附带失败现场截图,让 LLM 能接着用interact_element手工收尾。
Related MCP server: browser-mcp
1. 快速开始
1.0 三步走
# ① 克隆并构建
git clone https://github.com/zhili663/tencent-browser-mcp.git
cd tencent-browser-mcp
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install
npm run build
# ② 启动一个「可被 CDP 接管」的 Edge(Windows 双击即可)
scripts\start-edge-cdp.bat
# ③ 在这个窗口里登录腾讯云,然后把 dist/index.js 配到你的 MCP 客户端1.1 启动带 CDP 调试端口的 Edge
最快的方式:双击自带的一键启动脚本(推荐)
scripts\start-edge-cdp.bat ← 双击运行即可它会自动完成:找到 Edge → 用独立配置目录启动 → 打开腾讯云控制台 → 等待并自检调试端口 → 打印"可以接管了"。
脚本启动的这个 Edge 和你日常用的 Edge 可以同时开着,互不干扰(因为配置目录不同)。在这个窗口里登录一次腾讯云之后,登录态会持久保存在该目录里,以后直接双击 → 确认已登录 → 让 Agent 接管即可。
脚本还支持参数(命令行调用时):
scripts\start-edge-cdp.bat -Port 9333 # 换调试端口(之后调用工具时传 cdpPort=9333)
scripts\start-edge-cdp.bat -UserDataDir "D:\EdgeCDP" # 换配置目录
scripts\start-edge-cdp.bat -NoOpenTencent # 启动时不自动打开腾讯云端口已经就绪时,重复运行不会多开浏览器,只会提示"已就绪,直接连"。
启动器还会等登录页真正渲染出来:全新配置目录第一次访问腾讯云时,登录页可能长时间停在"白底 + 一句品牌 slogan"的占位壳上(看起来就是白屏)。启动器会自动刷新重试,最多等 120 秒,并在控制台打印进度,不会让你对着白屏干等。详见 FAQ 的 Q4。
下面的手工命令适合你想自己掌控参数、或排查问题时使用。
1.1.1 为什么必须加 --user-data-dir(最容易踩的坑)
从 Chrome 136 / 对应版本的 Edge 开始,官方出于安全考虑不再允许对"默认用户数据目录"开启远程调试端口:如果你只写 --remote-debugging-port=9222 而不指定 --user-data-dir,端口很可能根本不会监听(命令行看起来完全正常,但 connect_edge 会一直报 ECONNREFUSED)。
所以:请务必显式指定一个独立的 --user-data-dir。
参考:Changes to remote debugging switches to improve security(Chrome for Developers)
副作用与对策:独立目录 = 一个全新的浏览器配置文件,第一次需要在这个配置文件里登录一次腾讯云(之后会持久保存在该目录中,不会每次都要求登录)。
1.1.2 各平台启动命令
# Windows(推荐:使用独立配置文件目录,不影响你日常使用的 Edge)
& "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" `
--remote-debugging-port=9222 `
--user-data-dir="$env:LOCALAPPDATA\EdgeCDP" `
--no-first-run --no-default-browser-checkEdge 装在 64 位目录时,把路径换成 C:\Program Files\Microsoft\Edge\Application\msedge.exe 即可。
# macOS
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" \
--remote-debugging-port=9222 --user-data-dir="$HOME/EdgeCDP"
# Linux
microsoft-edge --remote-debugging-port=9222 --user-data-dir="$HOME/EdgeCDP"启动后访问 http://127.0.0.1:9222/json/version 能看到 JSON,就说明端口已就绪。
2. 编译构建
2.1 前置要求
node -v # 需要 >= 18.18,建议 20/22/24 LTS
npm -v # 或用 pnpm / yarn,命令等价其它机器上部署时,装官方 Node.js LTS 即可:https://nodejs.org/
2.2 安装依赖
npm install建议顺手跳过 Playwright 自带浏览器下载(约 500MB):本项目只做 CDP 接管,从不需要 Playwright 自己下载的 Chromium。
# Windows PowerShell
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1; npm install# macOS / Linux
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install2.3 构建
npm run build # tsc 编译 src/index.ts -> dist/index.js
# 其它可用脚本:
npm run watch # 增量编译
npm run typecheck # 只做类型检查
npm run clean # 删除 dist
npm run rebuild # clean + build2.4 自检(两条命令,强烈建议先跑通再配客户端)
npm run smoke # 协议层自检:不需要开浏览器,拉起进程跑 initialize / tools/list / tools/call
npm run e2e # 端到端自检:需要先启动可接管的 Edge(默认连 9222)
npm run e2e -- --cdp-port 9333 # 指定端口smoke:校验 7 个工具的 JSON Schema、错误处理、以及 stdout 没有被日志污染(stdio 型 MCP Server 最常见的翻车点)。退出码 0 = 全部通过。e2e:真实连接 Edge 跑完 9 步:connect_edge → take_screenshot → get_text → 故意失败的选择器(校验失败信封)→ type 真实键盘输入 → navigate_tencent_console → wait_for_user_auth → connect_edge 登录态预检 → 白屏占位自愈。 其中第 5 步会在本机临时起一个测试页,验证type真的把字符敲进了页面(这正是 Web 终端的形态);第 9 步验证白屏能被识别并自动刷新重试。
⚠️
e2e会驱动当前激活标签页跳转(含一个本地测试页和腾讯云页面)。请用一个专门的测试窗口跑它,不要对着正在干正事的标签页运行。
2.5 手动启动(排错用)
# Windows PowerShell
$env:MCP_LOG_LEVEL='debug'; node dist/index.js
# macOS / Linux
MCP_LOG_LEVEL=debug node dist/index.js正常情况下它会"挂住"等待 stdin 上的 JSON-RPC 报文;Ctrl+C 退出。所有日志都在 stderr,stdout 只用于协议通信。
3. 配置到 MCP 客户端
下面配置里的键名就是客户端里显示的 Server 名称,同时决定工具在模型侧的前缀(例如键名 tencent-browser → 工具 mcp__tencent-browser__connect_edge)。
请把 /ABSOLUTE/PATH/TO/tencent-browser-mcp/dist/index.js 换成你自己的绝对路径;Windows 路径在 JSON 里必须写成双反斜杠(D:\\code\\tencent-browser-mcp\\dist\\index.js)。
3.1 Claude Desktop
配置文件位置:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"tencent-browser": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/tencent-browser-mcp/dist/index.js"],
"env": {
"MCP_LOG_LEVEL": "info"
}
}
}
}改完必须完全退出并重启 Claude Desktop(不是关窗口,是退出进程)。
3.2 Cursor
项目级:<项目根>/.cursor/mcp.json;全局:Windows %USERPROFILE%\.cursor\mcp.json,macOS/Linux ~/.cursor/mcp.json。
{
"mcpServers": {
"tencent-browser": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/tencent-browser-mcp/dist/index.js"],
"env": {
"MCP_LOG_LEVEL": "info"
}
}
}
}配置后在 Cursor 的 Settings → MCP 里确认该 Server 状态为绿色(已连接),并在对话中把工具授权给 Agent 使用。
3.3 其它客户端 / 命令行 Agent
MCP 是客户端无关协议:任何支持 stdio 型 MCP Server 的客户端,用的都是上面同一份 mcpServers 结构。把它粘进对应客户端的配置文件(或 --mcp-config 指定的文件)即可。
{
"mcpServers": {
"tencent-browser": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/tencent-browser-mcp/dist/index.js"],
"env": {
"MCP_LOG_LEVEL": "info"
}
}
}
}如何确认挂载成功:让客户端列出工具,应当看到且仅看到这 7 个:connect_edge、take_screenshot、navigate_tencent_console、interact_element、add_dns_record、configure_security_group、wait_for_user_auth。
少数客户端换了外层键名(例如 VS Code 的
.vscode/mcp.json用"servers"且需要"type": "stdio"),内层字段(command/args/env)完全一致。
3.4 配置检查清单
node -v能输出版本号(客户端启动 Server 时用的是同一个node)dist/index.js存在(先跑过npm run build)路径是绝对路径,Windows 下反斜杠已转义成
\\已运行
scripts\start-edge-cdp.bat,且窗口提示"可接管状态就绪"改完配置后重启了客户端
npm run smoke退出码为 0
4. 工具清单
工具 | 关键参数 | 说明 |
|
| 连接/复用一个 CDP 连接,返回浏览器版本、所有标签页的 URL/标题,以及 |
|
| 截取当前激活标签页,返回 Base64 PNG(MCP image content)。整页截图超过约 3.5MB 会自动降级为可视区域截图。 |
|
| 快捷导航。导航后自动检测登录/验证码:命中时直接附带截图并给出人工介入提示。 |
|
| 通用兜底操作。选择器支持 CSS / |
|
| 高层封装:打开解析记录页 → 查重 → 新增或修改 → 保存 → 回读表格校验。 |
|
| 高层封装:定位实例 → 打开安全组/防火墙 → 添加规则 → 提交。 |
|
| 人机协同: |
4.1 一个典型的完整流程
对 LLM 说:"把
www.example.com的 A 记录指向1.2.3.4,TTL 600,然后给广州的ins-abcdefgh放行 80 和 443 端口。"
期望的调用顺序:
connect_edge → 确认接管的窗口与标签页
navigate_tencent_console(dnspod) → 打开控制台
↳ 若返回 needsUserAuth=true → 让用户在弹出的 Edge 里登录/扫码 → wait_for_user_auth(mode=detect) 轮询
add_dns_record(domain=example.com, subDomain=www, recordType=A, value=1.2.3.4, ttl=600)
↳ 失败时看返回里的 steps + 截图,用 interact_element 手工收尾
configure_security_group(region=ap-guangzhou, instanceId=ins-abcdefgh, port=80,443, protocol=TCP, policy=ACCEPT)
↳ 返回里带 warnings 提醒高危端口风险4.2 推荐工作流:先登录,再让 Agent 接管
# ① 双击(或在终端运行)启动器 —— 打开一个「可被接管」的 Edge 窗口
scripts\start-edge-cdp.bat[*] Edge: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
[*] 启动 Edge(调试端口 9222)...
[OK] 可接管状态就绪:Edg/153.0.4234.32 端点 http://127.0.0.1:9222② 在这个窗口里正常登录腾讯云(微信扫码 / 账号密码都行,本工具完全不接触你的凭据)
③ 回到 Agent 这边说一句:「已登录,继续」
④ Agent 做的第一件事就是 connect_edge 做登录态预检,并把结果摊开给你看,例如:
preflight: 发现 1 个腾讯云标签页:1 个可直接操作,0 个需要人工登录/验证
tencentTabs: [ { authRequired: false, authKind: "none", url: "https://console.cloud.tencent.com/lighthouse/instance/index" } ]登录态判断是"实测"而不是"猜":不仅看 URL,还会实际探测页面上有没有登录框、扫码二维码容器、滑块验证 iframe 等特征。如果预检显示"需要人工登录",Agent 会停下来告诉你,而不是对着登录页瞎点。
4.3 操作失败时你会拿到什么
任何一步失败(包括**"操作做了但回读校验没通过"**这种业务性失败),返回体里都必然同时包含这三样:
字段 | 内容 |
| 步骤轨迹:第几步、做了什么、 |
| 页面文字摘要(最多 1200 字,已压缩空白),告诉你当时页面上到底写了什么 |
图片内容块 + | 失败现场截图(Base64 PNG)+ 截图元信息(URL、标题、字节数、时间) |
再加上 hint(排错建议)与 details.page.url/title,足够判断是"选择器失效"还是"需要登录"还是"权限/配额限制"。
4.4 用本 Server 在 Lighthouse 上部署 1Panel(实操示例)
前提:scripts\start-edge-cdp.bat 已启动、你已在该窗口登录腾讯云。之后 Agent 会这样走:
connect_edge→ 确认登录态就绪(tencentTabs里authRequired: false)。navigate_tencent_console(target: "lighthouse")→ 打开轻量应用服务器实例列表。定位目标实例 → 打开它的在线终端 / OrcaTerm(或
configure_security_group(mode: "list")先确认 22/80/443 等端口的现状)。敲 1Panel 安装命令(关键一步用
type):{ "action": "type", "selector": "终端区域的选择器(例如 .xterm 或 iframe 内的容器)", "text": "curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh", "submit": true, "delay": 30 }type走的是真实键盘事件,所以 xterm/Canvas 终端能收到(fill只改 DOM 值,终端收不到);submit: true会在输入完自动回车;delay: 30是每个字符间隔毫秒数,别低于 20,否则终端可能丢字符;如果终端在 iframe 里,用
frameUrlContains定位那个 frame。
安装脚本是交互式的(会问端口、安全入口、用户名密码)。每一步的终端回显要读回来给你看(
type的返回里有screenText,get_text也能读终端文本),需要你决定的地方停下来问,绝不替你编密码。装完后用
configure_security_group放行 1Panel 面板端口(默认面板端口在安装时指定,常见 8090 / 安全入口随机路径),再把面板地址给你。全程可随时
take_screenshot看画面。
⚠️ 安全组是"真实变更云上配置":变更前先展示要加什么、加完回读规则列表;对
0.0.0.0/0放行 22/3389/3306/6379 这类高危端口时返回里会带warnings提醒。1Panel 官方安装脚本地址(
resource.fit2cloud.com)请在执行前自行确认;涉及从外网拉脚本执行的操作,先看命令原文再执行。
5. 环境变量
变量 | 默认 | 说明 |
|
|
|
6. 安全说明
凭据:本 Server 不接收、不存储任何账号密码或验证码;登录必须由你本人在浏览器里完成。
浏览器:绝不调用
browser.close()(那会关掉你正在用的 Edge 窗口)。退出时只释放 CDP 连接。网络:只连
127.0.0.1(CDP 端口)。除腾讯云控制台页面本身外,不向外发送任何数据。变更类操作:
add_dns_record/configure_security_group会真实修改云端配置。工具描述里已标注destructiveHint: true,请在客户端的工具授权里留意;configure_security_group支持mode="list"先只读确认。风险提醒:对
0.0.0.0/0放行22/3389/3306/6379/27017等高危端口时,返回结果里会带warnings字段提示,建议改用具体来源 IP。
7. Web 终端(OrcaTerm / xterm)怎么读输出
这是本项目最关键的一个工程约束,务必了解:
OrcaTerm / xterm 把终端渲染进 <canvas>,终端文字完全不在 DOM 里。
实测:没有 .xterm-rows,没有无障碍层(.xterm-accessibility),React fiber 里也拿不到 Terminal 实例。
所以"读命令输出"不能靠抓 DOM,只能靠 截图 + OCR:
# 敲命令(真实键盘事件,终端才能收到)
node scripts/mcp-call.mjs --calls-file calls.json # calls.json 里用 interact_element + action=type + submit=true
# 读输出(截图 + Windows 内置 OCR,OCR 由 ocr-image.ps1 完成)
node scripts/read-screen.mjs --url-contains orcaterm --selector .xterm --scale 3要点:
--scale 3会在截图前把deviceScaleFactor临时调到 3 倍(小字号等宽字体 OCR 更准),截完立即恢复,不影响你继续用。OCR 引擎是 Windows 自带的
Windows.Media.Ocr(通常为zh-Hans-CN),不依赖任何第三方服务,图片不出本机。OCR 会把
_读成空格(MY_VAR→MY VAR)、把0读成e、1读成l。因此:判断关键词时要容忍这些差异;
密码、密钥这类关键值,请以屏幕上的显示为准,不要让 OCR 结果当唯一依据。
命令输出尽量用"单列"(
awk '{print $4}'、sed -n 3p)形式打印,多列表格会被 OCR 按位置打乱。
dom-query.mjs 则是另一个方向的工具:页面是普通 DOM(例如 1Panel 面板、腾讯云控制台)时,直接跑 JS 把真实结构 dump 出来,比猜选择器可靠得多:
node scripts/dom-query.mjs --url-contains 8090 --js-file q.js8. 常见问题(FAQ)
Q1:connect_edge 报 connect ECONNREFUSED 127.0.0.1:9222
端口没监听。按顺序排查:① 是否没加 --user-data-dir(见 1.1.1 的 Chrome/Edge 136+ 限制);② Edge 是否本来就在运行(旧进程会吞掉新的启动参数,需先完全退出);③ 端口是否被占用(换 9333 并传 cdpPort);④ 用 http://127.0.0.1:9222/json/version 直接验证。
Q2:连上了,但操作的是"错误的"标签页
调用 connect_edge,看返回的 pages 数组与 activePage;必要时手动点一下目标标签页(工具通过 document.hasFocus() 判断激活页),或用 interact_element 明确指定选择器操作。多标签场景下,interact_element / take_screenshot 支持 pageUrlContains 显式指定标签页。
Q3:返回 needsUserAuth: true / authKind: "qr"
这是正常的人机交接,不是报错:登录态过期或需要扫码。请在 Edge 窗口里完成登录,然后用 wait_for_user_auth(mode=detect 轮询或 mode=wait)确认后再重试原操作。
Q4:打开腾讯云登录页只看到白屏 / 只有一句品牌 slogan 页脚怎么办?
这是登录 SPA 的加载占位壳,不是工具坏了。现象:页面白底,只有页脚一句 slogan,登录框和二维码都不出来。
原因:腾讯云登录页由 SSR 外壳 + 十几个外部脚本组成(cloudcache.tencent-cloud.com 的 react / passport 包、Aegis 探针、以及 Google Tag Manager / DoubleClick 等第三方脚本)。全新 Edge 配置目录第一次访问时缓存全空、脚本要逐个冷启动,容易长时间停在占位壳上。
三个解决办法(从省事到彻底):
在那个窗口按
Ctrl+R刷新一次 —— 绝大多数情况立刻就出来了。让工具自己修:调用
wait_for_user_auth(任意模式)或interact_element(action="reload"),工具会检测到白屏并自动刷新重试。重跑启动器:
scripts\start-edge-cdp.bat会主动等登录页渲染完成(自动刷新,最多 120 秒),并打印进度。
实测记录:同一个配置目录、同一个启动器,第一次冷启动时出现过该白屏;缓存预热后再启动,登录页(含微信二维码 iframe)秒开、无任何请求失败。所以这基本是一次性现象。
Q4.1:为什么启动器只开一个标签页了?
全新配置目录下,两个登录页同时冷启动会互相抢带宽,反而更容易停在白屏。需要 DNSPod 页面时,让 Agent 用 navigate_tencent_console(target="dnspod") 打开即可(那时缓存已经热了)。
Q5:腾讯云控制台改版了,add_dns_record / configure_security_group 失败
这两个工具用的是"多候选选择器 + 分步容错"的启发式策略,改版后可能需要调整。失败时返回里会带:
details.steps:卡在哪一步、为什么;details.page.textExcerpt:当时页面上的文字;一张失败现场截图。
推荐的应对顺序:① 用 take_screenshot 看清页面;② 用 interact_element 手工完成剩余步骤;③ 若要长期修好,改 src/index.ts 顶部集中定义的 CONSOLE_ENTRY_URLS / URL_CANDIDATES(地址变了改这里)与各 fillFieldByLabels / chooseDropdownOption 调用里的候选标签文案(字段名变了改这里),然后 npm run build。
Q6:客户端提示工具调用超时
wait_for_user_auth(mode=wait) 会长时间占住一次调用。改用 mode=detect,让 LLM 每隔几秒轮询一次(返回体会给出这个建议)。
Q7:截图太大 / 图片被客户端丢弃
整页截图超过约 3.5MB 会自动降级为可视区域截图(返回里 downgradedFromFullPage: true)。也可以传 savePath 落盘,或干脆用默认的 fullPage: false。
Q8:日志在哪里看?
全部在 stderr。Claude Desktop 的日志目录是 Windows %APPDATA%\Claude\logs\、macOS ~/Library/Logs/Claude/,其中 mcp-server-*.log 对应各个 MCP Server。把 MCP_LOG_LEVEL 设为 debug 会打印每个选择器的命中情况。手动排错时直接 MCP_LOG_LEVEL=debug node dist/index.js 最直观。
Q9:为什么工具返回值是 JSON 文本 + 图片两个 content 块?
文本块是结构化状态(含 steps、ok、hint),图片块是失败现场或页面状态截图。MCP 客户端会把两样都交给模型,所以模型既能读到严格字段、也能"看见"页面。
9. 项目结构
tencent-browser-mcp
├── package.json # 依赖与脚本(build / smoke / e2e / clean)
├── tsconfig.json # TypeScript 配置(NodeNext ESM,strict + noUncheckedIndexedAccess)
├── src/
│ └── index.ts # MCP Server 全部实现(7 个 Tool、CDP 单例、异常处理)
├── scripts/
│ ├── start-edge-cdp.bat # 一键启动「可被 CDP 接管」的 Edge(双击即可,纯 ASCII 以兼容 cmd 代码页)
│ ├── start-edge-cdp.ps1 # 启动器的实际逻辑(端口自检 + 登录页渲染自检,带 UTF-8 BOM 以兼容 PS 5.1)
│ ├── wait-login-ready.mjs# 盯着登录页直到真正渲染出来:白屏就自动刷新重试
│ ├── diagnose-page.mjs # 页面排错:DOM 探针 + 失败请求 + 控制台报错 + 截图(白屏/卡死时用)
│ ├── dom-query.mjs # 在页面里跑一段 JS 并打印结果(drive 陌生控制台时的"眼睛",只读)
│ ├── read-screen.mjs # 截图 + OCR:读取 canvas 渲染的 Web 终端输出(见第 7 节)
│ ├── ocr-image.ps1 # Windows 内置 OCR(Windows.Media.Ocr),被 read-screen.mjs 调用
│ ├── mcp-call.mjs # 批量调用 MCP 工具(入参写在 JSON 文件里,避免命令行拼 JSON)
│ ├── mcp-client.mjs # 极简 MCP stdio 客户端(供上述脚本复用)
│ ├── smoke-test.mjs # 协议层自检:npm run smoke
│ └── e2e-check.mjs # 端到端自检(9 步,含 type 输入、登录态预检、白屏自愈):npm run e2e
├── dist/ # 构建产物(dist/index.js 就是 MCP 客户端要启动的入口)
└── .gitignore10. 已知限制(如实说明)
腾讯云控制台 UI 自动化是启发式的。 控制台是 React SPA 且会改版;本 Server 用"多候选选择器 + 标签文案匹配 + 分步容错 + 回读校验"来提高鲁棒性,但不保证改版后无需调整(调整点见 Q5)。真正稳定的做法是改用腾讯云官方 API(需要 SecretId/SecretKey),那属于另一套方案。
高危变更没有二次确认弹窗。 工具会在调用前由 MCP 客户端展示参数并请求授权(
destructiveHint: true),Server 自身不做 dry-run。建议先用configure_security_group(mode="list")查看现状。首次使用独立 profile 需要登录一次,这是 Chrome/Edge 136+ 安全限制带来的必然代价。
一个进程只维护一条 CDP 连接。 同时操作多个浏览器实例需要起多个 Server 进程(各自不同的端口)。
wait_for_user_auth(mode=wait)这类长轮询依赖客户端不超时;工具已给出mode=detect的替代路径。
11. License
Available Tools
7 toolsadd_dns_record添加/修改 DNS 解析记录ADestructive
高层封装:在 DNSPod 控制台为指定域名添加或修改一条解析记录。流程为:打开该域名的解析记录页 → 检查是否已存在同主机记录+同类型的记录 → 存在则点"修改",否则点"添加记录" → 按标签填写主机记录/记录类型/记录值/TTL → 保存 → 回读表格校验。mode=auto 时自动判断新增还是修改;mode=create 强制新增;mode=update 要求记录必须已存在。若中途遇到登录过期/滑动验证,会停下来返回截图并提示人工介入(不会盲目继续点)。执行过程会返回完整步骤轨迹;失败时附带失败现场截图,可用 interact_element 手工收尾。
Inputs: value (required), domain (required), subDomain (required), recordType (required), +4 more.
configure_security_group配置服务器安全组/防火墙规则ADestructive
⚠️ 会真实修改云上防火墙配置。高层封装:在服务器控制台为指定实例添加一条入站/出站规则(放行或拒绝端口)。流程为:按地域打开实例列表 → 搜索 instanceId → 打开该实例的安全组/防火墙配置 → 切到对应方向 → 点"添加规则" → 填写来源/协议端口/策略/备注 → 提交 → 回读规则列表确认。product 可显式指定 cvm(云服务器安全组)或 lighthouse(轻量应用服务器防火墙);若不指定,会根据 instanceId 前缀自动判断(ins- 开头为 CVM,lhins- 开头为 Lighthouse)。port 支持单端口(80)、多端口(80,443)、端口段(8000-9000);protocol 为 TCP/UDP/ICMP/ALL,policy 为 ACCEPT/DROP。对 0.0.0.0/0 开放 22/3389/3306/6379 等高危端口时会返回风险提醒(仅提醒,不阻断)。改版导致界面变化时,会返回失败现场截图与手工步骤建议。
Inputs: port (required), policy (required), region (required), protocol (required), +7 more.
connect_edge连接本地 Edge 浏览器ARead-only
通过 CDP(Chrome DevTools Protocol) 连接本机已用 --remote-debugging-port 启动的 Microsoft Edge。这是所有其它 Tool 的前置步骤(其它 Tool 在未连接时也会自动尝试连接)。返回浏览器版本、CDP 端点以及当前所有标签页的 URL/标题,便于确认"接管"的是正确的窗口。本 Server 不会启动新浏览器、不会关闭用户的浏览器窗口,也不读取或保存任何账号凭据。
Inputs: force, cdpPort.
interact_element页面元素基础交互ADestructive
在当前页面上执行基础 DOM 操作。action 取值:click=点击;fill=填写输入框(自动兼容受控组件,失败会降级为模拟键入);wait_for=等待元素出现/可见/隐藏;hover=鼠标悬停;select=选择下拉项(text 传选项文案);press=发送按键(text 传按键名,如 Enter);type=用真实键盘事件逐字输入(专用于 xterm/Canvas 这类"看不见输入框"的 Web 终端,例如腾讯云 OrcaTerm 在线终端;selector 传终端容器用于点击取得焦点,传 body 表示直接往当前焦点输入,配合 submit=true 会在输入完按 Enter);get_text=读取元素文本。selector 支持 Playwright 全部选择器语法:CSS、text=文字、xpath=//...、以及 :has-text() 等扩展伪类。所有操作失败时返回结构化错误并附上当前页面截图,便于 LLM 修正选择器后重试。
Inputs: action (required), selector (required), nth, text, +8 more.
take_screenshot截取当前标签页截图ARead-only
截取 Edge 当前激活标签页的屏幕截图,以 Base64 PNG 返回(MCP image content)。用途:确认页面当前状态、识别滑动验证码/图形验证码、核对表单是否填写正确、排查操作失败原因。建议在每次关键操作后调用一次,作为"视觉反馈"闭环。为避免报文过大,整页截图超过约 3.5MB 时会自动降级为可视区域截图并在返回中标注。
Inputs: cdpPort, fullPage, savePath, pageUrlContains.
wait_for_user_auth等待人工完成登录/验证ARead-only
当检测到登录过期、滑动验证码、微信扫码等需要人工介入的情况时,暂停自动化流程并等待用户处理。mode=detect:立即检测当前页面的登录/验证状态并返回截图,不等待(适合客户端有工具超时限制的场景,可反复调用轮询)。mode=wait:持续轮询直到登录/验证完成或超时(默认 180 秒,最长 900 秒)。mode=confirm:用户已人工确认处理完毕,清除挂起状态并返回当前页面状态。无论哪种模式都会返回截图与当前 URL/标题,便于确认人机交接是否成功。
Inputs: mode, note, cdpPort, timeoutMs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clear, distinct role: connection setup, screenshot capture, console navigation, low-level DOM interaction, two high-level cloud workflows, and auth wait handling. Even though interact_element overlaps mechanically with the high-level tools, the descriptions clearly position it as a primitive, so an agent should not misselect.
All tool names follow an imperative verb_noun pattern in snake_case: connect_edge, take_screenshot, navigate_tencent_console, interact_element, add_dns_record, configure_security_group, wait_for_user_auth. The naming is highly predictable and consistent.
Seven tools is well-scoped for a browser-control server focused on Tencent Cloud console automation. Each tool earns its place: a connection step, a visual feedback step, navigation, a general interaction primitive, two high-level workflows, and a human-in-the-loop auth tool.
The core loop of navigate → interact → screenshot → handle auth is well covered, and the two high-level workflows include verification steps. Minor gaps remain: there is no tab-switching, page text extraction beyond get_text, scrolling, or delete operations for DNS/security-group rules, but agents can work around most of these.
Maintenance
Related MCP Connectors
DoorLoop MCP server for ChatGPT, Claude and any AI agent: list tenants, create lease, post rent charge and record payment in your own DoorLoop account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to DoorLoop yourself; Cotlet does not store your password and you need no DoorLoop API key. About the official DoorLoop API: DoorLoop has an open REST API, but it is not self-serve (checked 11 Oct 2026). The pricing page lists API access on the Premium plan only, DoorLoop says it is "still selective about who gets access", and you apply and talk by phone before you get the documentation. Setup and FAQ: https://cotlet.dev/integrations/doorloop-api-mcp-server
TaxDome MCP server for ChatGPT, Claude and any AI agent: create job, request documents, send invoice, message client and list overdue tasks in your own TaxDome account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to TaxDome yourself; Cotlet does not store your password and you need no TaxDome API key. About the official TaxDome API: TaxDome has no public API that firms can use today (checked 14 Oct 2026). Its Zapier integration only creates, updates and finds contacts, and TaxDome MCP, which would let Claude or ChatGPT work in a firm account, is announced but not open yet and is offered to Professional and Business plan firms first. Setup and FAQ: https://cotlet.dev/integrations/taxdome-api-mcp-server
LinkedIn MCP server for ChatGPT, Claude and any AI agent: create post, comment on post, send message, send connection invitation, search people, search companies, list connections and read conversations in your own LinkedIn account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to LinkedIn yourself; Cotlet does not store your password and you need no LinkedIn API key. About the official LinkedIn API: LinkedIn has an official API, but most of it needs an approved application (checked 6 Nov 2026). The open Share on LinkedIn permission lets an app post, comment and like on behalf of a member. Setup and FAQ: https://cotlet.dev/integrations/linkedin-api-mcp-server
Teachable MCP server for ChatGPT, Claude and any AI agent: update lecture, create coupon, send email, reply to comment and list enrollments in your own Teachable account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to Teachable yourself; Cotlet does not store your password and you need no Teachable API key. About the official Teachable API: Teachable has a public API, but only on the Growth plan and up, and it reads courses and lecture content and manages users, enrollments, pricing plans and transactions (checked 11 Oct 2026). Lesson editing, coupons, emails to students and comments are not in it. Setup and FAQ: https://cotlet.dev/integrations/teachable-api-mcp-server
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables LLM-powered browser automation and security testing with features like browser management, network monitoring, DOM manipulation, and captcha handling.521-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to control a local Chromium browser via CDP for page snapshots, screenshots, human-like interactions, autonomous crawling, API/GraphQL reconnaissance, authenticated differential testing, and Burp-like intercept, repeater, and intruder workflows with scope enforcement and audit logging.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to control local Chrome/Edge browser profiles through MCP, including tab groups, bounded DOM actions, observations, and optional encrypted credential use.MIT
- AlicenseAqualityCmaintenanceEnables LLM agents to launch or attach to a Microsoft Edge session and drive it through a four-tiered tool set spanning navigation, clicking, typing, and token-efficient accessibility-tree inspection. Also exposes raw Chrome DevTools Protocol calls for network interception, cookie manipulation, console and performance telemetry, and device emulation.202MIT