sa2web-mcp
Exposes a remote browser as MCP tools via Playwright, enabling AI agents to navigate and interact with web pages through DOM snapshots, clicks, typing, and form operations.
README
SA2 Playwright MCP Wrapper
Languages: English | 中文 | 日本語 | Français | Español | Русский
This project exposes a DOM-based remote browser as MCP tools through Playwright.
The remote browser shell renders the target website inside iframe#rbi-frame. browser_snapshot
always starts from that iframe and recursively includes descendant iframe nodes. DOM tools such as
browser_extract_text, browser_click, browser_type, and browser_wait operate inside that
iframe tree by default.
For agents, the recommended path is intentionally small:
sa2_help
-> sa2_list_available_targets # only when opening saved SaaS/workspace/inner sites
-> sa2_open_target
-> browser_snapshot or browser_extract_text
-> browser_click / browser_type / browser_press / browser_wait
Use sa2_open_target directly for arbitrary public websites:
{
"type": "cloud",
"url": "https://example.com"
}
Use sa2_list_available_targets first for saved SaaS, workspace, and inner-site entries. It
returns stable targetId values such as saas:12, workspace:34, and inner:56; pass one of
those to sa2_open_target.
The lower-level browser_* list/enter/navigate tools are still available for compatibility and
advanced control, but normal agents should prefer the sa2_* tools above.
browser_navigate opens target URLs through cloud browsing. The remote browser origin is inferred
from SA2_LOGIN_URL.
So browser_navigate({ "url": "https://example.com" }) opens:
https://www.test7878.com/?surf=direct&_d=https%3A%2F%2Fexample.com
Install
After the package is published to npm, normal users can install it globally so sa2, sa2-browser, and sa2-mcp are available on PATH:
npm install -g sa2web-mcp
If you are installing from a local checkout instead of npm, build first and then install the current folder globally:
npm install
npx playwright install chromium
npm run build
npm install -g .
Plain npm install only installs dependencies for the current checkout; it does not put this package's own commands on your global PATH. For development, npm link is also fine after npm run build.
Run
npm start
Development mode:
npm run dev
CLI:
npm run build
npm run cli -- help
npm run cli -- shell
npm run cli -- targets
npm run cli -- open https://example.com
npm run cli -- open --target-id workspace:123
npm run cli -- open workspace 123
npm run cli -- saas GitHub
npm run cli -- inner 7
npm run cli -- snapshot --url https://example.com --headless true
npm run cli -- snapshot --url https://example.com --filter 'main article'
npm run cli -- click --url https://example.com --ref e3
npm run cli -- type --url https://example.com --selector '#email' --text hello@example.com
After global install or link, the package exposes sa2 and sa2-browser CLI commands, plus sa2-mcp for MCP clients. The CLI starts the MCP server over stdio internally and supports shell, open, targets, saved-target shortcuts (workspace, saas, inner), snapshot, text, click, type, paste, scroll, device, press, wait, screenshot, back, forward, reload, close, and raw tool commands.
Use sa2 shell for a persistent browser session. Single-command invocations still start their own server process and close it when the command finishes, so pass --url, --target-id, or another target selector for commands that need page state. If no target is provided, the CLI opens SA2_LOGIN_URL.
Inside sa2 shell, refs from snapshot stay available for later commands:
sa2> open https://example.com
sa2> targets
sa2> open --target-id workspace:123
sa2> open saas GitHub
sa2> inner 7
sa2> snapshot
sa2> click --ref e3
sa2> type --selector '#email' --text hello@example.com
sa2> screenshot --output page.png
sa2> exit
MCP Client Config
The repository includes .mcp.json for local development. MCP clients can run sa2-mcp only after the package is globally installed or linked:
npm install
npm run build
npm install -g .
Use npm link instead of npm install -g . if you want changes in the checkout to be reflected immediately during development.
The important values are:
{
"SA2_LOGIN_URL": "https://www.test7878.com/agent/login?clientId=...&clientSecret=...",
"SA2_LOGIN_REDIRECT_PATH": "/app/login",
"SA2_LOGIN_REDIRECT_WAIT_MS": "8000",
"SA2_RBI_FRAME_SELECTOR": "#rbi-frame",
"SA2_RBI_FRAME_WAIT_MS": "5000",
"SA2_RBI_FRAME_CONTENT_WAIT_MS": "15000",
"SA2_AUTO_LOGIN_BEFORE_NAVIGATE": "true",
"SA2_LOGIN_SETTLE_MS": "1500",
"SA2_IGNORE_HTTPS_ERRORS": "true",
"SA2_LOG_LEVEL": "info",
"SA2_LOG_STDERR": "true",
"SA2_LOG_FILE": "/tmp/sa2-browser.log"
}
Logging uses a log4js-style timestamp, level, and category layout. Levels are trace, debug, info, warn,
error, fatal, and off. Logs go to stderr by default because stdout is reserved for the MCP stdio protocol;
SA2_LOG_FILE optionally appends the same redacted logs to a file. URL secrets, tokens, passwords, cookies, and
authorization values are redacted.
For real use, keep clientSecret outside source control and inject it through your MCP client's
environment configuration.
Different AI clients use different MCP config shapes. Ready-to-copy templates are available in configs/README.md, including Claude Desktop, Claude Code, Cursor, Windsurf, VS Code Copilot, Cline, Roo Code, opencode, Gemini CLI, and Zed.
Tools
Recommended high-level tools:
sa2_help: return the intended agent workflow and examples.sa2_list_available_targets: list proxy options plus all saved SaaS, workspace, and inner-site targets with stabletargetIdvalues.sa2_open_target: open any target. Use{ "type": "cloud", "url": "https://example.com" }for public websites, or{ "targetId": "workspace:34" }for saved targets.
Page inspection and interaction tools:
browser_snapshot: return a flat semantic snapshot for models with interactable refs, readable text ids, media elements, descendant iframes, hidden raw URLs, and compactcontext=[t1,t2]references for controls. Optionalfilteraccepts a CSS selector; omit it for the default full snapshot. Useref=eNvalues for actions.id=tNandcontext=[tN]are snapshot-only text references, not DOM ids, CSS selectors, or actionable refs.browser_extract_text: return visible page text from the iframe tree. Its optionalselectormust be a real CSS selector; do not pass snapshot text ids such ast7,#t7, ortext[id='t7'].browser_click: click by snapshot ref, selector, role/name, text, or x/y coordinates.browser_type: type/fill by snapshot ref, selector, role/name, or currently focused element, preserving multiline textarea and contenteditable input.browser_press/browser_press_key: press a keyboard key.browser_wait: wait for milliseconds, text, selector, or URL substring.browser_hover/browser_drag: mouse hover and drag.browser_fill_form/browser_select_option/browser_check/browser_uncheck: form operations.browser_file_upload: upload files through file inputs.browser_paste: paste plain text, HTML, RTF, and local files (including images) through clipboard data; file inputs usesetInputFilesdirectly.browser_scroll: scroll the root page or an element by direction/distance, to coordinates or edges, or bring a ref/selector target into view.browser_list_devices: list every Playwright device preset accepted by device emulation.browser_toggle_device: toggle desktop/mobile emulation using Playwright device presets and Chromium CDP without recreating the browser context.browser_handle_dialog: accept or dismiss alert/confirm/prompt dialogs.browser_navigate_back/browser_navigate_forward/browser_reload: click the shell buttons#btn-back,#btn-forward, and#btn-reload.browser_screenshot/browser_take_screenshot: return a PNG screenshot.browser_resize: resize the viewport.browser_evaluate/browser_run_code: run debugging code againstiframe#rbi-frame.browser_close: close the browser session.
Advanced compatibility tools:
browser_open_login: openSA2_LOGIN_URL.browser_list_proxies: list cloud browsing proxy options from/api/v1/home/freebrowse.browser_navigate: open a target URL through cloud browsing; optionalsurfis validated against/api/v1/home/freebrowse.browser_list_saas_sites/browser_enter_saas_site: list and enter SaaS sites.browser_list_workspaces/browser_enter_workspace: list workspace accounts and enter an account-level workspace.browser_list_inner_sites/browser_enter_inner_site: list and enter internal sites.
Agent usage
See docs/AGENT_USAGE.md for detailed instructions on connecting this MCP server to an AI agent, recommended tool workflows, publishing safeguards, and troubleshooting.
For opencode-specific setup notes, see docs/OPENCODE_USAGE.md.
Manual test
npm run build
npm run manual-test -- https://example.com
Keep the browser open while debugging:
npm run manual-test -- https://example.com --keep-open
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。