
Playwright-Lighthouse MCP Server

2025.03.12
1
TypeScript网站性能分析自动化测试浏览器自动化开发效率
Playwright-Lighthouse MCP Server 是一个基于 Playwright 和 Lighthouse 的 MCP 服务器,用于分析网站性能。通过 Model Context Protocol (MCP),LLMs 可以执行网站性能分析。该服务器提供 Lighthouse 性能分析和截图捕获功能,适用于需要自动化网站性能测试和优化的场景。
View on GitHub
Overview
基本能力
产品定位
Playwright-Lighthouse MCP Server 是一个用于网站性能分析的 MCP 服务器,通过 Playwright 和 Lighthouse 提供自动化性能测试和截图功能。
核心功能
- 使用 Lighthouse 进行性能分析
- 截图捕获
适用场景
- 网站性能优化
- 自动化测试
- 开发过程中的性能监控
工具列表
- run-lighthouse: 在当前打开的页面上运行 Lighthouse 性能分析。
- 参数:
url
: 要分析的网站 URLcategories
: 要分析的类别数组(默认: ["performance"])- 可用类别: "performance", "accessibility", "best-practices", "seo", "pwa"
maxItems
: 每个类别显示的最大改进项数(默认: 3, 最大: 5)
- take-screenshot: 捕获当前打开页面的截图。
- 参数:
url
: 要捕获的网站 URLfullPage
: 如果为 true,捕获整个页面的截图(默认: false)
常见问题解答
无
使用教程
使用依赖
- Node.js 18 或更高版本
- npm
安装教程
# 克隆仓库
git clone https://github.com/kbyk004/playwright-lighthouse-mcp.git
cd playwright-lighthouse-mcp
# 安装依赖
npm install
npx playwright install
# 构建
npm run build
调试方式
npm run inspector
与 MCP 客户端集成
该服务器设计用于支持 Model Context Protocol (MCP) 的客户端。例如,可以与 Claude for Desktop 集成。
Claude for Desktop 配置示例
将以下内容添加到 Claude for Desktop 配置文件 (~/Library/Application Support/Claude/claude_desktop_config.json
):
{
"mcpServers": {
"playwright-lighthouse": {
"command": "node",
"args": [
"/path-to/playwright-lighthouse-mcp/build/index.js"
]
}
}
}