Browserbase MCP server

Automate web browsers remotely on a cloud environment.
Back to servers
Setup instructions
Provider
Browserbase
Release date
Dec 05, 2024
Language
TypeScript
Stats
2.1K stars

The Browserbase MCP Server integrates with the Model Context Protocol (MCP) to provide cloud browser automation capabilities. It allows Large Language Models (LLMs) to interact with web pages, take screenshots, and execute JavaScript in a cloud browser environment using Browserbase and Stagehand technologies.

Installation

You can install the Browserbase MCP server in two ways:

Using Smithery

The simplest way to install is through Smithery:

# Visit the Smithery page to install
https://smithery.ai/server/@browserbasehq/mcp-browserbase

Manual Installation

To install and run the server locally:

  1. Clone the repository:

    git clone https://github.com/browserbasehq/mcp-browserbase.git
    cd mcp-browserbase
    
  2. Install dependencies:

    npm install
    
  3. Start the server:

    npm start
    

Usage

The Browserbase MCP Server provides two main components that you can use:

Browserbase MCP

Browserbase MCP offers a comprehensive set of browser automation features:

  • Browser Automation: Control and orchestrate cloud browsers
  • Data Extraction: Extract structured data from webpages
  • Console Monitoring: Track and analyze browser console logs
  • Screenshots: Capture full-page and element screenshots
  • Web Interaction: Navigate, click, and fill forms

Stagehand MCP

Stagehand MCP provides a higher-level abstraction with natural language commands:

  • Atomic Instructions: Execute precise actions using natural language

    act("click the login button")
    extract("find the red shoes")
    
  • Model Support: Works with multiple models including OpenAI's GPT-4 and Anthropic's Claude-3.7 Sonnet

  • Vision Support: Uses annotated screenshots for better interpretation of complex DOMs

Configuration

To configure the MCP server, you'll need to set up appropriate environment variables:

# Browserbase API credentials
BROWSERBASE_API_KEY=your_api_key

# Optional: Set custom port
MCP_SERVER_PORT=3000

API Examples

Browser Navigation

// Example of navigating to a webpage
await mcp.browserbase.navigate("https://example.com");

// Take a screenshot
const screenshot = await mcp.browserbase.screenshot();

// Extract data from a page
const data = await mcp.browserbase.extract({
  selector: ".product-list",
  attributes: ["title", "price"]
});

Using Stagehand

// Using natural language commands
await mcp.stagehand.act("click the sign-up button");
await mcp.stagehand.act("fill the email field with [email protected]");
await mcp.stagehand.extract("get all product prices from this page");

Troubleshooting

If you encounter issues with the MCP server:

  • Verify your API credentials are correct
  • Check network connectivity to Browserbase services
  • Ensure you have the latest version of the server

For additional support, consult the API documentation or reach out to the Stagehand community.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "browserbase" '{"command":"npx","args":["-y","@browserbasehq/mcp-browserbase"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "browserbase": {
            "command": "npx",
            "args": [
                "-y",
                "@browserbasehq/mcp-browserbase"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "browserbase": {
            "command": "npx",
            "args": [
                "-y",
                "@browserbasehq/mcp-browserbase"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later