This MCP Puppeteer server enables browser automation capabilities for LLMs, allowing interaction with web pages, screenshot capture, and JavaScript execution in a real browser environment.
You can run the MCP Puppeteer server using either Docker or NPX. Each method has a different configuration approach.
The Docker implementation uses headless Chromium:
{
"mcpServers": {
"puppeteer": {
"command": "docker",
"args": ["run", "-i", "--rm", "--init", "-e", "DOCKER_CONTAINER=true", "mcp/puppeteer"]
}
}
}
The NPX version will open a browser window:
{
"mcpServers": {
"puppeteer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
}
}
}
The Puppeteer server provides several tools for browser automation:
puppeteer_navigate - Navigate to any URL
// Example: Navigate to Google
{
"url": "https://www.google.com"
}
puppeteer_click - Click elements on a page
// Example: Click a button with id="submit"
{
"selector": "#submit"
}
puppeteer_hover - Hover over elements
// Example: Hover over a dropdown menu
{
"selector": ".dropdown-menu"
}
puppeteer_fill - Fill input fields
// Example: Fill a search box
{
"selector": "input[name='q']",
"value": "search term"
}
puppeteer_select - Select an option from a dropdown
// Example: Select an option from a dropdown
{
"selector": "select#country",
"value": "USA"
}
puppeteer_screenshot - Capture screenshots
// Example: Capture full page screenshot
{
"name": "homepage",
"width": 1280,
"height": 800
}
// Example: Capture specific element
{
"name": "login-form",
"selector": "#login-form"
}
puppeteer_evaluate - Execute JavaScript code
// Example: Extract page title
{
"script": "return document.title;"
}
The server provides two types of resources:
Access browser console logs via the resource ID console://logs
. This provides all console messages from the browser in text format.
Access captured screenshots via the resource ID screenshot://<name>
, where <name>
is the name specified during capture. These resources are PNG images.
This example shows how to navigate to a website, fill out a form, and take a screenshot:
Navigate to a website:
// puppeteer_navigate
{
"url": "https://example.com/login"
}
Fill out username and password fields:
// puppeteer_fill for username
{
"selector": "#username",
"value": "testuser"
}
// puppeteer_fill for password
{
"selector": "#password",
"value": "password123"
}
Click the login button:
// puppeteer_click
{
"selector": "#login-button"
}
Take a screenshot of the logged-in page:
// puppeteer_screenshot
{
"name": "logged-in-page",
"width": 1280,
"height": 800
}
Access the screenshot using resource ID screenshot://logged-in-page
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.