Skip to main content
Glama
sa2web-mcp

sa2web-mcp

by sa2web

# SA2WEB MCP

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
npx playwright install chromium --with-deps

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 --with-deps
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.

Related MCP server: Playwright MCP

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 stable targetId values.

  • 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 compact context=[t1,t2] references for controls. Optional filter accepts a CSS selector; omit it for the default full snapshot. Use ref=eN values for actions. id=tN and context=[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 optional selector must be a real CSS selector; do not pass snapshot text ids such as t7, #t7, or text[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 use setInputFiles directly.

  • 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 against iframe#rbi-frame.

  • browser_close: close the browser session.

Advanced compatibility tools:

  • browser_open_login: open SA2_LOGIN_URL.

  • browser_list_proxies: list cloud browsing proxy options from /api/v1/home/freebrowse.

  • browser_navigate: open a target URL through cloud browsing; optional surf is 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

Available Tools

19 tools
browser_checkB

Check a checkbox or radio by ref, selector, role/name, or text.

Inputs: ref, name, role, text, +1 more.

browser_closeB

Close the current Playwright browser session.

Inputs: no named parameters.

browser_file_uploadC

Upload files through a file input by ref or selector.

Inputs: ref, path, paths, selector.

browser_fill_formB

Fill multiple form fields at once.

Inputs: fields (required).

browser_handle_dialogC

Accept or dismiss the current JavaScript dialog.

Inputs: accept, timeoutMs, promptText.

browser_list_devicesA

List all Playwright device presets available to browser_toggle_device. Returns each preset's viewport, screen, device scale factor, touch/mobile flags, and default browser type. Desktop is included as the restore target.

Inputs: no named parameters.

browser_navigateA

Advanced compatibility tool. Navigate to a public URL through cloud browsing. Prefer sa2_open_target with type=cloud for simpler agent behavior.

Inputs: url (required), surf, waitUntil.

browser_navigate_backA

Go back by clicking the remote browser toolbar button #btn-back.

Inputs: no named parameters.

browser_navigate_forwardA

Go forward by clicking the remote browser toolbar button #btn-forward.

Inputs: no named parameters.

browser_open_loginA

Advanced compatibility tool. Open the configured remote browser login URL from SA2_LOGIN_URL; most agents should prefer sa2_open_target, which logs in automatically.

Inputs: waitUntil.

browser_pasteA

Paste clipboard-style text and/or files into a target by snapshot ref, selector, or role/name. Supports text/plain, text/html, text/rtf, and local file paths such as images. If no target is provided, the focused editable element is used, then the root document body.

Inputs: ref, rtf, html, name, +5 more.

browser_reloadA

Reload by clicking the remote browser toolbar button #btn-reload.

Inputs: no named parameters.

browser_resizeC

Resize the browser viewport.

Inputs: width (required), height (required).

browser_run_codeC

Run an async JavaScript snippet with Playwright page and iframe#rbi-frame helpers.

Inputs: code (required).

browser_screenshotC

Take a PNG screenshot of the current page.

Inputs: fullPage.

browser_select_optionC

Select dropdown option values by ref or selector.

Inputs: ref, index, label, value, +2 more.

browser_take_screenshotC

Take a PNG screenshot of the current page.

Inputs: fullPage.

browser_toggle_deviceA

Toggle the current browser page between desktop and mobile device emulation without recreating the browser context. Uses Playwright device descriptors and Chromium CDP for dynamic mobile metrics, touch, device scale factor, orientation, and user agent. On Firefox/WebKit only viewport resizing is available. Omit enabled to toggle the current state.

Inputs: width, device, height, reload, +5 more.

browser_uncheckB

Uncheck a checkbox by ref, selector, role/name, or text.

Inputs: ref, name, role, text, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 19 tools

    Disambiguation2/5

    The set contains two identical screenshot tools (browser_screenshot and browser_take_screenshot), creating direct ambiguity. Several other tools overlap in edge behavior (browser_paste/browser_file_upload, browser_toggle_device/browser_resize), and browser_navigate references a sa2_open_target tool not present in the set, making selection confusing.

    Naming Consistency4/5

    Tool names consistently use a browser_ prefix with snake_case verbs, which makes the overall pattern predictable. The main inconsistency is browser_screenshot versus browser_take_screenshot, where two names exist for the same action, plus the odd browser_open_login compatibility naming.

    Tool Count3/5

    19 tools is on the heavy side for a browser utility surface, especially given a duplicate screenshot tool and advanced compatibility aliases. It is not excessive enough to be unusable, but several tools feel redundant, so the count is not well-trimmed.

    Completeness2/5

    Fundamental browser interactions are missing: there is no general click, text extraction, wait, or hover tool, and browser_run_code is the only fallback for basic actions. The descriptions also recommend sa2_open_target as the preferred entry point, but that tool is absent from the set, creating a dead end.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables browser automation and web scraping by exposing Playwright tools through an HTTP-based MCP server. Users can navigate pages, interact with web elements, capture screenshots, and extract structured content using a persistent Chromium instance.
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Exposes Playwright browser automation as MCP tools, enabling AI assistants to control a real browser tab-by-tab for form filling, navigation, and more, while preserving the user's active session.
      -
    • F
      license
      A
      quality
      C
      maintenance
      Enables coding agents to drive a real Playwright-backed browser session, navigating, observing, interacting, and capturing proof on web pages via MCP tools across stdio and Streamable HTTP transports.
      15
      2
      -