Xandon/puppeteer-mcp-server
If you are the rightful owner of puppeteer-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Puppeteer MCP Server is a comprehensive Model Context Protocol server designed for browser automation, integrating seamlessly with AI assistants like Claude.
puppeteer_navigate
Navigate to a URL and return page information.
puppeteer_click
Click on an element specified by CSS selector.
puppeteer_fill
Fill a form field with the specified value.
puppeteer_select
Select an option from a dropdown menu.
puppeteer_screenshot
Take a screenshot of a webpage or specific element.
puppeteer_evaluate
Execute JavaScript code in the browser context.
Puppeteer MCP Server
A comprehensive Model Context Protocol (MCP) server for browser automation using Puppeteer, designed to work seamlessly with AI assistants like Claude.
Overview
The Model Context Protocol (MCP) is an open standard introduced by Anthropic that standardizes how AI models connect to external data sources and tools. This server provides a secure, production-ready interface for browser automation tasks.
Features
š§ Core Tools
- Navigation: Navigate to URLs with security validation
- Interaction: Click, fill forms, and select dropdown options
- Screenshots: Capture full page or element-specific screenshots
- JavaScript Execution: Run sandboxed JavaScript in browser context
š Resources
- Screenshot Management: Access and manage captured screenshots
- Console Logs: Retrieve browser console logs and error messages
š”ļø Security Features
- URL validation and domain blocking
- Sandboxed JavaScript execution
- Rate limiting (100 requests per 15 minutes)
- Resource limits and timeout enforcement
- Chrome security sandbox with custom seccomp profile
š³ Docker Support
- Production-ready Docker containers
- Non-root user execution
- Resource limits and health checks
- Chrome dependencies pre-installed
Installation
Local Development
- Clone and install dependencies:
git clone <repository-url>
cd puppeteer-mcp-server
npm install
- Build the project:
npm run build
- Start the server:
npm start
Docker Deployment
- Build and run with Docker Compose:
docker-compose up --build
- For production with monitoring:
docker-compose --profile monitoring up --build
Available Tools
puppeteer_navigate
Navigate to a URL and return page information.
Parameters:
url
(string, required): The URL to navigate totimeout
(number, optional): Navigation timeout in milliseconds (default: 30000)
Example:
{
"url": "https://example.com",
"timeout": 30000
}
puppeteer_click
Click on an element specified by CSS selector.
Parameters:
selector
(string, required): CSS selector for the elementtimeout
(number, optional): Timeout in milliseconds (default: 5000)
Example:
{
"selector": "button.submit",
"timeout": 5000
}
puppeteer_fill
Fill a form field with the specified value.
Parameters:
selector
(string, required): CSS selector for the form fieldvalue
(string, required): Value to fill in the fieldtimeout
(number, optional): Timeout in milliseconds (default: 5000)
Example:
{
"selector": "input[name='email']",
"value": "user@example.com",
"timeout": 5000
}
puppeteer_select
Select an option from a dropdown menu.
Parameters:
selector
(string, required): CSS selector for the select elementvalue
(string, required): Value of the option to selecttimeout
(number, optional): Timeout in milliseconds (default: 5000)
Example:
{
"selector": "select[name='country']",
"value": "US",
"timeout": 5000
}
puppeteer_screenshot
Take a screenshot of a webpage or specific element.
Parameters:
url
(string, required): The URL to screenshotselector
(string, optional): CSS selector for specific elementwidth
(number, optional): Viewport width (default: 1280)height
(number, optional): Viewport height (default: 720)fullPage
(boolean, optional): Capture full page (default: false)
Example:
{
"url": "https://example.com",
"selector": ".main-content",
"width": 1920,
"height": 1080,
"fullPage": true
}
puppeteer_evaluate
Execute JavaScript code in the browser context.
Parameters:
script
(string, required): JavaScript code to executetimeout
(number, optional): Execution timeout in milliseconds (default: 30000)
Example:
{
"script": "document.title",
"timeout": 30000
}
Available Resources
screenshot://list
Lists all saved screenshots with metadata.
screenshot://file/{filename}
Retrieves a specific screenshot file.
console://logs
Retrieves all captured console logs.
console://logs/recent
Retrieves the 50 most recent console logs.
console://logs/errors
Retrieves only error and warning console logs.
Configuration
Environment Variables
Variable | Default | Description |
---|---|---|
NODE_ENV | development | Environment mode |
LOG_LEVEL | info | Logging level |
PUPPETEER_TIMEOUT | 30000 | Default timeout for operations |
MAX_CONCURRENT_PAGES | 5 | Maximum concurrent browser pages |
RATE_LIMIT_WINDOW_MS | 900000 | Rate limit window (15 minutes) |
RATE_LIMIT_MAX_REQUESTS | 100 | Maximum requests per window |
PUPPETEER_EXECUTABLE_PATH | Auto-detected | Chrome executable path |
Security Considerations
- Domain Blocking: Localhost and private IPs are blocked by default
- Protocol Filtering: Only HTTP/HTTPS URLs are allowed
- Script Validation: JavaScript execution is sandboxed and validated
- Resource Limits: Memory and CPU usage are monitored and limited
- Rate Limiting: Prevents abuse with configurable limits
Usage with Claude Desktop
- Add to your Claude Desktop configuration:
{
"mcpServers": {
"puppeteer": {
"command": "node",
"args": ["/path/to/puppeteer-mcp-server/build/index.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
-
Restart Claude Desktop to load the server.
-
Use browser automation tools in your conversations:
- "Take a screenshot of https://example.com"
- "Click the login button on the current page"
- "Fill the search form with 'puppeteer tutorial'"
Development
Scripts
npm run build
: Compile TypeScript to JavaScriptnpm run start
: Start the production servernpm run dev
: Start development server with hot reloadnpm run inspector
: Start with MCP Inspector for debugging
Project Structure
src/
āāā config/ # Configuration files
āāā tools/ # MCP tool implementations
āāā browser/ # Browser management
āāā resources/ # MCP resource implementations
āāā types/ # TypeScript type definitions
āāā server.ts # Main server class
āāā index.ts # Entry point
Troubleshooting
Common Issues
- Chrome not found: Ensure Chrome is installed or set
PUPPETEER_EXECUTABLE_PATH
- Permission denied: Run with proper user permissions or use Docker
- Memory issues: Adjust Docker memory limits or reduce
MAX_CONCURRENT_PAGES
- Network timeout: Increase
PUPPETEER_TIMEOUT
for slow websites
Debug Mode
Enable debug logging:
LOG_LEVEL=debug npm start
MCP Inspector
Debug MCP communication:
npm run inspector
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section
- Review logs in the
logs/
directory - Open an issue on GitHub