### Development setup for puppeteer-mcp-claude Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Commands for cloning the repository, installing dependencies, building the project, and using the local setup script for development purposes. ```bash git clone https://github.com/jaenster/puppeteer-mcp-claude.git cd puppeteer-mcp-claude npm install ``` ```bash npm run build ``` ```bash npm run setup-mcp ``` -------------------------------- ### Start Local Test Server Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Start the local test server for the project. This server will be accessible at http://localhost:3003. ```bash npm run test:real ``` -------------------------------- ### Install puppeteer-mcp-claude with npx Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Run this command for a universal installer that works for both Claude Desktop and Claude Code. It automatically detects and configures your Claude applications. ```bash npx puppeteer-mcp-claude install ``` -------------------------------- ### Global npm installation Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Install the puppeteer-mcp-claude package globally using npm. This is part of the manual installation process. ```bash npm install -g puppeteer-mcp-claude ``` -------------------------------- ### Run Development Mode Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Starts the MCP server in development mode for detailed logging of operations. Useful for debugging. ```bash npm run dev ``` -------------------------------- ### Complete Web Automation Workflow Example Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Demonstrates a full web automation sequence including browser launch, navigation, form filling, interaction, data extraction, and cleanup. Ensure all Puppeteer functions are correctly imported and available. ```javascript // 1. Launch browser with stealth mode await puppeteer_launch({ headless: false, stealth: true, viewport: { width: 1366, height: 768 } }); // 2. Create a page and navigate await puppeteer_new_page({ pageId: "main" }); await puppeteer_navigate({ pageId: "main", url: "https://example.com/login", waitUntil: "networkidle2" }); // 3. Fill in login form await puppeteer_type({ pageId: "main", selector: "input[name='email']", text: "user@example.com" }); await puppeteer_type({ pageId: "main", selector: "input[name='password']", text: "securePassword123" }); // 4. Click submit and wait for dashboard await puppeteer_click({ pageId: "main", selector: "button[type='submit']" }); await puppeteer_wait_for_selector({ pageId: "main", selector: ".dashboard-content", timeout: 10000 }); // 5. Take screenshot of logged-in state await puppeteer_screenshot({ pageId: "main", path: "/tmp/dashboard.png", fullPage: true }); // 6. Extract data using JavaScript await puppeteer_evaluate({ pageId: "main", script: "document.querySelector('.user-name').textContent" }); // 7. Get cookies for later use await puppeteer_get_cookies({ pageId: "main" }); // 8. Clean up await puppeteer_close_browser({}); ``` -------------------------------- ### Install Puppeteer MCP Claude Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Commands to add, install, check status, and uninstall the Puppeteer MCP Claude server for Claude Code. ```bash claude mcp add puppeteer-mcp-claude ``` ```bash npx puppeteer-mcp-claude install ``` ```bash npx puppeteer-mcp-claude status ``` ```bash npx puppeteer-mcp-claude uninstall ``` -------------------------------- ### Manual MCP server configuration for Claude Desktop Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Example JSON configuration for manually setting up the puppeteer-mcp-claude server in `claude_desktop_config.json`. This specifies the command and arguments to run the server. ```json { "mcpServers": { "puppeteer-mcp-claude": { "command": "npx", "args": ["puppeteer-mcp-claude", "serve"], "env": { "NODE_ENV": "production" } } } } ``` -------------------------------- ### Install puppeteer-mcp-claude via Claude MCP Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Use this command to add the puppeteer-mcp-claude server to your Claude Code MCP configuration. This is the recommended method for integrating browser automation. ```bash claude mcp add puppeteer-mcp-claude ``` -------------------------------- ### Check puppeteer-mcp-claude installation status Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md This command allows you to verify the installation status of the puppeteer-mcp-claude server across all detected Claude applications. ```bash npx puppeteer-mcp-claude status ``` -------------------------------- ### Test Puppeteer Tools Availability Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md List all available tools in Claude Code to verify that Puppeteer tools are present after setup. ```bash List all available tools ``` -------------------------------- ### puppeteer_get_cookies Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Retrieves cookies from a page. Can filter by specific URLs or get all cookies for the current page. ```APIDOC ## puppeteer_get_cookies ### Description Retrieves cookies from a page. Can filter by specific URLs or get all cookies for the current page. ### Method Not specified, assumed to be a function call. ### Endpoint Not applicable, this is a function call. ### Parameters #### Request Body - **pageId** (string) - Required - Identifier for the page. - **urls** (array) - Optional - An array of URLs to filter cookies by. ### Request Example ```json { "pageId": "main", "urls": [ "https://example.com", "https://api.example.com" ] } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result message. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The result message, e.g., 'Retrieved cookies: [{"name":"session_id","value":"abc123",...}]'. #### Response Example ```json { "content": [ { "type": "text", "text": "Retrieved cookies: [{"name":"session_id","value":"abc123",...}]" } ] } ``` ``` -------------------------------- ### Get Text Content with Puppeteer Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Extracts the visible text content from an element specified by a CSS selector. Returns the innerText of the matched element. Useful for scraping data or verifying displayed information. ```javascript // Get heading text await puppeteer_get_text({ pageId: "main", selector: "h1.page-title" }); ``` ```javascript // Get paragraph content await puppeteer_get_text({ pageId: "main", selector: ".article-content p:first-child" }); ``` ```javascript // Get error message text await puppeteer_get_text({ pageId: "main", selector: ".error-message" }); ``` ```javascript // Get table cell content await puppeteer_get_text({ pageId: "main", selector: "table tbody tr:first-child td:nth-child(2)" }); ``` -------------------------------- ### Display puppeteer-mcp-claude help Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Run this command to view help information and a list of available tools provided by the puppeteer-mcp-claude server. ```bash npx puppeteer-mcp-claude help ``` -------------------------------- ### Basic Web Automation with Puppeteer Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Launches a browser, creates a new page, navigates to a URL, and takes a screenshot. Ensure `puppeteer_launch` is called before other Puppeteer tools. ```javascript // Launch browser await puppeteer_launch({ headless: false }); // Create a new page await puppeteer_new_page({ pageId: "main" }); // Navigate to a website await puppeteer_navigate({ pageId: "main", url: "https://example.com" }); // Take a screenshot await puppeteer_screenshot({ pageId: "main", path: "screenshot.png" }); ``` -------------------------------- ### Run Test Suite Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Executes the general test suite to verify the functionality of the MCP server. ```bash npm test ``` -------------------------------- ### Quick Console Test with Puppeteer Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Perform a comprehensive browser automation test using a single command, including launching a browser, creating a page, navigating, taking a screenshot, and closing the browser. The '--dangerously-skip-permissions' flag is used to bypass permission checks. ```bash claude --dangerously-skip-permissions "Use puppeteer_launch to start a browser, then use puppeteer_new_page to create a page with ID 'test', then use puppeteer_navigate to go to google.com, then use puppeteer_screenshot to take a screenshot called 'google-test.png', then use puppeteer_close_browser to close the browser" ``` -------------------------------- ### puppeteer_launch Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Launches a new Puppeteer browser instance or connects to an existing Chrome instance. Supports headless/headed modes, custom viewport, stealth mode, proxy configuration, and custom user agents. ```APIDOC ## puppeteer_launch ### Description Launches a new Puppeteer browser instance or connects to an existing Chrome instance with remote debugging. Supports headless/headed modes, custom viewport, stealth mode for bot detection avoidance, proxy configuration, and custom user agents. ### Method POST ### Endpoint /puppeteer_launch ### Parameters #### Request Body - **headless** (boolean) - Optional - Whether to run the browser in headless mode. - **stealth** (boolean) - Optional - Whether to enable stealth mode to avoid bot detection. - **viewport** (object) - Optional - Configuration for the browser viewport. - **width** (number) - Optional - Viewport width. - **height** (number) - Optional - Viewport height. - **deviceScaleFactor** (number) - Optional - Device scale factor. - **isMobile** (boolean) - Optional - Whether the viewport is for a mobile device. - **hasTouch** (boolean) - Optional - Whether the viewport has touch support. - **isLandscape** (boolean) - Optional - Whether the viewport is in landscape mode. - **proxy** (object) - Optional - Proxy configuration. - **server** (string) - Required - Proxy server address. - **username** (string) - Optional - Proxy username. - **password** (string) - Optional - Proxy password. - **userAgent** (string) - Optional - Custom user agent string. - **browserWSEndpoint** (string) - Optional - WebSocket endpoint for connecting to an existing Chrome instance. - **executablePath** (string) - Optional - Path to the Chrome executable. - **userDataDir** (string) - Optional - Path to the user data directory. - **args** (array) - Optional - Additional arguments to pass to the browser. - **slowMo** (number) - Optional - Slow down all Puppeteer operations by the specified milliseconds. ### Request Example ```json { "headless": true } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result of the operation. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The textual content, e.g., 'Browser launched successfully'. #### Response Example ```json { "content": [ { "type": "text", "text": "Browser launched successfully" } ] } ``` ``` -------------------------------- ### Launch Puppeteer Browser Instance Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Launches a new Puppeteer browser instance or connects to an existing one. Supports various configurations including headless mode, viewport, stealth, proxy, and custom executables. ```javascript // Basic headless launch await puppeteer_launch({ headless: true }); ``` ```javascript // Launch with visible browser window await puppeteer_launch({ headless: false }); ``` ```javascript // Launch with custom viewport and stealth mode await puppeteer_launch({ headless: false, stealth: true, viewport: { width: 1920, height: 1080, deviceScaleFactor: 1, isMobile: false, hasTouch: false, isLandscape: true }, userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" }); ``` ```javascript // Launch with proxy support await puppeteer_launch({ headless: true, proxy: { server: "http://proxy.example.com:8080", username: "user", password: "pass" } }); ``` ```javascript // Connect to existing Chrome instance (start Chrome with --remote-debugging-port=9222) await puppeteer_launch({ browserWSEndpoint: "ws://localhost:9222/devtools/browser/..." }); ``` ```javascript // Launch with custom Chrome executable and user data directory await puppeteer_launch({ executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", userDataDir: "/tmp/chrome-profile", args: ["--disable-extensions", "--disable-gpu"], slowMo: 50 // Slow down actions by 50ms for debugging }); // Returns: { content: [{ type: 'text', text: 'Browser launched successfully' }] } ``` -------------------------------- ### Test with Local Site Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Test Puppeteer tools by navigating to a local site, filling out a form, submitting it, and taking a screenshot. The '--dangerously-skip-permissions' flag is used to bypass permission checks. ```bash claude --dangerously-skip-permissions "Use puppeteer tools to navigate to http://localhost:3003, fill out the form with test data, submit it, and take a screenshot" ``` -------------------------------- ### Run Integration Tests Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Execute integration tests for the MCP server. Ensure Claude Code is restarted before running. ```bash npm run test:integration ``` -------------------------------- ### Navigate Page to URL Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Navigates a specified page to a URL, with options to control when navigation is considered complete (e.g., load event, DOM content loaded, network idle). ```javascript // Basic navigation (waits for 'load' event by default) await puppeteer_navigate({ pageId: "main", url: "https://example.com" }); ``` ```javascript // Wait for DOM content to be loaded (faster) await puppeteer_navigate({ pageId: "main", url: "https://example.com", waitUntil: "domcontentloaded" }); ``` ```javascript // Wait for network to be completely idle (no requests for 500ms) await puppeteer_navigate({ pageId: "main", url: "https://example.com/spa-app", waitUntil: "networkidle0" }); ``` ```javascript // Wait for at most 2 network connections (useful for pages with long-polling) await puppeteer_navigate({ pageId: "main", url: "https://example.com/realtime-app", waitUntil: "networkidle2" }); // Returns: { content: [{ type: 'text', text: 'Navigated to https://example.com' }] } ``` -------------------------------- ### Form Interaction with Puppeteer Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Demonstrates typing into a search field, clicking a button, and waiting for search results. Use `puppeteer_wait_for_selector` to ensure elements are present before interaction. ```javascript // Type into a search field await puppeteer_type({ pageId: "main", selector: "input[name='search']", text: "Claude AI" }); // Click a button await puppeteer_click({ pageId: "main", selector: "button[type='submit']" }); // Wait for results to load await puppeteer_wait_for_selector({ pageId: "main", selector: ".search-results" }); ``` -------------------------------- ### Check MCP Configuration Status Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Check the current status of the MCP configuration. ```bash npm run status-mcp ``` -------------------------------- ### puppeteer_navigate Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Navigates a specified page to a given URL with configurable wait conditions. Supports waiting for various events like 'load', 'domcontentloaded', or network idle states. ```APIDOC ## puppeteer_navigate ### Description Navigates a page to a specified URL with configurable wait conditions. Supports waiting for load events, DOM content loaded, or network idle states. ### Method POST ### Endpoint /puppeteer_navigate ### Parameters #### Request Body - **pageId** (string) - Required - The identifier of the page to navigate. - **url** (string) - Required - The URL to navigate to. - **waitUntil** (string) - Optional - When to consider the navigation successful. Options: 'load', 'domcontentloaded', 'networkidle0', 'networkidle2'. Defaults to 'load'. ### Request Example ```json { "pageId": "main", "url": "https://example.com" } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result of the operation. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The textual content, e.g., 'Navigated to https://example.com'. #### Response Example ```json { "content": [ { "type": "text", "text": "Navigated to https://example.com" } ] } ``` ``` -------------------------------- ### Create New Browser Page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Creates a new browser tab with a unique identifier for independent control. Useful for managing multiple concurrent operations. ```javascript // Create a new page with unique identifier await puppeteer_new_page({ pageId: "main" }); ``` ```javascript // Create multiple pages for parallel operations await puppeteer_new_page({ pageId: "login-page" }); await puppeteer_new_page({ pageId: "dashboard-page" }); await puppeteer_new_page({ pageId: "settings-page" }); // Returns: { content: [{ type: 'text', text: 'Page main created successfully' }] } ``` -------------------------------- ### Restart Claude Code Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Restart Claude Code in interactive mode to apply new configurations. ```bash claude --interactive ``` -------------------------------- ### Add Test Element Dynamically with JavaScript Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/test-site/index.html This function creates a new div element, styles it, and appends it to a specified container. It's useful for dynamically adding content to the page, such as test elements for UI testing. The new element displays the time it was added. ```javascript function addTestElement() { const container = document.getElementById('test-elements-container'); const newElement = document.createElement('div'); newElement.className = 'test-element'; newElement.style.cssText = 'margin: 10px 0; padding: 10px; background-color: #e9ecef; border-radius: 4px;'; newElement.innerHTML = `

Test element added at: ${new Date().toLocaleTimeString()}

`; container.appendChild(newElement); } ``` -------------------------------- ### Close Multiple Pages Sequentially Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Demonstrates closing multiple browser tabs sequentially by calling the close_page function for each. ```javascript await puppeteer_close_page({ pageId: "login-page" }); await puppeteer_close_page({ pageId: "temp-page" }); ``` -------------------------------- ### Set Cookies for a Page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Sets one or more cookies for a specified page. Supports standard cookie attributes like domain, path, expiration, and security flags. ```javascript await puppeteer_set_cookies({ pageId: "main", cookies: [ { name: "session_id", value: "abc123xyz", domain: "example.com" } ] }); ``` ```javascript await puppeteer_set_cookies({ pageId: "main", cookies: [ { name: "auth_token", value: "eyJhbGciOiJIUzI1NiIs...", domain: ".example.com", path: "/", expires: Date.now() / 1000 + 86400, // 24 hours from now httpOnly: true, secure: true, sameSite: "Strict" }, { name: "user_preferences", value: JSON.stringify({ theme: "dark", lang: "en" }), domain: "example.com", path: "/", sameSite: "Lax" } ] }); ``` -------------------------------- ### Remove MCP Configuration Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Remove the MCP configuration from the project. ```bash npm run remove-mcp ``` -------------------------------- ### Data Extraction with Puppeteer Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Shows how to extract text from an element and execute custom JavaScript within the browser context. Ensure the browser is launched and the page is navigated before extraction. ```javascript // Extract text from an element await puppeteer_get_text({ pageId: "main", selector: "h1" }); // Execute custom JavaScript await puppeteer_evaluate({ pageId: "main", script: "document.querySelectorAll('a').length" }); ``` -------------------------------- ### Close Browser Instance Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Closes the entire browser instance and all associated pages, cleaning up all resources. ```javascript await puppeteer_close_browser({}); ``` -------------------------------- ### Uninstall puppeteer-mcp-claude Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/README.md Use this command to remove the puppeteer-mcp-claude server from all your Claude applications. ```bash npx puppeteer-mcp-claude uninstall ``` -------------------------------- ### puppeteer_new_page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Creates a new browser tab (page) with a unique identifier for later reference. Each page maintains its own state and can be controlled independently. ```APIDOC ## puppeteer_new_page ### Description Creates a new browser tab with a unique identifier for later reference. Each page maintains its own state and can be controlled independently. ### Method POST ### Endpoint /puppeteer_new_page ### Parameters #### Request Body - **pageId** (string) - Required - A unique identifier for the new page. ### Request Example ```json { "pageId": "main" } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result of the operation. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The textual content, e.g., 'Page main created successfully'. #### Response Example ```json { "content": [ { "type": "text", "text": "Page main created successfully" } ] } ``` ``` -------------------------------- ### Retrieve Cookies from a Page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Retrieves cookies from a specified page. Can fetch all cookies for the current page or filter by specific URLs. ```javascript await puppeteer_get_cookies({ pageId: "main" }); ``` ```javascript await puppeteer_get_cookies({ pageId: "main", urls: [ "https://example.com", "https://api.example.com" ] }); ``` -------------------------------- ### Show Dynamic Content with JavaScript Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/test-site/index.html This function makes a hidden div visible and updates its content with the current time. It's useful for toggling the visibility of elements and displaying real-time data. Ensure the target element has `id='dynamic-content'` and a placeholder for time with `id='current-time'`. ```javascript function showDynamicContent() { const dynamicContent = document.getElementById('dynamic-content'); dynamicContent.style.display = 'block'; document.getElementById('current-time').textContent = new Date().toLocaleTimeString(); } ``` -------------------------------- ### Handle Form Submission with JavaScript Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/test-site/index.html This script handles the submission of a form, preventing default submission, retrieving input values, and displaying them in a result section. It also resets the form after submission. Use this for client-side form processing. ```javascript document.getElementById('test-form').addEventListener('submit', function(e) { e.preventDefault(); const name = document.getElementById('name').value; const email = document.getElementById('email').value; document.getElementById('result-name').textContent = name; document.getElementById('result-email').textContent = email; document.getElementById('result').style.display = 'block'; // Clear form this.reset(); }); ``` -------------------------------- ### Exit Claude Code Session Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/TESTING.md Use Ctrl+C or type 'exit' to stop the current Claude Code session. ```bash # Press Ctrl+C or type exit ``` -------------------------------- ### Capture Screenshot with Puppeteer Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Captures a screenshot of the browser page. Can capture the visible viewport or the entire scrollable page and save it as a PNG file. If no path is provided, the screenshot is held in memory. ```javascript // Screenshot visible viewport await puppeteer_screenshot({ pageId: "main", path: "/tmp/viewport-screenshot.png" }); ``` ```javascript // Full page screenshot (captures entire scrollable area) await puppeteer_screenshot({ pageId: "main", path: "/tmp/full-page-screenshot.png", fullPage: true }); ``` ```javascript // Screenshot without saving to file (for in-memory use) await puppeteer_screenshot({ pageId: "main" }); ``` ```javascript // Screenshot with specific naming await puppeteer_screenshot({ pageId: "dashboard-page", path: "./screenshots/dashboard-2024-01-15.png", fullPage: false }); ``` -------------------------------- ### Type Text into Element with Puppeteer Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Simulates typing text into an input field or textarea character by character. Use this for filling out forms or entering data into text areas. Ensure the selector targets the correct input or textarea. ```javascript // Type into a text input await puppeteer_type({ pageId: "main", selector: "input[name='username']", text: "john.doe@example.com" }); ``` ```javascript // Type into a password field await puppeteer_type({ pageId: "main", selector: "input[type='password']", text: "secretPassword123" }); ``` ```javascript // Type into a search box await puppeteer_type({ pageId: "main", selector: "#search-input", text: "puppeteer automation" }); ``` ```javascript // Type into a textarea await puppeteer_type({ pageId: "main", selector: "textarea.comment-box", text: "This is a multi-line\ncomment with special chars: @#$%" }); ``` -------------------------------- ### Delayed Element Appearance with JavaScript Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/test-site/index.html This script uses `setTimeout` to add a new div element to the page after a 2-second delay. This is ideal for testing scenarios where elements appear asynchronously, such as with `waitForSelector` in Puppeteer. ```javascript setTimeout(function() { const delayedElement = document.createElement('div'); delayedElement.id = 'delayed-element'; delayedElement.style.cssText = 'margin: 20px 0; padding: 15px; background-color: #cce5ff; border-radius: 4px;'; delayedElement.innerHTML = '

This element appeared after 2 seconds - perfect for testing waitForSelector!

'; document.querySelector('.container').appendChild(delayedElement); }, 2000); ``` -------------------------------- ### puppeteer_close_browser Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Closes the entire browser instance and all associated pages. Cleans up all resources. ```APIDOC ## puppeteer_close_browser ### Description Closes the entire browser instance and all associated pages. Cleans up all resources. ### Method Not specified, assumed to be a function call. ### Endpoint Not applicable, this is a function call. ### Parameters This endpoint does not require any parameters. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result message. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The result message, e.g., 'Browser closed'. #### Response Example ```json { "content": [ { "type": "text", "text": "Browser closed" } ] } ``` ``` -------------------------------- ### Evaluate JavaScript in Browser Context with Puppeteer Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Executes arbitrary JavaScript code within the browser's execution context. Returns the result of the script, which can be any JSON-serializable value. Useful for complex DOM manipulations, data extraction, or triggering client-side logic. ```javascript // Get the page title await puppeteer_evaluate({ pageId: "main", script: "document.title" }); ``` ```javascript // Count elements on the page await puppeteer_evaluate({ pageId: "main", script: "document.querySelectorAll('a').length" }); ``` ```javascript // Get all link URLs await puppeteer_evaluate({ pageId: "main", script: "Array.from(document.querySelectorAll('a')).map(a => a.href)" }); ``` ```javascript // Scroll to bottom of page await puppeteer_evaluate({ pageId: "main", script: "window.scrollTo(0, document.body.scrollHeight)" }); ``` ```javascript // Get localStorage data await puppeteer_evaluate({ pageId: "main", script: "JSON.parse(localStorage.getItem('userData'))" }); ``` ```javascript // Modify DOM elements await puppeteer_evaluate({ pageId: "main", script: "document.querySelector('#hidden-field').value = 'new-value'" }); ``` ```javascript // Get computed styles await puppeteer_evaluate({ pageId: "main", script: "getComputedStyle(document.querySelector('.button')).backgroundColor" }); ``` -------------------------------- ### Close a Specific Page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Closes a specific browser tab identified by its pageId and removes it from the managed pages. ```javascript await puppeteer_close_page({ pageId: "main" }); ``` -------------------------------- ### Click Element with Puppeteer Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Clicks on an element identified by a CSS selector. The element must be visible and interactable. Use this for simulating user clicks on buttons, links, or other interactive elements. ```javascript // Click a button by ID await puppeteer_click({ pageId: "main", selector: "#submit-button" }); ``` ```javascript // Click a link by class await puppeteer_click({ pageId: "main", selector: ".nav-link.active" }); ``` ```javascript // Click by data attribute await puppeteer_click({ pageId: "main", selector: "[data-testid='login-btn']" }); ``` ```javascript // Click a specific list item await puppeteer_click({ pageId: "main", selector: "ul.menu > li:nth-child(3) > a" }); ``` -------------------------------- ### puppeteer_set_cookies Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Sets one or more cookies for a page. Supports all standard cookie attributes including domain, path, expiration, and security flags. ```APIDOC ## puppeteer_set_cookies ### Description Sets one or more cookies for a page. Supports all standard cookie attributes including domain, path, expiration, and security flags. ### Method Not specified, assumed to be a function call. ### Endpoint Not applicable, this is a function call. ### Parameters #### Request Body - **pageId** (string) - Required - Identifier for the page. - **cookies** (array) - Required - An array of cookie objects to set. - **name** (string) - Required - The name of the cookie. - **value** (string) - Required - The value of the cookie. - **domain** (string) - Optional - The domain for which the cookie is set. - **path** (string) - Optional - The path for which the cookie is set. - **expires** (number) - Optional - The expiration date of the cookie as a Unix timestamp. - **httpOnly** (boolean) - Optional - Whether the cookie is HTTP only. - **secure** (boolean) - Optional - Whether the cookie is secure. - **sameSite** (string) - Optional - The SameSite attribute for the cookie ('Strict', 'Lax', 'None'). ### Request Example ```json { "pageId": "main", "cookies": [ { "name": "session_id", "value": "abc123xyz", "domain": "example.com" } ] } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result message. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The result message, e.g., 'Set 2 cookie(s) for page main'. #### Response Example ```json { "content": [ { "type": "text", "text": "Set 2 cookie(s) for page main" } ] } ``` ``` -------------------------------- ### puppeteer_close_page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Closes a specific browser tab and removes it from the managed pages. ```APIDOC ## puppeteer_close_page ### Description Closes a specific browser tab and removes it from the managed pages. ### Method Not specified, assumed to be a function call. ### Endpoint Not applicable, this is a function call. ### Parameters #### Request Body - **pageId** (string) - Required - Identifier for the page to close. ### Request Example ```json { "pageId": "main" } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result message. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The result message, e.g., 'Page main closed'. #### Response Example ```json { "content": [ { "type": "text", "text": "Page main closed" } ] } ``` ``` -------------------------------- ### Delete Cookies from a Page Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Deletes specified cookies from a page. Cookies can be identified by name, and optionally filtered by domain and path. ```javascript await puppeteer_delete_cookies({ pageId: "main", cookies: [ { name: "session_id" } ] }); ``` ```javascript await puppeteer_delete_cookies({ pageId: "main", cookies: [ { name: "auth_token", domain: ".example.com", path: "/" }, { name: "tracking_id", domain: "analytics.example.com" } ] }); ``` -------------------------------- ### Wait for Selector with Puppeteer Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Waits for an element matching the specified CSS selector to appear in the DOM. This is crucial for handling dynamically loaded content or elements that appear after asynchronous operations. Supports custom timeouts. ```javascript // Wait for element with default timeout (30 seconds) await puppeteer_wait_for_selector({ pageId: "main", selector: ".loading-complete" }); ``` ```javascript // Wait with custom timeout (5 seconds) await puppeteer_wait_for_selector({ pageId: "main", selector: "#dynamic-content", timeout: 5000 }); ``` ```javascript // Wait for modal to appear await puppeteer_wait_for_selector({ pageId: "main", selector: ".modal.visible", timeout: 10000 }); ``` ```javascript // Wait for search results await puppeteer_wait_for_selector({ pageId: "main", selector: ".search-results li", timeout: 15000 }); ``` -------------------------------- ### Change Page Title with JavaScript Source: https://github.com/jaenster/puppeteer-mcp-claude/blob/main/test-site/index.html This function modifies the browser tab's title and displays an alert. It's useful for testing dynamic title updates and user notifications. The new title includes a timestamp. ```javascript function changeTitle() { document.title = 'Title Changed by Puppeteer Test - ' + new Date().toLocaleTimeString(); alert('Page title changed!'); } ``` -------------------------------- ### puppeteer_set_request_interception Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Enables request interception to block specific resource types or modify request headers. Useful for performance optimization and testing. ```APIDOC ## puppeteer_set_request_interception ### Description Enables request interception to block specific resource types or modify request headers. Useful for performance optimization and testing. ### Method Not specified, assumed to be a function call. ### Endpoint Not applicable, this is a function call. ### Parameters #### Request Body - **pageId** (string) - Required - Identifier for the page. - **enable** (boolean) - Required - Whether to enable or disable request interception. - **blockResources** (array) - Optional - An array of resource types to block (e.g., 'image', 'font', 'stylesheet', 'media'). - **modifyHeaders** (object) - Optional - An object containing headers to add or modify for all requests. - **header-name** (string) - The value of the header. ### Request Example ```json { "pageId": "main", "enable": true, "blockResources": ["image", "font", "stylesheet"], "modifyHeaders": { "User-Agent": "CustomBot/1.0" } } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result message. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The result message, e.g., 'Request interception enabled for page main'. #### Response Example ```json { "content": [ { "type": "text", "text": "Request interception enabled for page main" } ] } ``` ``` -------------------------------- ### puppeteer_delete_cookies Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Deletes specified cookies from a page by name, optionally filtered by domain and path. ```APIDOC ## puppeteer_delete_cookies ### Description Deletes specified cookies from a page by name, optionally filtered by domain and path. ### Method Not specified, assumed to be a function call. ### Endpoint Not applicable, this is a function call. ### Parameters #### Request Body - **pageId** (string) - Required - Identifier for the page. - **cookies** (array) - Required - An array of cookie objects specifying which cookies to delete. - **name** (string) - Required - The name of the cookie to delete. - **domain** (string) - Optional - The domain of the cookie to delete. - **path** (string) - Optional - The path of the cookie to delete. ### Request Example ```json { "pageId": "main", "cookies": [ { "name": "session_id" } ] } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the result message. - **type** (string) - The type of content, e.g., 'text'. - **text** (string) - The result message, e.g., 'Deleted 2 cookie(s) from page main'. #### Response Example ```json { "content": [ { "type": "text", "text": "Deleted 2 cookie(s) from page main" } ] } ``` ``` -------------------------------- ### Set Request Interception Source: https://context7.com/jaenster/puppeteer-mcp-claude/llms.txt Enables or disables request interception for a page. Can be used to block specific resource types, modify request headers, or block all media and tracking resources. ```javascript await puppeteer_set_request_interception({ pageId: "main", enable: true, blockResources: ["image", "font", "stylesheet"] }); ``` ```javascript await puppeteer_set_request_interception({ pageId: "main", enable: true, blockResources: ["image", "media", "font"] }); ``` ```javascript await puppeteer_set_request_interception({ pageId: "main", enable: true, modifyHeaders: { "X-Custom-Header": "custom-value", "Authorization": "Bearer token123", "Accept-Language": "en-US,en;q=0.9" } }); ``` ```javascript await puppeteer_set_request_interception({ pageId: "main", enable: true, blockResources: ["image", "stylesheet", "font"], modifyHeaders: { "User-Agent": "CustomBot/1.0" } }); ``` ```javascript await puppeteer_set_request_interception({ pageId: "main", enable: false }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.