这是一个使用 Google Lighthouse 提供全面网络性能审计和分析能力的 Model Context Protocol (MCP) 服务器。此服务器使 LLM 和 AI 代理能够执行详细的网站性能评估、可访问性审核、SEO 分析、安全检查以及核心网络指标监控。
<a href="https://glama.ai/mcp/servers/@danielsogl/lighthouse-mcp-server"> <img width="380" height="200" src="https://gips1.baidu.com/it/u=129513817,2590941492&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Lighthouse MCP 服务器" /> </a>使用以下配置之一安装 Lighthouse MCP 服务器:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}
您也可以通过 VS Code 命令行安装 Lighthouse MCP 服务器:
# 对于 VS Code
code --add-mcp '{"name":"lighthouse","command":"npx","args":["-y","@danielsogl/lighthouse-mcp@latest"]}'
# 对于 VS Code Insiders
code-insiders --add-mcp '{"name":"lighthouse","command":"npx","args":["-y","@danielsogl/lighthouse-mcp@latest"]}'
安装后,Lighthouse MCP 服务器将在 VS Code 中与您的 GitHub Copilot 代理一起使用。
</details>转到 Cursor 设置 → MCP → 添加新 MCP 服务器。命名为 "lighthouse",使用 command 类型并设置命令 npx @danielsogl/lighthouse-mcp@latest:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}
</details>
遵循 Windsurf MCP 文档。使用以下配置:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}
</details>
遵循 MCP 安装 指南,使用以下配置:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}
</details>
Lighthouse MCP 服务器提供了以下工具进行全面的网络分析:
| 工具 | 描述 | 参数 |
|---|---|---|
run_audit | 运行完整的 Lighthouse 审核 | url, categories?, device?, throttling? |
get_accessibility_score | 获取可访问性评分和建议 | url, device?, includeDetails? |
get_seo_analysis | 获取 SEO 分析和建议 | url, device?, includeDetails? |
check_pwa_readiness | 检查渐进式 Web 应用程序准备情况 | url, device?, includeDetails? |
| 工具 | 描述 | 参数 |
|---|---|---|
get_performance_score | 获取整体性能评分 | url, device? |
get_core_web_vitals | 获取核心网络指标数据 | url, device?, includeDetails?, threshold? |
compare_mobile_desktop | 比较设备之间的性能 | url, categories?, throttling?, includeDetails? |
check_performance_budget | 检查性能预算 | url, device?, budget |
get_lcp_opportunities | 查找 LCP 优化机会 | url, device?, includeDetails?, threshold? |
| 工具 | 描述 | 参数 |
|---|---|---|
find_unused_javascript | 查找未使用的 JavaScript 代码 | url, device?, minBytes?, includeSourceMaps? |
analyze_resources | 分析所有网站资源 | url, device?, resourceTypes?, minSize? |
| 工具 | 描述 | 参数 |
|---|---|---|
get_security_audit | 执行全面的安全审核 | url, device?, checks? |
Lighthouse MCP 服务器包括可重用的提示,帮助 LLM 提供结构化的分析和建议:
| 提示 | 描述 | 参数 |
|---|---|---|
analyze-audit-results | 分析 Lighthouse 审核结果 | auditResults, focusArea? |
compare-audits | 比较前后审核结果 | beforeAudit, afterAudit, changesImplemented? |
optimize-core-web-vitals | 获取核心网络指标优化建议 | coreWebVitals, framework?, constraints? |
optimize-resources | 获取资源优化建议 | resourceAnalysis, loadingStrategy?, criticalUserJourneys? |
Lighthouse MCP 服务器提供了内置的参考资源,包含重要的指南和最佳实践:
| 资源 | 描述 | URI |
|---|---|---|
core-web-vitals-thresholds | 核心网络指标性能阈值 | lighthouse://performance/core-web-vitals-thresholds |
optimization-techniques | 性能优化技术和影响 | lighthouse://performance/optimization-techniques |
wcag-guidelines | WCAG 2.1 可访问性指南和问题 | lighthouse://accessibility/wcag-guidelines |
seo-best-practices | SEO 最佳实践和优化机会 | lighthouse://seo/best-practices |
security-best-practices | 网络安全最佳实践和漏洞 | lighthouse://security/best-practices |
budget-guidelines | 按站点类型划分的性能预算推荐 | lighthouse://performance/budget-guidelines |
categories-scoring | Lighthouse 审核类别和评分方法 | lighthouse://audits/categories-scoring |
framework-guides | 框架特定的优化指南 | lighthouse://frameworks/optimization-guides |
| 提示 | 描述 | 参数 |
|---|---|---|
create-performance-plan | 生成全面的性能改进计划 | currentMetrics, targetGoals?, timeframe? |
create-performance-budget | 创建自定义性能预算推荐 | currentMetrics, businessGoals?, userBase? |
seo-recommendations | 生成 SEO 改进推荐 | seoAudit, websiteType?, targetAudience? |
accessibility-guide | 创建可访问性改进指南 | accessibilityAudit, complianceLevel?, userGroups? |
auditResults: 来自 Lighthouse 工具的 JSON 审核结果focusArea: 需要关注的具体类别 ("performance", "accessibility", "seo", "best-practices", "pwa")beforeAudit / afterAudit: 审核前后的 Lighthouse 审核结果changesImplemented: 审核之间实施的变化描述currentMetrics: 当前的性能指标targetGoals: 具体的性能目标或业务目标timeframe: 实施改进的时间线framework: 前端框架或技术栈constraints: 技术或业务约束websiteType: 网站类型(例如,电子商务、博客、企业网站)targetAudience: 目标受众或市场信息complianceLevel: WCAG 合规级别 ("AA" 或 "AAA")userGroups: 需要考虑的特定用户组url (必需): 要分析的网站 URLdevice: 目标设备 ("desktop" 或 "mobile", 默认: "desktop")includeDetails: 是否包含详细的审核信息 (默认: false)throttling: 是否启用网络/CPU 节流 (默认: false)categories: 要审核的 Lighthouse 类别 (["performance", "accessibility", "best-practices", "seo", "pwa"])threshold: 自定义指标阈值(例如,{"lcp": 2.5, "fid": 100, "cls": 0.1})budget: 性能预算限制(例如,{"performanceScore": 90, "largestContentfulPaint": 2500})resourceTypes: 要分析的资源类型 (["images", "javascript", "css", "fonts", "other"])minBytes: 分析的最小文件大小阈值(默认: 2048)checks: 要执行的安全检查 (["https", "mixed-content", "csp", "hsts", "vulnerabilities"])// 获取整体性能评分
{
"tool": "get_performance_score",
"arguments": {
"url": "https://example.com",
"device": "mobile"
}
}
// 检查核心网络指标并使用自定义阈值
{
"tool": "get_core_web_vitals",
"arguments": {
"url": "https://example.com",
"device": "mobile",
"includeDetails": true,
"threshold": {
"lcp": 2.5,
"fid": 100,
"cls": 0.1
}
}
}
// 执行全面的安全审核
{
"tool": "get_security_audit",
"arguments": {
"url": "https://example.com",
"checks": ["https", "csp", "hsts"]
}
}
// 查找优化机会
{
"tool": "analyze_resources",
"arguments": {
"url": "https://example.com",
"resourceTypes": ["images", "javascript"],
"minSize": 1024
}
}
访问内置的指南和最佳实践:
// 获取核心网络指标阈值
{
"resource": {
"uri": "lighthouse://performance/core-web-vitals-thresholds"
}
}
// 访问 WCAG 可访问性指南
{
"resource": {
"uri": "lighthouse://accessibility/wcag-guidelines"
}
}
// 获取框架特定的优化指南
{
"resource": {
"uri": "lighthouse://frameworks/optimization-guides"
}
}
// 分析审核结果并提供针对性建议
{
"prompt": "analyze-audit-results",
"arguments": {
"auditResults": "{...lighthouse 审核 JSON...}",
"focusArea": "performance"
}
}
// 创建性能改进计划
{
"