Patchright Stealth Browser MCP server

Provides stealth browser automation capabilities through a containerized server that avoids anti-bot detection systems while offering essential tools for navigating websites, interacting with elements, and extracting content.
Back to servers
Setup instructions
Provider
Dylan Groos
Release date
May 06, 2025
Language
JavaScript
Stats
5 stars

Patchright Lite MCP Server is a streamlined implementation of the Model Context Protocol that provides stealth browser automation capabilities to AI models. It wraps the Patchright Node.js SDK, which offers undetected browser automation designed to avoid anti-bot detection systems while providing a simple interface for AI integration.

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/patchright-lite-mcp-server.git
    cd patchright-lite-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Build the TypeScript code:

    npm run build
    
  4. Install Chromium-Driver for Pathright:

    npx patchright install chromium
    

Running the Server

Start the server with:

npm start

This will launch the MCP server using stdio transport, ready to integrate with AI tools that support MCP.

Integrating with AI Models

Claude Desktop

Add this configuration to your claude-desktop-config.json file:

{
  "mcpServers": {
    "patchright": {
      "command": "node",
      "args": ["path/to/patchright-lite-mcp-server/dist/index.js"]
    }
  }
}

VS Code with GitHub Copilot

Configure the MCP server in VS Code using this command:

code --add-mcp '{"name":"patchright","command":"node","args":["path/to/patchright-lite-mcp-server/dist/index.js"]}'

Docker Usage

Run the server using the pre-built Docker image:

docker run -it --rm dylangroos/patchright-mcp

Building the Docker Image Locally

docker build -t patchright-mcp .
docker run -it --rm patchright-mcp

Available Tools

The server provides four essential tools for browser automation:

browse

Launches a browser, navigates to a URL, and extracts content.

Tool: browse
Parameters: {
  "url": "https://example.com",
  "headless": true,
  "waitFor": 1000
}

Returns:

  • Page title
  • Visible text preview
  • Browser ID (for subsequent operations)
  • Page ID (for subsequent operations)
  • Screenshot path

interact

Performs a simple interaction on a page.

Tool: interact
Parameters: {
  "browserId": "browser-id-from-browse",
  "pageId": "page-id-from-browse",
  "action": "click", // can be "click", "fill", or "select"
  "selector": "#submit-button",
  "value": "Hello World" // only needed for fill and select
}

Returns:

  • Action result
  • Current URL
  • Screenshot path

extract

Extracts specific content from the current page.

Tool: extract
Parameters: {
  "browserId": "browser-id-from-browse",
  "pageId": "page-id-from-browse",
  "type": "text" // can be "text", "html", or "screenshot"
}

Returns:

  • Extracted content based on the requested type

close

Closes a browser to free resources.

Tool: close
Parameters: {
  "browserId": "browser-id-from-browse"
}

Example Usage Flow

Here's a complete workflow demonstrating how to use the tools in sequence:

  1. Launch a browser and navigate to a site:

    Tool: browse
    Parameters: {
      "url": "https://example.com/login",
      "headless": false
    }
    
  2. Fill in a login form:

    Tool: interact
    Parameters: {
      "browserId": "browser-id-from-step-1",
      "pageId": "page-id-from-step-1",
      "action": "fill",
      "selector": "#username",
      "value": "[email protected]"
    }
    
  3. Fill in password:

    Tool: interact
    Parameters: {
      "browserId": "browser-id-from-step-1",
      "pageId": "page-id-from-step-1",
      "action": "fill",
      "selector": "#password",
      "value": "password123"
    }
    
  4. Click the login button:

    Tool: interact
    Parameters: {
      "browserId": "browser-id-from-step-1",
      "pageId": "page-id-from-step-1",
      "action": "click",
      "selector": "#login-button"
    }
    
  5. Extract text to verify login:

    Tool: extract
    Parameters: {
      "browserId": "browser-id-from-step-1",
      "pageId": "page-id-from-step-1",
      "type": "text"
    }
    
  6. Close the browser:

    Tool: close
    Parameters: {
      "browserId": "browser-id-from-step-1"
    }
    

Security Considerations

  • Use this automation tool responsibly and ethically
  • Avoid actions that violate websites' terms of service
  • Be mindful of rate limits to avoid overloading websites

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "patchright" '{"command":"node","args":["path/to/patchright-lite-mcp-server/dist/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "patchright": {
            "command": "node",
            "args": [
                "path/to/patchright-lite-mcp-server/dist/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "patchright": {
            "command": "node",
            "args": [
                "path/to/patchright-lite-mcp-server/dist/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later