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.
To install and run Puppeteer MCP server using Docker:
{
"mcpServers": {
"puppeteer": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--init",
"-e",
"DOCKER_CONTAINER=true",
"mcp/puppeteer"
]
}
}
}
For installation using NPX, which will open a visible browser window:
{
"mcpServers": {
"puppeteer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
}
}
}
Add the MCP server configuration to your VS Code settings:
{
"mcp": {
"servers": {
"puppeteer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
}
}
}
}
{
"mcp": {
"servers": {
"puppeteer": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--init",
"-e",
"DOCKER_CONTAINER=true",
"mcp/puppeteer"
]
}
}
}
}
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"
}
}
}
}
You can also specify launch options directly when making tool calls:
{
"url": "https://example.com",
"launchOptions": {
"headless": false,
"defaultViewport": { "width": 1280, "height": 720 }
}
}
To navigate to a URL:
{
"tool": "puppeteer_navigate",
"parameters": {
"url": "https://example.com",
"launchOptions": null,
"allowDangerous": false
}
}
To capture a screenshot:
{
"tool": "puppeteer_screenshot",
"parameters": {
"name": "homepage",
"selector": "body",
"width": 1024,
"height": 768,
"encoded": false
}
}
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"
}
}
Execute custom JavaScript:
{
"tool": "puppeteer_evaluate",
"parameters": {
"script": "document.querySelector('h1').textContent"
}
}
Access browser console outputs at console://logs
Access screenshots at screenshot://<name>
where <name>
is the name you specified when taking the screenshot.
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.