This MCP server provides cloud browser automation capabilities using Browserbase, Puppeteer, and Stagehand. It allows Language Models (LLMs) to interact with web pages, take screenshots, and execute JavaScript in a cloud browser environment, making it easier to integrate LLMs with external web data.
The server offers two main components:
The Browserbase MCP provides comprehensive browser automation features:
The Stagehand MCP offers a higher-level interface with:
act("click the login button")
or extract("find the red shoes")
You can install the MCP server using one of these methods:
Clone the repository:
git clone https://github.com/browserbase/mcp-server.git
cd mcp-server
Install dependencies:
npm install
Start the server:
npm start
You can also install the MCP server using Smithery:
# If you have Smithery installed
smithery install @browserbasehq/mcp-browserbase
Visit Smithery's Browserbase MCP page for more details.
To use the Browserbase MCP, you need to set up your configuration:
Create a configuration file (e.g., config.json
):
{
"browserbase": {
"apiKey": "your-browserbase-api-key"
}
}
Pass the configuration when starting the server:
npm start -- --config=config.json
Here's a simple example of using the Browserbase MCP to navigate to a webpage and take a screenshot:
// Example client code
const response = await fetch('http://localhost:3000/browserbase/navigate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com'
})
});
const data = await response.json();
console.log(data);
// Take a screenshot
const screenshotResponse = await fetch('http://localhost:3000/browserbase/screenshot', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
selector: 'body' // Optional: specify an element
})
});
const screenshot = await screenshotResponse.json();
console.log(screenshot.data); // Base64 encoded image
Stagehand provides a higher-level interface for browser automation:
// Example client code
const response = await fetch('http://localhost:3000/stagehand/act', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
instruction: "click the login button",
model: "gpt-4" // Optional: specify which model to use
})
});
const result = await response.json();
console.log(result);
// Extract data from a webpage
const extractResponse = await fetch('http://localhost:3000/stagehand/extract', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
instruction: "find the product prices and names"
})
});
const extractedData = await extractResponse.json();
console.log(extractedData);
The MCP server accepts several configuration options:
--port
: Specify the server port (default: 3000)--config
: Path to configuration file--debug
: Enable debug loggingExample:
npm start -- --port=4000 --config=prod-config.json --debug
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.