browser-gateway
Reliable, scalable browser infrastructure for AI agents. Route, pool, and failover across any browser provider. 8 built-in browser tools using raw Chrome CDP - navigate, screenshot, snapshot, interact, evaluate. Zero-config with auto Chrome detection & concurrent sessions support
README
browser-gateway
Reliable, scalable browser infrastructure for AI agents and automation.
Route, pool, and failover across any browser provider. Built-in MCP server for AI agents.
What It Does
┌─────────────────────┐
│ browser-gateway │
│ │
│ routing / failover │
│ load balancing │
│ health monitoring │
│ request queuing │
└──────────┬───────────┘
│
┌──────────────────┼──────────────────┐
│ │ │
┌──────┴──────┐ ┌──────┴──────┐ ┌───────┴──────┐
│ Provider A │ │ Provider B │ │ Provider C │
│ Cloud CDP │ │ Playwright │ │ Local Chrome │
│ priority: 1 │ │ Docker :4000│ │ Docker :9222 │
└─────────────┘ └─────────────┘ └──────────────┘
One endpoint. Multiple providers. Automatic failover if one goes down.
Your app connects to ws://gateway:9500/v1/connect. The gateway picks the best available provider based on health, capacity, and your routing strategy. Providers can be cloud CDP services, Docker containers, or local Chrome instances.
Core Features
Routing & Reliability
- Automatic Failover - Provider down? Next one picks up instantly. Zero client changes.
- 5 Load Balancing Strategies - Priority chain, round-robin, least-connections, latency-optimized, weighted
- Per-Provider Concurrency Limits - Set
maxConcurrentper provider, gateway enforces it - Request Queue - All providers busy? Connections wait instead of failing
- Cooldown System - Skip failing providers automatically, recover after TTL
- Health Checks - Periodic connectivity probes detect unhealthy providers
- Graceful Shutdown - Active sessions drain cleanly on SIGTERM/SIGINT
- Webhooks - Get notified when providers go down, recover, or queue overflows
MCP Server for AI Agents
- 8 Browser Tools - navigate, snapshot, screenshot, viewport, interact, evaluate, close, status
- Zero Config - Auto-detects Chrome, launches on first tool use
- Concurrent Sessions - Multiple agents get separate browsers, no conflicts
- Raw CDP - Lightweight, no Playwright or Puppeteer dependency
- Works with Claude Code, Cursor, and any MCP-compatible client
Management
- Web Dashboard - Manage providers, view sessions, edit config from the browser
- Provider CRUD - Add, edit, delete, and test providers from the dashboard or API
- Config Editor - Edit gateway.yml with syntax highlighting and validation
- Auth - Token-based with secure HttpOnly cookie for the dashboard
- Protocol Agnostic - Works with Playwright, Puppeteer, any WebSocket protocol
Quick Start
As a WebSocket Proxy (for applications)
npm install -g browser-gateway
Create gateway.yml:
version: 1
providers:
primary:
url: wss://provider.example.com?token=${PROVIDER_TOKEN}
limits:
maxConcurrent: 5
priority: 1
fallback:
url: ws://my-playwright-server:4000
limits:
maxConcurrent: 10
priority: 2
browser-gateway serve
Connect from your app:
// For CDP providers
const browser = await chromium.connectOverCDP('ws://localhost:9500/v1/connect');
// For Playwright run-server providers
const browser = await chromium.connect('ws://localhost:9500/v1/connect');
Dashboard at http://localhost:9500/web.
As an MCP Server (for AI agents)
Add to your Claude Code or Cursor config:
{
"mcpServers": {
"browser-gateway": {
"command": "npx",
"args": ["browser-gateway", "mcp"]
}
}
}
No config files needed. The agent can now browse websites, take screenshots, fill forms, and extract data.
See the MCP documentation for all options.
Dashboard
Built-in web dashboard at http://localhost:9500/web. Served from the same port as the gateway.
| Page | What You Can Do |
|---|---|
| Overview | Gateway health at a glance: active sessions, provider status, connection endpoint |
| Providers | Add, edit, delete, and test browser providers. Changes write to gateway.yml |
| Sessions | Live table of every active connection: provider, duration, message count |
| Config | Edit gateway.yml in the browser with validation and automatic backups |
If BG_TOKEN is set, the dashboard requires authentication via a secure HttpOnly cookie.
See Dashboard Guide for details.
Authentication
Set BG_TOKEN to require a token (or put it in a .env file):
BG_TOKEN=my-secret-token browser-gateway serve
- WebSocket clients pass the token as
?token=query param - API clients use
Authorization: Bearer <token>header - Dashboard shows a login form, sets a secure HttpOnly cookie
- Health endpoint (
/health) is always public
CLI
# Proxy server
browser-gateway serve # Start the gateway + dashboard
browser-gateway serve --port 8080 # Custom port
browser-gateway serve --config path.yml # Custom config
# MCP server for AI agents
browser-gateway mcp # Auto-detect Chrome, zero config
browser-gateway mcp --headless # Headless mode (for CI/Docker)
browser-gateway mcp --cdp-endpoint ws:// # Connect to existing browser
browser-gateway mcp --config gateway.yml # Multi-provider with failover
# Utilities
browser-gateway check # Test provider connectivity
browser-gateway version # Print version
browser-gateway help # Show help
API
| Endpoint | Method | Description |
|---|---|---|
/v1/connect |
WebSocket | Connect to a browser (the core feature) |
/v1/status |
GET | Gateway health + provider status |
/v1/sessions |
GET | Active sessions |
/v1/providers |
GET/POST | List or add providers |
/v1/providers/:id |
PUT/DELETE | Update or remove a provider |
/v1/providers/:id/test |
POST | Test provider connectivity |
/v1/config |
GET/PUT | Read or save config |
/v1/config/validate |
POST | Validate YAML without saving |
/mcp |
POST | MCP Streamable HTTP endpoint |
/json/version |
GET | CDP discovery (for browser-use, Playwright, Stagehand) |
/health |
GET | Health check |
Docker
docker run -d \
-p 9500:9500 \
-v ./gateway.yml:/app/gateway.yml:ro \
-e PROVIDER_TOKEN=xxx \
ghcr.io/browser-gateway/server:latest
How It Works
- Client connects to
ws://gateway:9500/v1/connect - Gateway selects a provider using your routing strategy
- Gateway opens a raw TCP connection to the provider
- HTTP upgrade forwarded, provider responds with
101 Switching Protocols - Bidirectional TCP pipe:
client <-> gateway <-> provider - All WebSocket messages forwarded transparently (never parsed or modified)
- On disconnect: session cleaned up, slot released, metrics updated
- If all providers full: connection waits in a queue until a slot opens
Works With
browser-gateway is compatible with existing browser tools. Just pass the gateway URL — it auto-resolves via /json/version.
AI Agent Frameworks:
# browser-use (Python) — HTTP URL auto-resolves
BrowserSession(cdp_url="http://localhost:9500")
// Stagehand (TypeScript)
new Stagehand({ env: "LOCAL", localBrowserLaunchOptions: { cdpUrl: "http://localhost:9500" } })
Playwright MCP (all 70 Playwright tools through gateway routing):
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--cdp-endpoint", "http://localhost:9500"]
}
}
}
Puppeteer / Playwright:
// Playwright — HTTP or WebSocket
const browser = await chromium.connectOverCDP("http://localhost:9500");
// Puppeteer — WebSocket
const browser = await puppeteer.connect({ browserWSEndpoint: "ws://localhost:9500/v1/connect" });
Documentation
- MCP Server for AI Agents - Setup, tools, options
- Integrations - Playwright, Puppeteer, browser-use, Stagehand, Playwright MCP
- Getting Started
- Configuration Reference
- How Failover Works
- Load Balancing Strategies
- Request Queue
- Webhooks
- Web Dashboard
- Supported Providers
- Session Lifecycle
- CLI Reference
- Docker Deployment
Contributing
Contributions welcome. See CONTRIBUTING.md for guidelines.
License
MIT - see LICENSE.
Links
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。