Puppeteer MCP Server (Python Implementation)
A Model Context Protocol server that provides browser automation capabilities using Playwright (Python’s equivalent to Puppeteer). This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.
Overview
This Python implementation provides a stable alternative to the TypeScript version, offering the same capabilities with improved error handling and logging. It uses Playwright, which is the Python equivalent to Puppeteer, providing robust browser automation capabilities.
Key Features
- Full browser automation
- Page navigation
- Screenshot capture (full page or elements)
- Form interaction (clicking and filling)
- JavaScript execution
- Console log monitoring
- Configurable timeouts
- Detailed error handling
- Comprehensive logging
Prerequisites
- Python 3.8+
- pip (Python package installer)
Installation
- Install the required packages:
pip install -r requirements.txt
- Install Playwright browsers:
playwright install
Usage
Starting the Server
Run the server directly:
python puppeteer_server.py
Claude Desktop Configuration
Add this to your Claude configuration file:
{
"mcpServers": {
"puppeteer": {
"command": "python",
"args": ["path/to/puppeteer.py"]
}
}
}
Available Tools
puppeteer_navigate
Navigate to any URL in the browser.
{
"name": "puppeteer_navigate",
"arguments": {
"url": "https://example.com",
"timeout": 60000 // optional, defaults to 60000ms
}
}
puppeteer_screenshot
Capture screenshots of the entire page or specific elements.
{
"name": "puppeteer_screenshot",
"arguments": {
"name": "my_screenshot",
"selector": "#specific-element", // optional
"width": 1280, // optional, default: 1280
"height": 720, // optional, default: 720
"timeout": 30000 // optional, defaults to 30000ms
}
}
puppeteer_click
Click elements on the page.
{
"name": "puppeteer_click",
"arguments": {
"selector": ".button-class",
"timeout": 30000 // optional, defaults to 30000ms
}
}
puppeteer_fill
Fill out input fields.
{
"name": "puppeteer_fill",
"arguments": {
"selector": "#input-id",
"value": "text to fill",
"timeout": 30000 // optional, defaults to 30000ms
}
}
puppeteer_evaluate
Execute JavaScript in the browser console.
{
"name": "puppeteer_evaluate",
"arguments": {
"script": "document.title",
"timeout": 30000 // optional, defaults to 30000ms
}
}
Error Handling
The server provides detailed error messages for common scenarios:
- Navigation failures
- Element not found
- Timeout errors
- JavaScript execution errors
- Screenshot failures
Logging
Comprehensive logging is implemented with different levels:
- INFO: Standard operations
- ERROR: Operation failures
- DEBUG: Detailed execution information
Notes
- Browser launches in non-headless mode for better debugging
- Default viewport size is 1280x720
- All timeouts are configurable
- Console logs are captured and stored
- Screenshots are stored in memory with base64 encoding
Contributing
Contributions are welcome! Please read the repository’s contributing guidelines before submitting pull requests.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Puppeteer MCP Server
Project Details
- twolven/mcp-server-puppeteer-py
- Apache License 2.0
- Last Updated: 3/21/2025
Categories
Recomended MCP Servers
PhonePi MCP enables seamless integration between desktop AI tools and your smartphone, providing 23+ direct actions including SMS...
MCP Server for the Perplexity API.
A Model Context Protocol server for integrating HackMD's note-taking platform with AI assistants.
Interact seamlessly with GitLab repositories to manage merge requests and issues. Fetch details, add comments, and streamline your...
High-performance FastAPI server implementing Model Context Protocol (MCP) for seamless integration with Large Language Models (LLMs). Built with...
All-in-one open-source embeddings database for semantic search, LLM orchestration and language model workflows
Model Context Protocol (MCP) Server for retrieving saved articles from Pocket API and loading them into Claude
a mcp server to manage github project's functionality
An MCP (Model Context Protocol) server implementation that integrates Claude with Salesforce, enabling natural language interactions with your...
Model Context Protocol (MCP) server to capture images from an OpenCV-compatible webcam or video source
An intelligent MCP server that provides tools for collecting and documenting code from directories