Configuration Overview
The Browserbase MCP server supports extensive configuration options through command-line flags and environment variables. Configure browser behavior, proxy settings, stealth modes, model selection, and more to customize your browser automation workflows.Command-line flags are only available when running the server locally (
npx @browserbasehq/mcp-server-browserbase
with flags or local development setup).Environment Variables
Configure the essential Browserbase credentials and optional debugging settings:BROWSERBASE_API_KEY
Your Browserbase API key for authentication
BROWSERBASE_PROJECT_ID
Your Browserbase project ID
Command-Line Flags
Available Flags
Flag | Description |
---|---|
--proxies | Enable Browserbase proxies for the session |
--advancedStealth | Enable Browserbase Advanced Stealth (Scale Plan only) |
--keepAlive | Enable Browserbase Keep Alive Session |
--contextId <contextId> | Specify a Browserbase Context ID to use |
--persist [boolean] | Whether to persist the Browserbase context (default: true) |
--port <port> | Port to listen on for HTTP/SHTTP transport |
--host <host> | Host to bind server to (default: localhost, use 0.0.0.0 for all interfaces) |
--cookies [json] | JSON array of cookies to inject into the browser |
--browserWidth <width> | Browser viewport width (default: 1024) |
--browserHeight <height> | Browser viewport height (default: 768) |
--modelName <model> | The model to use for Stagehand (default: gemini-2.0-flash) |
--modelApiKey <key> | API key for the custom model provider (required when using custom models) |
--experimental | Enable experimental features (default: false) |
Configuration Examples
Basic Configuration
Advanced Features
Enable Browserbase proxies for IP rotation and geo-location testing.
Browser Customization
Customize browser window dimensions. Default is 1024x768. Recommended aspect ratios: 16:9.Common Resolutions:
- Desktop: 1920x1080, 1280x720, 1024x768
- Mobile: 375x667 (iPhone), 360x640 (Android)
- Tablet: 768x1024 (iPad)
Model Configuration
Configure AI models for enhanced browser automation. Stagehand defaults to Google’s Gemini 2.0 Flash but supports multiple providers.When using any custom model (non-default), you must provide your own API key for that model provider using the
--modelApiKey
flag.Google Gemini (Default)
google/gemini-2.0-flash
(default)google/gemini-1.5-pro
google/gemini-1.5-flash
openai/gpt-4o
openai/gpt-4o-mini
openai/o1-mini
openai/o1-preview
openai/o3-mini
anthropic/claude-3-5-sonnet-latest
anthropic/claude-3-7-sonnet-latest
Development Configuration
Enable detailed logging for troubleshooting and development.
Best Practices
Performance - How can I optimize browser automation performance?
Performance - How can I optimize browser automation performance?
- Use appropriate viewport sizes for your use case
- Enable proxies only when needed for geo-location
- Choose efficient models (Gemini Flash for speed, GPT-4o for accuracy)
- Reuse contexts for authentication persistence
Security - What security measures should I implement?
Security - What security measures should I implement?
- Store API keys securely in environment variables
- Use Advanced Stealth for sensitive operations
- Implement proper session management
- Rotate cookies and contexts regularly
Development - What are the recommended development practices?
Development - What are the recommended development practices?
- Enable debug mode during development
- Use context persistence for faster iteration
- Test with different viewport sizes
- Monitor session usage and quotas
Production - How should I configure for production environments?
Production - How should I configure for production environments?
- Use NPM installation for reliability
- Configure appropriate timeouts
- Implement error handling and retries
- Monitor performance and resource usage