Patchright Lite MCP Server

Patchright Lite MCP Server

A streamlined Model Context Protocol server that enables AI models to perform stealth browser automation using Patchright, avoiding detection by anti-bot systems while providing essential web interaction capabilities.

Category
访问服务器

README

Patchright Lite MCP Server

A streamlined Model Context Protocol (MCP) server that wraps the Patchright Node.js SDK to provide stealth browser automation capabilities to AI models. This lightweight server focuses on essential functionality to make it easier for simpler AI models to use.

What is Patchright?

Patchright is an undetected version of the Playwright testing and automation framework. It's designed as a drop-in replacement for Playwright, but with advanced stealth capabilities to avoid detection by anti-bot systems. Patchright patches various detection techniques including:

  • Runtime.enable leak
  • Console.enable leak
  • Command flags leaks
  • General detection points
  • Closed Shadow Root interactions

This MCP server wraps the Node.js version of Patchright to make its capabilities available to AI models through a simple, standardized protocol.

Features

  • Simple Interface: Focused on core functionality with just 4 essential tools
  • Stealth Automation: Uses Patchright's stealth mode to avoid detection
  • MCP Standard: Implements the Model Context Protocol for easy AI integration
  • Stdio Transport: Uses standard input/output for seamless integration

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

  1. Clone this 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
    

Usage

Run the server with:

npm start

This will start the server with stdio transport, making it ready to integrate with AI tools that support MCP.

Integrating with AI Models

Claude Desktop

Add this 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

Use the VS Code CLI to add the MCP server:

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

Available Tools

The server provides just 4 essential tools:

1. 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

2. 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

3. 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

4. close

Closes a browser to free resources.

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

Example Usage Flow

  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": "user@example.com"
    }
    
  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

  • This server provides powerful automation capabilities. Use it responsibly and ethically.
  • Avoid automating actions that would violate websites' terms of service.
  • Be mindful of rate limits and don't overload websites with requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Patchright-nodejs by Kaliiiiiiiiii-Vinyzu
  • Model Context Protocol by modelcontextprotocol

Docker Usage

You can run this server using Docker:

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

Building the Docker Image Locally

Build the Docker image:

docker build -t patchright-mcp .

Run the container:

docker run -it --rm patchright-mcp

Docker Hub

The image is automatically published to Docker Hub when changes are merged to the main branch. You can find the latest image at: dylangroos/patchright-mcp

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选