Skip to main content
Glama
Patchright Lite MCP Server

Patchright Lite MCP Server

by dylangroos

Patchright Lite MCP 服务器

精简的模型上下文协议 (MCP) 服务器,封装了 Patchright Node.js SDK,为 AI 模型提供隐秘的浏览器自动化功能。这款轻量级服务器专注于核心功能,方便更简单的 AI 模型使用。

Patchright 是什么?

Patchright 是 Playwright 测试和自动化框架的隐蔽版本。它旨在作为 Playwright 的直接替代品,但具备先进的隐蔽功能,可以规避反机器人系统的检测。Patchright 可以修补各种检测技术,包括:

  • Runtime.enable 泄漏

  • Console.enable 泄漏

  • 命令标志泄漏

  • 通用检测点

  • 封闭的影子根交互

该 MCP 服务器包装了 Patchright 的 Node.js 版本,以便通过简单、标准化的协议将其功能提供给 AI 模型。

Related MCP server: Puppeteer-Extra MCP Server

特征

  • 简洁的界面:仅使用 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

Available Tools

4 tools
browseB

Browse to a URL and return the page title and visible text

Inputs: url (required), headless, waitFor.

closeC

Close browser to free resources

Inputs: browserId (required).

extractC

Extract information from the current page as text, html, or screenshot

Inputs: browserId (required), pageId (required), type (required).

interactC

Perform simple interactions on a page

Inputs: browserId (required), pageId (required), action (required), selector (required), +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 4 tools

    Disambiguation4/5

    The tools have mostly distinct purposes with clear boundaries: browse for navigation, extract for content retrieval, interact for actions, and close for cleanup. However, 'extract' and 'interact' could potentially overlap in some use cases (e.g., extracting after an interaction), but their descriptions help differentiate them.

    Naming Consistency5/5

    All tool names follow a consistent, simple verb-based pattern (browse, close, extract, interact) without any mixing of conventions. This makes the set predictable and easy to understand at a glance.

    Tool Count5/5

    With 4 tools, this server is well-scoped for its apparent purpose of web browsing and interaction. Each tool serves a clear, essential function, and there are no extraneous or redundant tools, making the count appropriate for the domain.

    Completeness4/5

    The toolset covers the core web browsing lifecycle: navigate (browse), retrieve content (extract), perform actions (interact), and clean up (close). A minor gap is the lack of explicit tools for handling multiple tabs or sessions, but agents can likely work around this with the provided tools.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      D
      quality
      D
      maintenance
      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.
      1
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that provides enhanced browser automation capabilities using Puppeteer-Extra with Stealth Plugin, enabling LLMs to interact with web pages in a way that better emulates human behavior and avoids detection as automation.
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI assistants to interact with web pages through browser automation, supporting web scraping, form filling, navigation, and other browser-based tasks using Playwright.
      1
      MIT