puppeteer mcp server
Enables browser automation with Puppeteer, supporting navigation, form interactions, and connection to active Chrome instances for comprehensive web page interaction.
Enables browser automation with Puppeteer, supporting navigation, form interactions, and connection to active Chrome instances for comprehensive web page interaction.
This MCP server provides browser automation capabilities through Puppeteer, allowing interaction with both new browser instances and existing Chrome windows.
This project is an experimental implementation inspired by @modelcontextprotocol/server-puppeteer. While it shares similar goals and concepts, it explores alternative approaches to browser automation through the Model Context Protocol.
/
├── src/
│ ├── config/ # Configuration modules
│ ├── tools/ # Tool definitions and handlers
│ ├── browser/ # Browser connection management
│ ├── types/ # TypeScript type definitions
│ ├── resources/ # Resource handlers
│ └── server.ts # Server initialization
├── index.ts # Entry point
└── README.md # Documentation
npm install -g puppeteer-mcp-server
You can also run it directly without installation using npx:
npx puppeteer-mcp-server
npm install
npm run build
npm start
To use this tool with Claude, you need to add it to your MCP settings configuration file.
Add the following to your Claude Desktop configuration file (located at %APPDATA%Claudeclaude_desktop_config.json
on Windows or ~/Library/Application Support/Claude/claude_desktop_config.json
on macOS):
{
"mcpServers": {
"puppeteer": {
"command": "puppeteer-mcp-server",
"args": [],
"env": {}
}
}
}
{
"mcpServers": {
"puppeteer": {
"command": "npx",
"args": ["-y", "puppeteer-mcp-server"],
"env": {}
}
}
}
{
"mcpServers": {
"puppeteer": {
"command": "node",
"args": ["path/to/puppeteer-mcp-server/dist/index.js"],
"env": {
"NODE_OPTIONS": "--experimental-modules"
}
}
}
}
Add the following to your Claude VSCode extension MCP settings file (located at %APPDATA%CodeUserglobalStoragesaoudrizwan.claude-devsettingscline_mcp_settings.json
on Windows or ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
on macOS):
{
"mcpServers": {
"puppeteer": {
"command": "puppeteer-mcp-server",
"args": [],
"env": {}
}
}
}
{
"mcpServers": {
"puppeteer": {
"command": "npx",
"args": ["-y", "puppeteer-mcp-server"],
"env": {}
}
}
}
{
"mcpServers": {
"puppeteer": {
"command": "node",
"args": ["path/to/puppeteer-mcp-server/dist/index.js"],
"env": {
"NODE_OPTIONS": "--experimental-modules"
}
}
}
}
For source installation, replace path/to/puppeteer-mcp-server
with the actual path to where you installed this tool.
The server will launch a new browser instance by default.
To connect to an existing Chrome window:
Close any existing Chrome instances completely
Launch Chrome with remote debugging enabled:
# Windows
"C:Program FilesGoogleChromeApplicationchrome.exe" --remote-debugging-port=9222
# macOS
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --remote-debugging-port=9222
# Linux
google-chrome --remote-debugging-port=9222
Navigate to your desired webpage in Chrome
Connect using the puppeteer_connect_active_tab
tool:
{
"targetUrl": "https://example.com", // Optional: specific tab URL
"debugPort": 9222 // Optional: defaults to 9222
}
The server will: - Detect and connect to the Chrome instance running with remote debugging enabled - Preserve your Chrome instance (won't close it) - Find and connect to non-extension tabs - Provide clear error messages if connection fails
Connect to an existing Chrome instance with remote debugging enabled.
- Optional:
- targetUrl
- URL of the specific tab to connect to
- debugPort
- Chrome debugging port (default: 9222)
Navigate to a URL.
- Required: url
- The URL to navigate to
Take a screenshot of the current page or a specific element.
- Required: name
- Name for the screenshot
- Optional:
- selector
- CSS selector for element to screenshot
- width
- Width in pixels (default: 800)
- height
- Height in pixels (default: 600)
Click an element on the page.
- Required: selector
- CSS selector for element to click
Fill out an input field.
- Required:
- selector
- CSS selector for input field
- value
- Text to enter
Use dropdown menus.
- Required:
- selector
- CSS selector for select element
- value
- Option value to select
Hover over elements.
- Required: selector
- CSS selector for element to hover
Execute JavaScript in the browser console.
- Required: script
- JavaScript code to execute
When using remote debugging: - Only enable on trusted networks - Use a unique debugging port - Close debugging port when not in use - Never expose debugging port to public networks
The server implements comprehensive logging using Winston:
logs/
directorymcp-puppeteer-YYYY-MM-DD.log
The server provides detailed error messages for: - Connection failures - Missing elements - Invalid selectors - JavaScript execution errors - Screenshot failures
Each tool call returns: - Success/failure status - Detailed error message if failed - Operation result data if successful
All errors are also logged to the log files with: - Timestamp - Error message - Stack trace (when available) - Context information
Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.
This project is licensed under the MIT License - see the LICENSE file for details.
[
{
"description": "Connect to an existing Chrome instance with remote debugging enabled",
"inputSchema": {
"properties": {
"debugPort": {
"default": 9222,
"description": "Optional Chrome debugging port (default: 9222)",
"type": "number"
},
"targetUrl": {
"description": "Optional URL of the target tab to connect to. If not provided, connects to the first available tab.",
"type": "string"
}
},
"required": [],
"type": "object"
},
"name": "puppeteer_connect_active_tab"
},
{
"description": "Navigate to a URL",
"inputSchema": {
"properties": {
"url": {
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
},
"name": "puppeteer_navigate"
},
{
"description": "Take a screenshot of the current page or a specific element",
"inputSchema": {
"properties": {
"height": {
"description": "Height in pixels (default: 600)",
"type": "number"
},
"name": {
"description": "Name for the screenshot",
"type": "string"
},
"selector": {
"description": "CSS selector for element to screenshot",
"type": "string"
},
"width": {
"description": "Width in pixels (default: 800)",
"type": "number"
}
},
"required": [
"name"
],
"type": "object"
},
"name": "puppeteer_screenshot"
},
{
"description": "Click an element on the page",
"inputSchema": {
"properties": {
"selector": {
"description": "CSS selector for element to click",
"type": "string"
}
},
"required": [
"selector"
],
"type": "object"
},
"name": "puppeteer_click"
},
{
"description": "Fill out an input field",
"inputSchema": {
"properties": {
"selector": {
"description": "CSS selector for input field",
"type": "string"
},
"value": {
"description": "Value to fill",
"type": "string"
}
},
"required": [
"selector",
"value"
],
"type": "object"
},
"name": "puppeteer_fill"
},
{
"description": "Select an element on the page with Select tag",
"inputSchema": {
"properties": {
"selector": {
"description": "CSS selector for element to select",
"type": "string"
},
"value": {
"description": "Value to select",
"type": "string"
}
},
"required": [
"selector",
"value"
],
"type": "object"
},
"name": "puppeteer_select"
},
{
"description": "Hover an element on the page",
"inputSchema": {
"properties": {
"selector": {
"description": "CSS selector for element to hover",
"type": "string"
}
},
"required": [
"selector"
],
"type": "object"
},
"name": "puppeteer_hover"
},
{
"description": "Execute JavaScript in the browser console",
"inputSchema": {
"properties": {
"script": {
"description": "JavaScript code to execute",
"type": "string"
}
},
"required": [
"script"
],
"type": "object"
},
"name": "puppeteer_evaluate"
}
]