Back to MCP directory
publicPublicdnsLocal runtime

Playwright CDP

一个基于Playwright的MCP服务器,支持通过CDP连接现有Chrome实例,提供浏览器自动化能力。

article

README

🚀 MCP Playwright CDP

MCP Playwright CDP是一个提供浏览器自动化功能的模型上下文协议(MCP)服务器,它借助Playwright并支持Chrome DevTools Protocol (CDP)。该服务器能让LLM在真实浏览器环境中与网页交互、截取屏幕截图,还能在浏览器上下文中执行JavaScript,同时支持通过CDP连接到运行中的Chrome实例。

smithery badge License: MIT

🚀 快速开始

此项目是executeautomation/mcp-playwright v0.2.7的分支版本,增强了通过CDP连接到运行中的Chrome实例的功能。

✨ 主要特性

  • 🔗 通过CDP连接到现有Chrome实例
  • 🌐 完整的浏览器自动化能力
  • 📸 截取整个页面或特定元素的屏幕截图
  • 🖱️ 全面的网页交互(导航、点击、表单填写)
  • 📊 控制台日志监控
  • 🔧 浏览器上下文中执行JavaScript
  • 🌍 支持HTTP API测试

📦 安装指南

使用npm或Smithery均可安装:

使用Smithery自动安装

通过Smithery为Claude Desktop自动安装MCP Playwright CDP:

npx -y @smithery/cli install @lars-hagen/mcp-playwright-cdp --client claude

手动安装

使用npm:

npm install

📚 详细文档

配置

将以下内容添加到Claude Desktop配置文件中:

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

请将/path/to/mcp-playwright替换为您实际的仓库路径。

CDP连接

此分支增加了通过CDP连接到运行中的Chrome实例的功能。使用方法如下:

  1. 启动Chrome并启用远程调试:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
  1. 服务器将自动尝试首先连接到正在运行的Chrome实例,然后再启动新的浏览器。

致谢

该项目基于executeautomation/mcp-playwright fork,并增强了通过CDP连接到运行中的Chrome实例的功能。

📄 许可证

本项目采用MIT许可证 - 查看LICENSE文件获取详细信息。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client