Runtime modes
LAUNCH=true: launch a managed Chromium instance through PlaywrightLAUNCH=false: connect to an existing browser throughCDP_URL
Environment variables
Browser configuration
| Variable | Default | Description |
|---|---|---|
CDP_URL | http://localhost:9222 | CDP endpoint when not launching locally |
LAUNCH | false | Whether to launch a browser (true) or connect (false) |
BROWSER_WIDTH | 1280 | Browser viewport width |
BROWSER_HEIGHT | 720 | Browser viewport height |
PORT | unset | Enables HTTP mode when provided |
HOST | localhost | Bind address for HTTP mode |
Authentication
| Variable | Default | Description |
|---|---|---|
API_KEY | unset | API key for HTTP endpoint authentication (optional) |
CLI flags
| Flag | Env equivalent |
|---|---|
--port <n> | PORT |
--host <host> | HOST |
--cdp-url <url> | CDP_URL |
--launch | LAUNCH=true |
--browser-width <n> | BROWSER_WIDTH |
--browser-height <n> | BROWSER_HEIGHT |
Example .env
Authentication (HTTP mode)
When running in HTTP mode, you can optionally enable API key authentication.Enable API key authentication
Provide the API key
Clients can authenticate using either method: HTTP Header (recommended):Authentication behavior
- The
initializerequest (MCP session establishment) is exempt from authentication when no session exists - All subsequent requests require a valid API key
- Constant-time comparison prevents timing attacks
- Response:
401 Unauthorizedfor invalid or missing keys
Operational notes
- In containerized setups,
HOST=0.0.0.0is usually required - Keep
LAUNCH=truefor self-contained Docker operation - Keep
LAUNCH=falsewhen you already run hardened browser infrastructure - Set
API_KEYin production environments for security
AI / Agent configuration
BrowserAgent supports optional LLM providers for autonomous workflows.| Variable / Flag | Default | Description |
|---|---|---|
OPENAI_API_KEY | unset | OpenAI API key |
ANTHROPIC_API_KEY | unset | Anthropic API key |
--ai-provider | openai | Select openai or anthropic |
--ai-model | gpt-4o | Model name |
--ai-base-url | provider default | Custom API endpoint |
--ai-api-key | from env | API key override |
--max-steps | 30 | Safety limit per task |
Security considerations
- Keep
API_KEYout of source control - Use environment variables or CI secrets
- Enable TLS in production for HTTP mode
- Restrict network access with firewalls
- Use strong, randomly generated API keys