DP

dylangroos/patchright-mcp-lite

浏览器自动化

本页由 AI 翻译,技术细节请以原文为准。 查看原文

26 stars 9 forks 质量 65 趋势 0Apache-2.0

Patchright(Playwright patch)轻量级模型 MCP 服务器

概览

一个简化的模型上下文协议(MCP)服务器,包裹了 Patchright Node.js SDK 为 AI 模型提供隐形浏览器自动化功能。这款轻量级服务器专注于关键功能,使更简单的 AI 模型更容易使用。 Patchright 是 Playwright 测试与自动化框架的未被检测版本。它被设计为 Playwright 的可直接替代,但具备先进的隐身能力,以避免被反机器人系统检测。Patchright 为多种检测技术提供补丁,包括: - Runtime.enable 泄漏 - Console.enable 泄漏 - 命令标志泄漏 - 一般检测点 - 闭合影子根交互 该MCP服务器包裹了Patchright的第Node.js版本,通过简单、标准化的协议向AI模型开放其功能。

概述(AI 翻译)

一个简化的模型上下文协议(MCP)服务器,包裹了 Patchright Node.js SDK 为 AI 模型提供隐形浏览器自动化功能。这款轻量级服务器专注于关键功能,使更简单的 AI 模型更容易使用。

什么是Patchright?

Patchright 是 Playwright 测试与自动化框架的未被检测版本。它被设计为 Playwright 的可直接替代,但具备先进的隐身能力,以避免被反机器人系统检测。Patchright 为多种检测技术提供补丁,包括:

  • Runtime.enable 泄漏
  • Console.enable 泄漏
  • 命令标志泄露
  • 一般检测点
  • 闭合影子根相互作用

该MCP服务器包裹了Patchright的第Node.js版本,通过简单、标准化的协议向AI模型开放其功能。

特色

  • 简单界面:专注于核心功能,仅有4个基本工具
  • 隐身自动化:使用Patchright的隐形模式以避免被发现
  • MCP 标准:实现模型上下文协议,便于 AI 集成
  • Stdio Transport:使用标准输入/输出实现无缝集成

先修条件

  • 节点。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 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
    
  4. Install Chromium-Driver for Pathright:

    npx patchright install chromium
    

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
}
在 GitHub 查看完整 README

安装

npx patchright install chromium
新手?先看 mcpskill.org 教程 →

配置

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