browser-gateway
Allows the gateway to route and manage browser sessions hosted in Docker containers, providing a scalable infrastructure for browser automation with health monitoring and failover.
Provides a compatible WebSocket gateway for Puppeteer, allowing AI agents to connect to and control browser instances via a centralized proxy with load balancing.
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.
Related MCP server: Playwright MCP
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 itRequest 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-gatewayCreate 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: 2browser-gateway serveConnect 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 serveWebSocket clients pass the token as
?token=query paramAPI clients use
Authorization: Bearer <token>headerDashboard 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 helpAPI
Endpoint | Method | Description |
| WebSocket | Connect to a browser (the core feature) |
| GET | Gateway health + provider status |
| GET | Active sessions |
| GET/POST | List or add providers |
| PUT/DELETE | Update or remove a provider |
| POST | Test provider connectivity |
| GET/PUT | Read or save config |
| POST | Validate YAML without saving |
| POST | MCP Streamable HTTP endpoint |
| 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:latestHow It Works
Client connects to
ws://gateway:9500/v1/connectGateway selects a provider using your routing strategy
Gateway opens a raw TCP connection to the provider
HTTP upgrade forwarded, provider responds with
101 Switching ProtocolsBidirectional TCP pipe:
client <-> gateway <-> providerAll 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. Use it as the infrastructure layer underneath:
AI Agent Frameworks:
# browser-use (Python)
BrowserSession(cdp_url="ws://localhost:9500/v1/connect")// Stagehand (TypeScript)
new Stagehand({ env: "LOCAL", localBrowserLaunchOptions: { cdpUrl: "ws://localhost:9500/v1/connect" } })Playwright MCP (get all 70 Playwright tools with gateway routing):
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--cdp-endpoint", "ws://localhost:9500/v1/connect"]
}
}
}Puppeteer / Playwright:
// Puppeteer
const browser = await puppeteer.connect({ browserWSEndpoint: "ws://localhost:9500/v1/connect" });
// Playwright
const browser = await chromium.connectOverCDP("ws://localhost:9500/v1/connect");Documentation
MCP Server for AI Agents - Setup, tools, options, Playwright MCP integration
Contributing
Contributions welcome. See CONTRIBUTING.md for guidelines.
License
MIT - see LICENSE.
Links
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/browser-gateway/browser-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server