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.
npx -y @browserbase/mcp-server-browserbaseOverview
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):
If your client cannot use SHTTP directly, a bridge invocation via npx is possible:
STDIO (Self-hosted)
- Install from npm or clone this repository and run locally or in Docker.
Run via npx (recommended for local use):
Run from source:
Run in Docker:
# build image
# example docker run in MCP client config
{
}
Available Tools
This MCP server exposes six primary tools LLMs can call. Each tool expects JSON input as shown.
| Tool | Purpose | Input (JSON) |
|---|---|---|
| start | Create or reuse a Browserbase session | {} |
| end | Close the current Browserbase session | {} |
| navigate | Navigate the browser to a URL | { “url”: “https://…” } |
| act | Perform an action on the page (click/type) | { “action”: “click #id” } |
| observe | Find actionable elements / summarize | { “instruction”: “…” } |
| extract | Extract 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:
| Flag | Description | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| –proxies | Enable Browserbase proxy routing | ||||||||||||||
| –advancedStealth | Turn on advanced stealth (plan-dependent) | ||||||||||||||
| –keepAlive | Keep Browserbase context alive between calls | ||||||||||||||
–contextId | Use a specific Browserbase context ID | –persist | Persist 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 | Pass flags via the args array in your MCP client config or as CLI parameters when launching the server. Use Cases
Links & Resources
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. |