Browserbase (Browser Automation) MCP server

Provides browser automation through dual servers: Browserbase for direct browser control and Stagehand for natural language-driven workflows, enabling navigation, data extraction, and complex multi-step actions
Back to servers
Setup instructions
Provider
Browserbase
Release date
Mar 25, 2025
Language
TypeScript

This MCP server allows your LLM applications to interact with web browsers programmatically through the Model Context Protocol (MCP). It provides capabilities for web automation, data extraction, and browser interaction through Browserbase and Puppeteer, enabling AI models to navigate websites, capture screenshots, and execute JavaScript.

Installation

Prerequisites

  • Node.js installed on your system
  • A Browserbase account (for API access)

Basic Installation

To set up the MCP server on your local machine:

# Clone the repository
git clone https://github.com/browserbase/mcp-server.git

# Navigate to the project directory
cd mcp-server

# Install dependencies
npm install

Configuration

Create a configuration file with your Browserbase credentials:

# Create a .env file in the project root
touch .env

# Add your Browserbase API key to the .env file
echo "BROWSERBASE_API_KEY=your_api_key_here" >> .env

Usage

Starting the Server

To start the MCP server locally:

npm start

The server will start on the default port (typically 3000).

Using the Browserbase MCP

Basic Web Navigation

Connect your LLM application to the MCP server to navigate web pages:

// Example client code
const response = await fetch('http://localhost:3000/v1/browserbase/navigate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://example.com'
  })
});

Taking Screenshots

Capture screenshots of web pages:

const screenshotResponse = await fetch('http://localhost:3000/v1/browserbase/screenshot', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    selector: 'body' // Optional: specify an element, defaults to full page
  })
});

Extracting Data

Extract data from web pages:

const dataResponse = await fetch('http://localhost:3000/v1/browserbase/extract', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    selector: '.product-items',
    attributes: ['textContent', 'href']
  })
});

Executing JavaScript

Run custom JavaScript in the browser context:

const jsResponse = await fetch('http://localhost:3000/v1/browserbase/execute', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    script: 'return document.title;'
  })
});

Working with Stagehand

Stagehand provides more advanced, natural language-based browser interactions:

const stagehandResponse = await fetch('http://localhost:3000/v1/stagehand/act', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    instruction: "click the login button",
    modelProvider: "openai" // Options: "openai", "anthropic", etc.
  })
});

Integration with LLM Applications

To integrate the MCP server with your LLM application:

  1. Connect your application to the MCP server endpoint
  2. Send requests with the appropriate parameters
  3. Process the responses in your application

Example integration in a Node.js application:

const axios = require('axios');

async function browseWithLLM(url, query) {
  // Navigate to the URL
  await axios.post('http://localhost:3000/v1/browserbase/navigate', {
    url: url
  });
  
  // Extract content based on LLM query
  const content = await axios.post('http://localhost:3000/v1/stagehand/extract', {
    instruction: query,
    modelProvider: "openai"
  });
  
  return content.data;
}

Troubleshooting

Common Issues

  • Connection errors: Ensure the server is running and accessible
  • Authentication failures: Verify your Browserbase API key is correct
  • Timeout errors: Consider adjusting timeout settings for complex operations

Debugging

Enable debug mode for more detailed logs:

DEBUG=mcp:* npm start

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-server-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-server-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-server-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