ccowan190/browserbase-mcp-oauth2
If you are the rightful owner of browserbase-mcp-oauth2 and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Browserbase MCP Server with OAuth2 Authentication is a robust server designed for browser automation, featuring seamless integration with Claude.ai through OAuth2 authentication.
Page Navigation
Navigate to URLs, go back/forward
Element Interaction
Click, type, hover on elements
Form Handling
Fill forms, submit data
Screenshot Capture
Take full page or element screenshots
Content Extraction
Get text, HTML, or structured data
Browserbase MCP Server with OAuth2 Authentication
A powerful browser automation MCP (Model Context Protocol) server built on Browserbase with OAuth2 authentication support for seamless Claude.ai integration.
๐ Features
- Browser Automation: Full Playwright browser automation capabilities
- OAuth2 Authentication: Google OAuth2 integration for Claude.ai
- Dual Authentication: OAuth2 with Cloud Run IAM fallback
- HundredX Integration: Domain validation for @hundredxinc.com accounts
- Claude.ai Ready: Direct integration with Claude.ai remote MCP servers
- Browserbase Cloud: Serverless browser automation via Browserbase
- Session Management: Secure session handling with token expiration
๐๏ธ Architecture
Claude.ai โ OAuth2 Flow โ Browserbase MCP Server โ Browserbase Cloud โ Browser Automation
โ
Google Authentication
โ
HundredX Domain Validation
๐ฆ Installation
Prerequisites
- Node.js 18+
- Browserbase account and API key
- Docker (for deployment)
- Google Cloud SDK (
gcloud
)
Quick Start
-
Clone the repository:
git clone https://github.com/ccowan190/browserbase-mcp-oauth2.git cd browserbase-mcp-oauth2
-
Install dependencies:
npm install && npm run build
-
Configure environment variables:
export BROWSERBASE_API_KEY="your-browserbase-api-key" export BROWSERBASE_PROJECT_ID="your-browserbase-project-id" export OAUTH2_CLIENT_ID="your-google-client-id" export OAUTH2_CLIENT_SECRET="your-google-client-secret"
-
Deploy to Google Cloud Run:
./deploy-browserbase-oauth2.sh
๐ง Configuration
Environment Variables
Variable | Description | Required |
---|---|---|
BROWSERBASE_API_KEY | Browserbase API key | Yes |
BROWSERBASE_PROJECT_ID | Browserbase project ID | Yes |
OAUTH2_CLIENT_ID | Google OAuth2 Client ID | Optional* |
OAUTH2_CLIENT_SECRET | Google OAuth2 Client Secret | Optional* |
OAUTH2_REDIRECT_URL | OAuth2 callback URL | Optional |
*If not provided, server falls back to Cloud Run IAM authentication
Browserbase Setup
- Create Browserbase Account: Sign up at browserbase.com
- Get API Credentials:
- API Key from your dashboard
- Project ID from your project settings
OAuth2 Setup
- Create OAuth2 Credentials in Google Cloud Console:
- Application type: Web application
- Name: Browserbase MCP Server for Claude.ai
- Authorized origins:
https://claude.ai
,https://api.anthropic.com
- Redirect URIs:
https://claude.ai/oauth/callback
,https://api.anthropic.com/oauth/callback
๐ Browser Automation Capabilities
Available Tools
- Page Navigation: Navigate to URLs, go back/forward
- Element Interaction: Click, type, hover on elements
- Form Handling: Fill forms, submit data
- Screenshot Capture: Take full page or element screenshots
- Content Extraction: Get text, HTML, or structured data
- Wait Operations: Wait for elements, network, or timeouts
- JavaScript Execution: Run custom JavaScript in browser context
Example Usage
// Navigate to a website
await browserbase.navigate('https://example.com');
// Take a screenshot
const screenshot = await browserbase.screenshot();
// Click an element
await browserbase.click('button[type="submit"]');
// Extract text content
const text = await browserbase.getText('.content');
๐ API Endpoints
Health Check
GET /health
Response:
{
"status": "ok",
"service": "browserbase-mcp-server",
"auth": "oauth2|iam",
"browserbase": "connected"
}
Authentication Status
GET /auth/status
Response:
{
"auth_type": "oauth2|iam",
"auth_enabled": true,
"login_url": "/oauth/login"
}
OAuth2 Authentication (when enabled)
GET /oauth/login # Initiates OAuth2 flow
GET /oauth/callback # Handles OAuth2 callback
MCP Protocol
POST /mcp # Browser automation operations (requires auth)
๐ Claude.ai Integration
Option 1: OAuth2 Authentication (Recommended)
- Deploy with OAuth2 credentials configured
- In Claude.ai integration settings:
- Service URL:
https://your-service-url/mcp
- OAuth Client ID: Your Google OAuth2 Client ID
- Service URL:
Option 2: NPM Package (Local Development)
{
"mcpServers": {
"browserbase": {
"command": "npx",
"args": ["@browserbasehq/mcp"],
"env": {
"BROWSERBASE_API_KEY": "your-api-key",
"BROWSERBASE_PROJECT_ID": "your-project-id"
}
}
}
}
Option 3: Proxy Method (Development)
# Start authenticated proxy
gcloud run services proxy browserbase-mcp-server --region=us-central1 --project=your-project --port=8080
# Configure Claude Desktop
# URL: http://localhost:8080/mcp
๐งช Testing
Run the comprehensive test suite:
./test-browserbase-oauth2.sh
Tests include:
- Health check endpoint
- Authentication status
- MCP endpoint protection
- OAuth2 flow (when enabled)
- Browser automation functionality
๐ก๏ธ Security Features
- Domain Validation: Only @hundredxinc.com email addresses allowed
- Token Expiration: Session tokens expire after 1 hour
- Secure Sessions: Browser sessions isolated per user
- HTTPS Only: All OAuth2 flows use secure connections
- IAM Fallback: Cloud Run IAM security when OAuth2 not configured
๐ Project Structure
โโโ src/
โ โโโ oauth2/ # OAuth2 authentication
โ โ โโโ oauth2.ts # OAuth2 handler implementation
โ โ โโโ index.ts # OAuth2 exports
โ โโโ tools/ # Browser automation tools
โ โโโ server.ts # Main MCP server
โ โโโ sessionManager.ts # Session management
โ โโโ transport.ts # HTTP transport with OAuth2
โโโ deploy-browserbase-oauth2.sh # Deployment script
โโโ test-browserbase-oauth2.sh # Testing script
โโโ Dockerfile # Container configuration
โโโ README.md # This file
๐ Deployment
Google Cloud Run
# Build and deploy
./deploy-browserbase-oauth2.sh
# Or manually:
docker build -t gcr.io/your-project/browserbase-mcp:oauth2 .
docker push gcr.io/your-project/browserbase-mcp:oauth2
gcloud run deploy browserbase-mcp-server \
--image=gcr.io/your-project/browserbase-mcp:oauth2 \
--set-env-vars="OAUTH2_CLIENT_ID=your-id,OAUTH2_CLIENT_SECRET=your-secret,BROWSERBASE_API_KEY=your-key"
Local Development
# Run locally with OAuth2
npm run build
BROWSERBASE_API_KEY=your-key \
OAUTH2_CLIENT_ID=your-id \
OAUTH2_CLIENT_SECRET=your-secret \
node cli.js
๐ Authentication Modes
OAuth2 Mode
- Enabled: When
OAUTH2_CLIENT_ID
andOAUTH2_CLIENT_SECRET
are set - Flow: Google OAuth2 โ Domain validation โ Session token
- Claude.ai: Direct integration with OAuth Client ID
IAM Mode (Fallback)
- Enabled: When OAuth2 credentials are not configured
- Flow: Google Cloud IAM authentication
- Claude.ai: Requires proxy or service account
๐ Monitoring
Monitor your deployment:
# Check health
curl https://your-service-url/health
# Check auth status
curl https://your-service-url/auth/status
# View logs
gcloud run services logs read browserbase-mcp-server --region=us-central1
๐ฏ Use Cases
- Web Scraping: Extract data from dynamic websites
- Form Automation: Fill and submit forms automatically
- Testing: Automated UI testing and validation
- Screenshots: Capture website screenshots for documentation
- Data Collection: Gather information from multiple sources
- Monitoring: Website uptime and content monitoring
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ License
This project is based on Browserbase's MCP server with OAuth2 enhancements.
๐ Support
- Issues: GitHub Issues
- Browserbase Docs: browserbase.com/docs
- MCP Protocol: modelcontextprotocol.io
๐ฏ Roadmap
- JWT token signing for enhanced security
- Multiple OAuth2 provider support
- Advanced session management
- Browser session recording
- Custom browser configurations
- Parallel browser operations
Built with โค๏ธ for browser automation and Claude.ai integration.