BR

Browserbase MCP Server with Stagehand for LLM Automation

Automate web interactions with the Browserbase MCP server using Stagehand to let LLMs browse pages, extract data, and perform automated actions.

Quick Install
npx -y @browserbase/mcp-server-browserbase

Overview

Browserbase MCP Server is a self-hostable implementation of a Model Context Protocol (MCP) server that connects large language models to a cloud browser automation stack. It combines Browserbase (cloud browser sessions) with Stagehand (LLM-driven browser automation) so LLMs can open pages, click and type, observe actionable elements, and extract structured data from websites. The server follows the MCP spec, exposing a small set of tools LLMs can call as part of a broader AI application.

There are two deployment modes: use Browserbase’s hosted MCP endpoint for the fastest setup, or run the server locally (STDIO/SHTTP) to keep everything on-premises. The hosted SHTTP option includes managed LLM access (Stagehand models) and is recommended for rapid adoption; the local server is useful for integration testing, custom models, or air-gapped environments.

Features

  • Exposes MCP-compatible tools to control cloud browser sessions from LLMs
  • Integrates Browserbase cloud browsers with Stagehand LLM automation
  • Supports two transport modes: SHTTP (remote HTTP MCP) and STDIO (local MCP)
  • Start/end browser sessions, navigate, perform actions, observe elements, and extract data
  • Configurable viewport, persistence, proxy/stealth options, and Stagehand model selection
  • Works with Puppeteer/Playwright-backed browser instances via Browserbase

Installation / Configuration

Two recommended approaches: use the hosted MCP server (SHTTP) or run the server locally (STDIO). Set the following environment variables when running the server (or provide via your process manager):

  • BROWSERBASE_API_KEY — your Browserbase API key
  • BROWSERBASE_PROJECT_ID — Browserbase project id
  • GEMINI_API_KEY (optional) — API key for Google Gemini if using that model

SHTTP (Hosted, easiest)

  • Add the hosted MCP endpoint to your MCP client config to point at Browserbase’s managed server.

Example client config (SHTTP):

{
  "mcpServers": {
    "browserbase": {
      "type": "http",
      "url": "https://mcp.browserbase.com/mcp"
    }
  }
}

If your client cannot use SHTTP directly, a bridge invocation via npx is possible:

{
  "mcpServers": {
    "browserbase": {
      "command": "npx",
      "args": ["mcp-remote", "https://mcp.browserbase.com/mcp"]
    }
  }
}

STDIO (Self-hosted)

  • Install from npm or clone this repository and run locally or in Docker.

Run via npx (recommended for local use):

{
  "mcpServers": {
    "browserbase": {
      "command": "npx",
      "args": ["@browserbasehq/mcp"],
      "env": {
        "BROWSERBASE_API_KEY": "",
        "BROWSERBASE_PROJECT_ID": "",
        "GEMINI_API_KEY": ""
      }
    }
  }
}

Run from source:

git clone https://github.com/browserbase/mcp-server-browserbase.git
cd mcp-server-browserbase
npm install
npm run build
node cli.js

Run in Docker:

# build image
docker build -t mcp-browserbase .
# example docker run in MCP client config
{
  "mcpServers": {
    "browserbase": {
      "command": "docker",
      "args": ["run","--rm","-i","-e","BROWSERBASE_API_KEY","-e","BROWSERBASE_PROJECT_ID","-e","GEMINI_API_KEY","mcp-browserbase"]
    }
  }
}

Available Tools

This MCP server exposes six primary tools LLMs can call. Each tool expects JSON input as shown.

ToolPurposeInput (JSON)
startCreate or reuse a Browserbase session{}
endClose the current Browserbase session{}
navigateNavigate the browser to a URL{ “url”: “https://…” }
actPerform an action on the page (click/type){ “action”: “click #id” }
observeFind actionable elements / summarize{ “instruction”: “…” }
extractExtract structured data from the page{ “instruction”: “optional” }

Stagehand is used under the hood to interpret freeform instructions (act/observe/extract) into concrete browser operations.

Configuration Flags

Common runtime flags accepted by the server:

Pass flags via the args array in your MCP client config or as CLI parameters when launching the server.

Use Cases

  • Data extraction / web scraping: Ask an LLM to open a product page, extract price, name, and availability into JSON using extract.
  • Form automation: Instruct the LLM to fill and submit multi-step forms (login, checkout) with act and navigate calls.
  • Research assistants: Have an LLM browse a sequence of pages, summarize findings with observe, and return citations.
  • End-to-end testing: Automate UI flows via Stagehand scripts driven by LLM-generated instructions and validate visible outcomes.
  • Augment chatbots: Integrate live web data into a chat agent by letting the model fetch and parse pages on demand.
  • Repository: https://github.com/browserbase/mcp-server-browserbase
  • Model Context Protocol: https://modelcontextprotocol.io/introduction
  • Browserbase docs and Stagehand examples are helpful when authoring extraction/observation instructions.

This server is geared toward developers building LLM integrations that need reliable, programmable browser context and a compact set of MCP tools to orchestrate browsing tasks.

FlagDescription
–proxiesEnable Browserbase proxy routing
–advancedStealthTurn on advanced stealth (plan-dependent)
–keepAliveKeep Browserbase context alive between calls
–contextId Use a specific Browserbase context ID
–persistPersist context across sessions (default true)
–port Port to bind for SHTTP (if running HTTP)
–host Host to bind (default localhost; 0.0.0.0 for all)
–browserWidth Viewport width (default 1024)
–browserHeight Viewport height (default 768)
–modelName Stagehand model to use (defaults to a Gemini model)
–modelApiKey API key for the chosen LLM model