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
249.4K downloads
47.0K stars

The Puppeteer MCP server provides browser automation capabilities, allowing LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment. It essentially gives AI models the ability to control a web browser programmatically.

Installation Options

Docker Installation (Headless Mode)

To install and run Puppeteer MCP server using Docker:

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

NPX Installation (Browser Window Visible)

For installation using NPX, which will open a visible browser window:

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

VS Code Configuration

Add the MCP server configuration to your VS Code settings:

NPX Version (for visible browser window)

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

Docker Version (for headless chromium)

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

Configuring Browser Behavior

Using Environment Variables

You can customize Puppeteer's launch options using environment variables:

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

Using Tool Parameters

You can also specify launch options directly when making tool calls:

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

Using the Puppeteer Tools

Navigation

To navigate to a URL:

{
  "tool": "puppeteer_navigate",
  "parameters": {
    "url": "https://example.com",
    "launchOptions": null,
    "allowDangerous": false
  }
}

Taking Screenshots

To capture a screenshot:

{
  "tool": "puppeteer_screenshot",
  "parameters": {
    "name": "homepage",
    "selector": "body",
    "width": 1024,
    "height": 768,
    "encoded": false
  }
}

Interacting with Elements

Click an element:

{
  "tool": "puppeteer_click",
  "parameters": {
    "selector": "#submit-button"
  }
}

Hover over an element:

{
  "tool": "puppeteer_hover",
  "parameters": {
    "selector": ".dropdown-menu"
  }
}

Fill out a form field:

{
  "tool": "puppeteer_fill",
  "parameters": {
    "selector": "#username",
    "value": "testuser"
  }
}

Select an option from a dropdown:

{
  "tool": "puppeteer_select",
  "parameters": {
    "selector": "#country",
    "value": "US"
  }
}

Running JavaScript

Execute custom JavaScript:

{
  "tool": "puppeteer_evaluate",
  "parameters": {
    "script": "document.querySelector('h1').textContent"
  }
}

Accessing Resources

Console Logs

Access browser console outputs at console://logs

Screenshots

Access screenshots at screenshot://<name> where <name> is the name you specified when taking the screenshot.

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