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.
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
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
To start the MCP server locally:
npm start
The server will start on the default port (typically 3000).
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'
})
});
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
})
});
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']
})
});
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;'
})
});
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.
})
});
To integrate the MCP server with your LLM 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;
}
Enable debug mode for more detailed logs:
DEBUG=mcp:* npm start
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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