BAP MCP
Lightweight browser automation server for AI agents, enabling fast (10-25ms per action), structured observations and semantic selectors with zero token overhead.
README
Browser Agent Protocol (BAP)
The execution layer for browser agents. 10-25ms per action, zero token overhead, structured observations your LLM can actually use.
BAP sits between your AI agent and the browser. The agent decides what to do, BAP does it — instantly, reliably, with semantic selectors and session persistence.
<p align="center"> <img src="./assets/demos/blog-reader.gif" alt="BAP navigating a website, clicking through pages, and scrolling through a blog post" width="960" /> </p>
<p align="center"> <a href="https://www.npmjs.com/package/@browseragentprotocol/cli"><strong>CLI</strong></a> · <a href="https://www.npmjs.com/package/@browseragentprotocol/mcp"><strong>MCP</strong></a> · <a href="https://pypi.org/project/browser-agent-protocol/"><strong>Python</strong></a> · <a href="./packages/cli/README.md"><strong>Docs</strong></a> · <a href="./LICENSE"><strong>Apache-2.0</strong></a> </p>
Why BAP
Every browser action in your agent pipeline has a cost — latency, tokens, and dollars.
per action per 20-action task 1000 tasks/day
Stagehand 800ms, $0.01 $0.20 $200
Browser Use 1500ms, $0.02 $0.40 $400
BAP (in-process) 20ms, $0.00 $0.00 $0
Stagehand and Browser Use send every click and fill through an LLM. BAP doesn't — your agent's LLM decides the action, BAP executes it directly via Playwright. The LLM call happens once (in your agent), not per-action (in the browser layer).
BAP is for teams that want to control the intelligence. You bring the LLM, BAP brings the browser.
What BAP gives your agent
| Without BAP | With BAP | |
|---|---|---|
| What the LLM sees | Raw HTML (10,000+ tokens) | @submit button: "Submit", @email textbox: "Email" (50 tokens) |
| Latency per action | 800-1500ms (LLM in the loop) | 10-25ms (direct execution) |
| Session state | Lost between turns | Persisted — browser stays warm |
| When selectors break | Agent fails | Self-healing via uSEID fallback |
| Reproducibility | Non-deterministic | DBAR deterministic replay |
Get Started
npm i -g @browseragentprotocol/cli
bap install-skill
Or run bap demo for a guided walkthrough.
Then give your agent a task:
Use BAP to open https://example.com, find the pricing page, and extract the plan names and prices.
Quick Example
# Navigate and observe — one fused call
bap goto https://example.com --observe
# Agent sees structured output:
# @navPricing link: "Pricing"
# @heroSignup button: "Get Started"
# @searchInput textbox: "Search..."
# Agent decides to click pricing — BAP executes in 15ms
bap act click:@navPricing --observe
# Extract structured data
bap extract --fields="plan,price,features"
How it works
Your LLM Agent ← decides what to do (planning, reasoning)
↓
BAP (MCP or CLI) ← executes it (10-25ms, structured observations)
↓
Playwright ← handles the browser (auto-wait, smart inputs)
↓
Chrome/Firefox/WebKit ← renders the page
BAP is a thin protocol layer over Playwright. It adds:
- Structured observations — interactive elements with refs, roles, and action hints instead of raw HTML
- Semantic selectors —
role:button:"Submit",text:"Sign in",@refinstead of brittle CSS - Fused operations —
goto --observesaves a roundtrip,act --observechains action + observation - Session persistence — browser stays alive across agent turns, no re-launching
- Self-healing selectors (uSEID) — when elements change between page loads, BAP falls back to semantic identity matching
- Deterministic replay (DBAR) — record a browser session, replay it identically for testing and CI
Interfaces
| Interface | Install | Best for |
|---|---|---|
| MCP (in-process) | npx @browseragentprotocol/mcp --in-process |
Fastest — 10-25ms/action, zero WebSocket overhead |
| MCP (standalone) | npx @browseragentprotocol/mcp |
Standard MCP clients (Claude, Cursor, Codex) |
| CLI + SKILL.md | npm i -g @browseragentprotocol/cli |
Coding agents with shell access |
| TypeScript SDK | npm i @browseragentprotocol/client |
Apps and agent backends |
| Python SDK | pip install browser-agent-protocol |
Python agents and notebooks |
Benchmark
Measured on real websites (Wikipedia, Hacker News) — browserbench:
Action CDP-raw Playwright BAP MCP BAP CLI PW CLI
─────────────────────────────────────────────────────────────────────
navigate 68ms 593ms 26ms 1490ms 590ms
observe 14ms 7ms 8ms 145ms 591ms
fill 1ms 18ms 13ms 148ms 588ms
extract 0ms 8ms 5ms 164ms 604ms
─────────────────────────────────────────────────────────────────────
tokens/call 0 0 35 155 0
pass rate 100% 100% 100% 100% 100%
BAP MCP (in-process) is within 2x of raw CDP and matches Playwright's direct API — while giving your agent structured observations, semantic selectors, and session persistence.
When to use what
| Use case | Recommendation |
|---|---|
| Known workflows on known sites (scraping, testing, data entry) | BAP MCP or Playwright — you know the selectors, AI per-action adds no value |
| Agent on unfamiliar sites (find pricing, navigate docs) | BAP for execution + your LLM for planning. Structured observations make the LLM cheaper and more accurate |
| Don't want to build the planning layer | Stagehand — bundles LLM + execution, but 40x slower and $200+/day at scale |
| Complex multi-step goals | Browser Use — highest abstraction, highest cost |
| Scale (100+ concurrent browsers) | Browserbase for infrastructure + BAP for the automation layer |
See It in Action
<p align="center"> <img src="./assets/demos/workflow.gif" alt="BAP navigating a bookstore, clicking Travel category, and viewing book details" width="960" /> <br/> <em>Navigate → click → browse: 3 commands, one workflow</em> </p>
<p align="center"> <img src="./assets/demos/skill-scorer.gif" alt="BAP browsing GitHub to find a SKILL.md, then scoring it on skills.menu" width="960" /> <br/> <em>Multi-site workflow: browse GitHub → open skills.menu → paste & score</em> </p>
Tips
- BAP defaults to headful Chrome with a persistent session.
- Use
--headlessfor CI or background runs. - Use
--no-profileif your Chrome profile is busy. - Use
--slimmode to cut tool definitions to ~600 tokens (vs ~4,200 for Playwright MCP). - Use
bap close-allto stop the daemon and all sessions.
Docs
Contributing
License
Apache-2.0. See LICENSE for details.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。