christophe77/puppeteer-mcp
If you are the rightful owner of puppeteer-mcp 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.
Puppeteer MCP Server is a Model Context Protocol server that integrates with Cursor AI to fetch and analyze web page content using Puppeteer, ideal for frontend development tasks.
Puppeteer MCP Server
A Model Context Protocol (MCP) server that enables Cursor AI to fetch and analyze web page content using Puppeteer. Perfect for frontend development workflows where you need to inspect rendered HTML, debug components, or analyze live websites.
š Features
- Web Page Fetching: Retrieve complete HTML source of any URL
- Cursor Integration: Seamlessly works with Cursor AI agent
- Puppeteer Powered: Uses headless Chrome for accurate rendering
- TypeScript: Fully typed and maintainable codebase
- Simple CLI: Easy-to-use command line interface
š Prerequisites
- Node.js 16+
- npm or yarn
- Cursor IDE
š ļø Installation
- Clone or download this project
git clone https://github.com/christophe77/puppeteer-mcp
cd puppeteer-mcp
- Install dependencies
npm install
- Build the project
npm run build
āļø Configuration
Cursor MCP Setup
Add the following configuration to your Cursor MCP settings (~/.cursor/mcp.json
):
{
"mcpServers": {
"puppeteer-mcp": {
"command": "node",
"args": ["C:\\path\\to\\your\\puppeteer-mcp\\dist\\puppeteer-mcp.js"]
}
}
}
Important: Replace C:\\path\\to\\your\\puppeteer-mcp
with your actual project path.
Restart Cursor
After updating the configuration, restart Cursor completely for the changes to take effect.
šÆ Usage
Method 1: Direct MCP Call (in Cursor)
@mcp puppeteer-mcp.fetchPageSource {"url": "https://example.com"}
Method 2: NPM Script (Recommended)
npm run fetch https://example.com
Method 3: Windows Batch File
fetch.bat https://example.com
š” Use Cases & Examples
1. Frontend Development Debugging
Scenario: Your React/Next.js component isn't rendering correctly
Problem:
The Header component logo is invisible. Check the code and fetch http://localhost:3000
Solution:
- Use the MCP tool to fetch the rendered HTML
- Compare with your component code
- Identify CSS issues, missing classes, or rendering problems
Example:
@mcp puppeteer-mcp.fetchPageSource {"url": "http://localhost:3000"}
2. Component Analysis
Scenario: Debugging a complex component structure
Use Cases:
- Verify if dynamic content is properly rendered
- Check if conditional rendering works as expected
- Analyze the final DOM structure
- Debug CSS-in-JS or styled-components output
3. SEO & Meta Tag Verification
Scenario: Ensuring proper meta tags and SEO elements
Example:
@mcp puppeteer-mcp.fetchPageSource {"url": "https://myapp.com/product/123"}
What to look for:
- Meta descriptions
- Open Graph tags
- Structured data
- Title tags
4. Cross-Browser Testing
Scenario: Verify how your app renders in different environments
Use Cases:
- Check if CSS Grid/Flexbox works correctly
- Verify responsive design
- Test JavaScript functionality
- Validate accessibility attributes
5. Third-Party Integration Testing
Scenario: Testing external widget or API integrations
Examples:
- Payment gateway integration
- Analytics tracking
- Chat widgets
- Social media embeds
6. Performance Analysis
Scenario: Analyzing page structure for optimization
What to analyze:
- DOM complexity
- Unused CSS
- Inline styles
- Script loading order
š§ Development
Available Scripts
# Build TypeScript
npm run build
# Build and watch for changes
npm run build:watch
# Start MCP server
npm start
# Development mode (build + watch + start)
npm run dev
# Fetch a webpage (simplified CLI)
npm run fetch <URL>
Project Structure
chrome-mcp/
āāā src/
ā āāā puppeteer-mcp.ts # Main MCP server
āāā dist/ # Compiled JavaScript
āāā fetch-web.js # CLI wrapper script
āāā fetch.bat # Windows batch file
āāā package.json
āāā tsconfig.json
āāā README.md
š Troubleshooting
"No tools or prompts" in Cursor
- Check the file path in
mcp.json
- use absolute path - Restart Cursor completely
- Verify the build - run
npm run build
- Test manually - run
npm run fetch <URL>
Server not responding
- Check Node.js version - requires 16+
- Verify dependencies - run
npm install
- Check Puppeteer - it may need to download Chrome
Permission issues
- Run as administrator if needed
- Check file permissions on the project directory
- Verify antivirus isn't blocking the process
š Advanced Usage
Custom Puppeteer Options
You can modify src/puppeteer-mcp.ts
to add custom Puppeteer options:
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
Adding More Tools
Extend the MCP server with additional tools:
server.registerTool(
'screenshot',
{
title: 'Take Screenshot',
description: 'Capture a screenshot of a webpage',
inputSchema: { url: z.string() },
},
async ({ url }) => {
// Implementation here
},
);
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
š License
ISC License - see package.json for details
š Support
If you encounter issues:
- Check the troubleshooting section
- Verify your Cursor MCP configuration
- Test with a simple URL first
- Check the console for error messages
Happy coding with Cursor AI! š