Browser automation with Puppeteer for web navigation screenshots and DOM analysis
A Model Context Protocol server that provides browser automation capabilities using Puppeteer. This server enables LLMs to interact with web pages, take screenshots, extract and download images, and execute JavaScript in a real browser environment.
puppeteer_navigate
url
(string, required): URL to navigate tolaunchOptions
(object, optional): PuppeteerJS LaunchOptions. Default null. If changed and not null, browser restarts. Example: { headless: true, args: ['--user-data-dir="C:/Data"'] }
allowDangerous
(boolean, optional): Allow dangerous LaunchOptions that reduce security. When false, dangerous args like --no-sandbox
, --disable-web-security
will throw errors. Default false.puppeteer_screenshot
name
(string, required): Name for the screenshotselector
(string, optional): CSS selector for element to screenshotwidth
(number, optional, default: 800): Screenshot widthheight
(number, optional, default: 600): Screenshot heightpuppeteer_click
selector
(string): CSS selector for element to clickpuppeteer_hover
selector
(string): CSS selector for element to hoverpuppeteer_fill
selector
(string): CSS selector for input fieldvalue
(string): Value to fillpuppeteer_select
selector
(string): CSS selector for element to selectvalue
(string): Value to selectpuppeteer_evaluate
script
(string): JavaScript code to executepuppeteer_extract_images
<img>
tags and CSS background images)selector
(string, optional): CSS selector to limit image extraction to a specific part of the pageincludeBackgroundImages
(boolean, optional, default: true): Whether to include CSS background imagespuppeteer_download_images
imageUrls
(array of strings, required): Array of image URLs to downloadoutputFolder
(string, optional, default: './downloaded_images'): Folder path where images should be savednamePrefix
(string, optional): Prefix for downloaded image filenamespuppeteer_analyze_element
selector
(string, required): CSS selector for the element to analyzeincludeStyles
(boolean, optional, default: false): Whether to include computed stylesmaxDepth
(number, optional, default: 3): Maximum depth for nested elementsincludeSiblings
(boolean, optional, default: false): Whether to include siblings of the selected elementpuppeteer_browser_status
action
(string, required): Action to perform
status
: Check browser connection status and tab informationlist_tabs
: List all open browser tabs with URLs and titlesswitch_tab
: Switch to a different browser tabnew_tab
: Open a new browser tabtabIndex
(number, required for switch_tab
): Index of the tab to switch tourl
(string, optional for new_tab
): URL to open in the new tabpuppeteer_analyze_page_hierarchy
selector
(string, optional, default: 'body'): CSS selector for the root element to analyzemaxDepth
(number, optional, default: 10): Maximum depth of the hierarchy to analyzeincludeTextNodes
(boolean, optional, default: true): Whether to include text nodes in the hierarchyincludeClasses
(boolean, optional, default: false): Whether to include CSS classes in the outputincludeIds
(boolean, optional, default: false): Whether to include element IDs in the outputpuppeteer_viewport_switcher
preset
(string, optional): Viewport preset to use. Can be general ('mobile', 'tablet', 'desktop') or specific ('mobileSM', 'mobileMD', 'mobileLG', 'tabletSM', 'tabletMD', 'tabletLG', 'desktopSM', 'desktopMD', 'desktopLG', 'desktopXL')width
(number, optional): Custom viewport width in pixels (ignored if preset is specified)height
(number, optional): Custom viewport height in pixels (ignored if preset is specified)deviceScaleFactor
(number, optional): Device scale factor (pixel ratio) - typically 1 for desktop and 2 for retina/mobileisMobile
(boolean, optional): Whether the meta viewport tag should be used for mobile simulationhasTouch
(boolean, optional): Whether the device has touch capabilitiesisLandscape
(boolean, optional): Whether the device is in landscape orientationpuppeteer_navigation_history
action
(string, required): Navigation action to perform - either 'back' to go back in history or 'forward' to go forwardsteps
(number, optional, default: 1): Number of steps to navigateThe server provides access to two types of resources:
Console Logs (console://logs
)
Screenshots (screenshot://<name>
)
<img>
tags and CSS backgroundsHere's the Claude Desktop configuration to use the Puppeter server:
NOTE The docker implementation will use headless chromium, where as the NPX version will open a browser window.
{
"mcpServers": {
"puppeteer": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--init",
"-e",
"DOCKER_CONTAINER=true",
"mcp/puppeteer"
]
}
}
}
{
"mcpServers": {
"puppeteer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
}
}
}
You can customize Puppeteer's browser behavior in two ways:
Environment Variable: Set PUPPETEER_LAUNCH_OPTIONS
with a JSON-encoded string in the MCP configuration's env
parameter:
{
"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"
}
}
}
}
Tool Call Arguments: Pass launchOptions
and allowDangerous
parameters to the puppeteer_navigate
tool:
{
"url": "https://example.com",
"launchOptions": {
"headless": false,
"defaultViewport": { "width": 1280, "height": 720 }
}
}
The project is organized into a modular structure:
src/
├── handlers/ # Request handlers
│ ├── resourceHandlers.ts
│ └── toolHandlers.ts
├── tools/ # Tool implementations
│ ├── definitions.ts
│ ├── downloadImages.ts
│ ├── extractImages.ts
│ ├── analyzeElement.ts
│ ├── browserStatus.ts
│ ├── colorPalette.ts
│ ├── navigation.ts
│ ├── pageHierarchy.ts
│ ├── sitemap.ts
│ ├── viewport.ts
│ └── index.ts
├── types/ # TypeScript interfaces
│ └── index.ts
├── utils/ # Utility functions
│ ├── browser.ts
│ └── helpers.ts
└── index.ts # Main entry point
// Navigate to a page
await callTool("puppeteer_navigate", { url: "https://example.com" });
// Extract all images from the page
await callTool("puppeteer_extract_images", {});
// Extract images from a specific section only
await callTool("puppeteer_extract_images", {
selector: "#content-area",
includeBackgroundImages: true,
});
// Download the extracted images
await callTool("puppeteer_download_images", {
outputFolder: "./my-images",
namePrefix: "example",
});
// Or download specific images directly
await callTool("puppeteer_download_images", {
imageUrls: [
"https://example.com/image1.jpg",
"https://example.com/image2.png",
],
outputFolder: "./specific-images",
});
// Navigate to a page
await callTool("puppeteer_navigate", { url: "https://example.com" });
// Analyze a specific element
await callTool("puppeteer_analyze_element", {
selector: ".hero-section",
});
// Analyze with more options
await callTool("puppeteer_analyze_element", {
selector: "#main-content",
includeStyles: true,
maxDepth: 5,
includeSiblings: false,
});
// Analyze an element and its siblings
await callTool("puppeteer_analyze_element", {
selector: "nav.main-navigation > ul > li.active",
includeSiblings: true,
});
// Check browser status
await callTool("puppeteer_browser_status", {
action: "status",
});
// Open multiple tabs with different content
await callTool("puppeteer_navigate", { url: "https://example.com" });
await callTool("puppeteer_browser_status", {
action: "new_tab",
url: "https://example.org",
});
await callTool("puppeteer_browser_status", {
action: "new_tab",
url: "https://example.net",
});
// List all open tabs
await callTool("puppeteer_browser_status", {
action: "list_tabs",
});
// Switch back to the first tab
await callTool("puppeteer_browser_status", {
action: "switch_tab",
tabIndex: 0,
});
// Take actions in the first tab
await callTool("puppeteer_screenshot", {
name: "first-tab-screenshot",
});
// Switch to the second tab
await callTool("puppeteer_browser_status", {
action: "switch_tab",
tabIndex: 1,
});
// Take actions in the second tab
await callTool("puppeteer_extract_images", {});
// Navigate to a page
await callTool("puppeteer_navigate", { url: "https://example.com" });
// Get the full page hierarchy
await callTool("puppeteer_analyze_page_hierarchy", {});
// Analyze a specific section with custom options
await callTool("puppeteer_analyze_page_hierarchy", {
selector: "#main-content",
maxDepth: 5,
includeTextNodes: true,
includeClasses: true,
includeIds: true,
});
// Navigate to a page
await callTool("puppeteer_navigate", { url: "https://example.com" });
// Switch to mobile view
await callTool("puppeteer_viewport_switcher", { preset: "mobile" });
// Take a screenshot in mobile view
await callTool("puppeteer_screenshot", { name: "mobile-view" });
// Switch to tablet view
await callTool("puppeteer_viewport_switcher", { preset: "tablet" });
// Take a screenshot in tablet view
await callTool("puppeteer_screenshot", { name: "tablet-view" });
// Switch to desktop view
await callTool("puppeteer_viewport_switcher", { preset: "desktop" });
// Take a screenshot in desktop view
await callTool("puppeteer_screenshot", { name: "desktop-view" });
// Use a custom viewport size
await callTool("puppeteer_viewport_switcher", {
width: 1440,
height: 900,
deviceScaleFactor: 2,
isMobile: false,
});
// Navigate to a sequence of pages
await callTool("puppeteer_navigate", { url: "https://example.com" });
await callTool("puppeteer_navigate", { url: "https://example.com/page1" });
await callTool("puppeteer_navigate", { url: "https://example.com/page2" });
// Go back one page in history
await callTool("puppeteer_navigation_history", { action: "back" });
// Current page is now example.com/page1
// Go back to the first page
await callTool("puppeteer_navigation_history", { action: "back" });
// Current page is now example.com
// Go forward two steps
await callTool("puppeteer_navigation_history", {
action: "forward",
steps: 2,
});
// Current page is now example.com/page2
Docker build:
docker build -t mcp/puppeteer -f Dockerfile .
npm install
npm run build
npm run dev
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
Discover seamless cross-platform e-commerce link conversion and product promotion with Taobao MCP Service supporting Taobao JD and Pinduoduo integrations
Configure and run ORAS MCP Server easily with Docker and VS Code integration
APIs for extreme p-value calculations in R via Python using FastMCP and pyper integration
Integrate and manage Cloudera Machine Learning with Python APIs for jobs, models, experiments, and project management
Discover MCP agent strategies supporting Function Calling and ReAct via HTTP SSE streamable protocols
Real-time and historical cryptocurrency market data via MCP server supporting major exchanges and comprehensive analysis