Puppeteer MCP server

Navigate websites, fill forms, and capture screenshots programmatically.
Back to servers
Provider
Anthropic
Release date
Nov 19, 2024
Language
TypeScript
Package
Stats
147.7K downloads
39.3K stars

The Puppeteer MCP server provides browser automation capabilities that allow large language models to interact with web pages, take screenshots, and execute JavaScript in a real browser environment. It enables AI assistants to navigate websites, fill forms, and capture visual content from the web.

Installation

You can run the Puppeteer MCP server using either Docker or NPX. Each method has slightly different characteristics.

Docker Installation

The Docker implementation uses headless Chromium:

{
  "mcpServers": {
    "puppeteer": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "--init", "-e", "DOCKER_CONTAINER=true", "mcp/puppeteer"]
    }
  }
}

To build the Docker image yourself:

docker build -t mcp/puppeteer -f src/puppeteer/Dockerfile .

NPX Installation

The NPX version opens a visible browser window:

{
  "mcpServers": {
    "puppeteer": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
    }
  }
}

Usage

The Puppeteer MCP server provides several tools for browser automation:

Navigation

{
  "url": "https://example.com",
  "launchOptions": {
    "headless": false,
    "defaultViewport": {"width": 1280, "height": 720}
  },
  "allowDangerous": false
}
  • url: The webpage to navigate to (required)
  • launchOptions: Optional Puppeteer configuration settings
  • allowDangerous: When false, blocks security-reducing options like --no-sandbox

Taking Screenshots

{
  "name": "homepage",
  "selector": "#main-content",
  "width": 1024,
  "height": 768
}
  • name: Identifier for the screenshot (required)
  • selector: CSS selector for a specific element (optional)
  • width and height: Dimensions of the screenshot (optional)

Clicking Elements

{
  "selector": ".submit-button"
}

Hovering Over Elements

{
  "selector": ".dropdown-menu"
}

Filling Form Fields

{
  "selector": "#username",
  "value": "testuser"
}

Selecting From Dropdowns

{
  "selector": "#country",
  "value": "Canada"
}

Executing JavaScript

{
  "script": "document.querySelector('.dark-mode-toggle').click(); return document.title;"
}

Customizing Browser Behavior

You can customize the Puppeteer launch options in two ways:

Using Environment Variables

Set PUPPETEER_LAUNCH_OPTIONS with a JSON-encoded string:

{
  "mcpServers": {
    "mcp-puppeteer": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-puppeteer"],
      "env": {
        "PUPPETEER_LAUNCH_OPTIONS": "{ \"headless\": false, \"executablePath\": \"C:/Program Files/Google/Chrome/Application/chrome.exe\", \"args\": [] }",
        "ALLOW_DANGEROUS": "true"
      }
    }
  }
}

Via Tool Call Arguments

Pass options directly to the navigation tool:

{
  "url": "https://example.com",
  "launchOptions": {
    "headless": false,
    "defaultViewport": {"width": 1280, "height": 720}
  },
  "allowDangerous": true
}

Available Resources

The server provides two types of resources:

Console Logs

Access browser console output at console://logs - this includes all console messages from the browser session.

Screenshots

Access captured screenshots at screenshot://<name> where <name> is the identifier specified during capture. These are PNG images.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later