browser-trace

browser-trace

MCP server that lets agents drive a browser and record every action into a replayable trace, then replay it deterministically with network request assertions. It exposes tools for navigating, clicking, filling, and verifying requests.

Category
访问服务器

README

<div align="center"> <img src="assets/logo.png" width="420" alt="Browser-Trace" /> <p><b>Record browser actions as a replayable Trace. Replay them deterministically — no agent, no LLM — and assert on network requests.</b></p> <p><b>English</b> · <a href="README.zh-CN.md">简体中文</a></p> </div>


Drive a browser once (by an agent, a script, or by hand). Every action is captured to a Trace (JSONL). Transpile that Trace into a declarative Replay Spec (YAML), then replay it deterministically forever — for regression checks, smoke tests, or reproducing a bug.

  • Record — every command (navigate / click / fill / …) auto-writes one Trace line with a full locator descriptor (all candidate selectors + role/text + rect) and the network requests it produced.
  • Transpile — mechanical Trace → Replay Spec. Drops failed attempts, carries the locator fallback chain, turns wait_for_request steps into assertions. Marks anything a human/LLM should review with _review.
  • Replay — reads the spec, locates each target by the fallback chain (selector → role+text → rect), and verifies assertions against the request store. Deterministic and cheap.

Ships three ways to use it: a CLI, an MCP server (for agents), and a Skill.

Requirements

  • Bun — build tool + dev runtime (runs the TypeScript directly).
  • Node ≥ 18 — runtime for the shipped dist/*.mjs artifacts.
  • Chrome / Chromium — the CLI launches and owns a managed instance.

Install

As a Claude Code plugin

The plugin bundles an MCP server whose tools an agent calls to drive + record.

git clone <this-repo> browser-trace
cd browser-trace
bun install
bun run build        # produces dist/cli.mjs + dist/mcp.mjs

.claude-plugin/plugin.json registers the MCP server as node ${CLAUDE_PLUGIN_ROOT}/dist/mcp.mjs. Install the plugin via your marketplace/local plugin path, or register the server directly:

claude mcp add browser-trace --scope local -- node /abs/path/to/browser-trace/dist/mcp.mjs

As a standalone CLI

bun run build
node dist/cli.mjs help

Quickstart (CLI)

# 1. launch a managed browser (headful; add --headless for CI)
node dist/cli.mjs launch --session demo

# 2. drive it — each action records one Trace line
node dist/cli.mjs navigate "https://example.com" --intent "open page"
node dist/cli.mjs snapshot                       # read-only: see clickable elements
node dist/cli.mjs click --role link --text "Learn more" --intent "open docs"
node dist/cli.mjs wait --url-pattern "*/api/track*" --intent "verify beacon"

# 3. stop (kills the browser)
node dist/cli.mjs stop

# 4. mechanical Trace → Replay Spec
node dist/cli.mjs transpile output/demo.trace.jsonl

# 5. deterministic replay (launches its own browser, checks assertions)
node dist/cli.mjs replay output/demo.replay.yaml

Replay writes a <spec>.compare.json with recorded_ms vs replay_ms (record-time command execution excludes agent think time, so a real agent recording is far slower than replay).

Commands

Command Records? Purpose
launch / stop / status own the browser lifecycle (random port, temp profile)
snapshot / screenshot no (read-only) perceive the page to pick a locator
navigate <url> yes go to a URL
click / fill yes act via --selector or --role+--text (never coordinates)
clear-cookies --patterns "reA,reB" yes delete cookies by name regex (e.g. force a deduped beacon to re-fire)
evaluate <js> yes escape hatch
wait --url-pattern P yes sync point / assertion — did a matching request fire this session
transpile <trace.jsonl> Trace → Replay Spec (YAML)
replay <spec.yaml> deterministic replay + assertions + timing

MCP tools

Same surface as the CLI, prefixed mcp__browser-trace__: trace_start / trace_stop / snapshot / screenshot / navigate / click / fill / clear_cookies / evaluate / wait_for_request. The MCP server is a thin forwarder — every tool shells out to the CLI, so MCP-driven and CLI-driven recording share one code path.

How it works

record (any driver, all via one entry)
  → Trace (JSONL, one line per command)
  → transpile (mechanical; _review flags for LLM/human)
  → Replay Spec (YAML)
  → replay (locator fallback chain + assertions) → pass/fail + timing

Trust boundary. The CLI is the sole entry that launches and owns the browser (random debugging port, private profile). Whatever drives it — agent, script, human — can only act through these commands, so the Trace is complete by construction. Don't run another browser-driving tool in the same session, or you get holes in the Trace.

Local development

bun install
bun run typecheck              # tsc --noEmit
bun run cli help               # run the CLI from TypeScript (no build)
bun run mcp                    # run the MCP server from TypeScript (stdio)
bun run build                  # bundle to dist/*.mjs for shipping

Dev runs the TypeScript directly with bun; the MCP server auto-detects .ts (dev, spawns bun) vs bundled .mjs (prod, spawns node). Runtime output (traces, request stores, session state) lands under output/ (gitignored).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选