Playwright CDP工具
正文语言类型为英语。 翻译结果:通过支持 Chrome DevTools 协议的 Playwright 框架,使大型语言模型(LLM)能够执行浏览器自动化操作,可以连接到现有的 Chrome 实例以进行高级网络交互和 JavaScript 执行。
服务介绍
MCP Playwright CDP
这是一个使用 Playwright 并支持 Chrome DevTools Protocol (CDP) 的 Model Context Protocol 服务器。该服务器使 LLMs 能够与网页交互、截屏,并在真实的浏览器环境中执行 JavaScript,同时能够通过 CDP 连接到现有的 Chrome 实例。
这是 executeautomation/mcp-playwright v0.2.7 的一个分支,增强了对连接到正在运行的 Chrome 实例的 CDP 支持。
主要功能
- 🔗 通过 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 实例的能力。要使用此功能:
- 启用远程调试启动 Chrome:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
- 服务器会先尝试自动连接到正在运行的 Chrome 实例,然后再启动新的浏览器。
致谢
该项目是 executeautomation/mcp-playwright 的一个分支,增强了对连接到正在运行的 Chrome 实例的 CDP 支持。
许可证
本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。