Patchright Lite MCP Server

Integrations

  • Provides a containerized version of the Patchright MCP server, accessible through Docker Hub for easy deployment and integration with AI tools

  • Allows GitHub Copilot to leverage Patchright's stealth browser automation capabilities through VS Code, enabling undetected web scraping and interaction

Patchright Lite MCP 服务器

精简的模型上下文协议 (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 :使用标准输入/输出实现无缝集成

先决条件

  • Node.js 18+
  • npm 或 yarn

安装

  1. 克隆此存储库:
    git clone https://github.com/yourusername/patchright-lite-mcp-server.git cd patchright-lite-mcp-server
  2. 安装依赖项:
    npm install
  3. 构建 TypeScript 代码:
    npm run build

用法

使用以下命令运行服务器:

npm start

这将使用 stdio 传输启动服务器,使其准备好与支持 MCP 的 AI 工具集成。

与人工智能模型集成

克劳德桌面

将其添加到您的claude-desktop-config.json文件中:

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

VS Code 与 GitHub Copilot

使用 VS Code CLI 添加 MCP 服务器:

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

可用工具

该服务器仅提供 4 个基本工具:

1. 浏览

启动浏览器,导航到 URL,并提取内容。

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

返回:

  • 页面标题
  • 可见文本预览
  • 浏览器ID(用于后续操作)
  • 页面ID(用于后续操作)
  • 截图路径

2. 互动

在页面上执行简单的交互。

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 }

返回:

  • 操作结果
  • 当前网址
  • 截图路径

3. 提取

从当前页面提取特定内容。

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

返回:

  • 根据请求类型提取内容

4. 关闭

关闭浏览器以释放资源。

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

使用流程示例

  1. 启动浏览器并导航到站点:
    Tool: browse Parameters: { "url": "https://example.com/login", "headless": false }
  2. 填写登录表格:
    Tool: interact Parameters: { "browserId": "browser-id-from-step-1", "pageId": "page-id-from-step-1", "action": "fill", "selector": "#username", "value": "user@example.com" }
  3. 填写密码:
    Tool: interact Parameters: { "browserId": "browser-id-from-step-1", "pageId": "page-id-from-step-1", "action": "fill", "selector": "#password", "value": "password123" }
  4. 点击登录按钮:
    Tool: interact Parameters: { "browserId": "browser-id-from-step-1", "pageId": "page-id-from-step-1", "action": "click", "selector": "#login-button" }
  5. 提取文本以验证登录:
    Tool: extract Parameters: { "browserId": "browser-id-from-step-1", "pageId": "page-id-from-step-1", "type": "text" }
  6. 关闭浏览器:
    Tool: close Parameters: { "browserId": "browser-id-from-step-1" }

安全注意事项

  • 此服务器提供强大的自动化功能。请以负责任且合乎道德的方式使用它。
  • 避免自动执行违反网站服务条款的操作。
  • 注意速率限制,不要使网站请求过载。

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

致谢

  • Kaliiiiiiiiii-Vinyzu 的 Patchright-nodejs
  • 模型上下文协议(modelcontextprotocol)

Docker 使用

您可以使用 Docker 运行此服务器:

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

在本地构建 Docker 镜像

构建 Docker 镜像:

docker build -t patchright-mcp .

运行容器:

docker run -it --rm patchright-mcp

Docker 中心

当更改合并到主分支时,镜像会自动发布到 Docker Hub。您可以在以下位置找到最新镜像: dylangroos/patchright-mcp

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

简化的模型上下文协议服务器,使 AI 模型能够使用 Patchright 执行隐形浏览器自动化,避免被反机器人系统检测,同时提供必要的 Web 交互功能。

  1. Patchright 是什么?
    1. 特征
      1. 先决条件
        1. 安装
          1. 用法
            1. 与人工智能模型集成
              1. 克劳德桌面
              2. VS Code 与 GitHub Copilot
            2. 可用工具
              1. 1. 浏览
              2. 2. 互动
              3. 3. 提取
              4. 4. 关闭
            3. 使用流程示例
              1. 安全注意事项
                1. 执照
                  1. 致谢
                    1. Docker 使用
                      1. 在本地构建 Docker 镜像
                      2. Docker 中心

                    Related MCP Servers

                    • -
                      security
                      A
                      license
                      -
                      quality
                      A Model Context Protocol server that enables Claude and other LLMs to make HTTP requests with realistic browser fingerprinting, bypassing common anti-bot measures and interacting with websites more naturally.
                      Last updated -
                      3
                      Python
                      MIT License
                      • Linux
                      • Apple
                    • -
                      security
                      F
                      license
                      -
                      quality
                      A web browser automation server that allows AI assistants to control Chrome with persistent state management, enabling complex browsing tasks through asynchronous browser operations.
                      Last updated -
                      1
                      Python
                      • Apple
                    • -
                      security
                      A
                      license
                      -
                      quality
                      AI-driven browser automation server that implements the Model Context Protocol to enable natural language control of web browsers for tasks like navigation, form filling, and visual interaction.
                      Last updated -
                      1
                      Python
                      MIT License
                      • Apple
                    • -
                      security
                      -
                      license
                      -
                      quality
                      A Model Context Protocol server that enables AI assistants to control Chrome browsers through the Chrome DevTools Protocol, allowing for navigation, clicking, typing, and extracting page information.
                      Last updated -
                      3
                      TypeScript

                    View all related MCP servers

                    ID: drc72bkluy