返回市场
灯塔-MCP服务器

灯塔-MCP服务器

作者:danielsogl27 星标更新:2025-11-24

项目介绍

Lighthouse MCP Server

NPM 版本 许可证: MIT Node 版本 CI 覆盖率 赞助

这是一个使用 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 审核,包括核心网络指标、性能评分和优化建议
  • ♿ 可访问性审核: WCAG 合规性检查和可访问性评分分析
  • 🔍 SEO 分析: 搜索引擎优化审核和最佳实践建议
  • 🔒 安全评估: HTTPS、CSP 和安全漏洞扫描
  • 📊 资源分析: JavaScript、CSS、图像和字体优化机会
  • 📱 移动与桌面: 设备之间的比较分析,带有节流选项
  • ⚡ 核心网络指标: LCP、FID、CLS 监控及阈值检查
  • 🎯 性能预算: 自定义性能阈值和预算监控
  • 📚 参考资源: 内置的关于网页性能、可访问性、SEO 和安全的最佳实践指南

🛠️ 需求

  • Node.js 22.0.0 或更高版本
  • Chrome/Chromium 浏览器(由 Lighthouse 自动管理)
  • VS Code、Cursor、Windsurf、Claude Desktop 或其他任何 MCP 客户端

🚀 快速开始

使用以下配置之一安装 Lighthouse MCP 服务器:

{
  "mcpServers": {
    "lighthouse": {
      "command": "npx",
      "args": ["@danielsogl/lighthouse-mcp@latest"]
    }
  }
}

在 VS Code 中安装

<img src="https://img.shields.io/badge/VS_Code-安装服务器-0078d4?style=for-the-badge&logo=visual-studio-code" alt="在 VS Code 中安装">

<img src="https://img.shields.io/badge/VS_Code_Insiders-安装服务器-1f8b34?style=for-the-badge&logo=visual-studio-code" alt="在 VS Code Insiders 中安装">

<details> <summary><b>手动安装 VS Code</b></summary>

您也可以通过 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 服务器

<details> <summary><b>手动安装 Cursor</b></summary>

转到 Cursor 设置MCP添加新 MCP 服务器。命名为 "lighthouse",使用 command 类型并设置命令 npx @danielsogl/lighthouse-mcp@latest

{
  "mcpServers": {
    "lighthouse": {
      "command": "npx",
      "args": ["@danielsogl/lighthouse-mcp@latest"]
    }
  }
}
</details>

在 Windsurf 中安装

<img src="https://img.shields.io/badge/Windsurf-安装服务器-00d4aa?style=for-the-badge" alt="在 Windsurf 中安装">

<details> <summary><b>手动安装 Windsurf</b></summary>

遵循 Windsurf MCP 文档。使用以下配置:

{
  "mcpServers": {
    "lighthouse": {
      "command": "npx",
      "args": ["@danielsogl/lighthouse-mcp@latest"]
    }
  }
}
</details>

在 Claude Desktop 中安装

<details> <summary><b>Claude Desktop 安装</b></summary>

遵循 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-guidelinesWCAG 2.1 可访问性指南和问题lighthouse://accessibility/wcag-guidelines
seo-best-practicesSEO 最佳实践和优化机会lighthouse://seo/best-practices
security-best-practices网络安全最佳实践和漏洞lighthouse://security/best-practices
budget-guidelines按站点类型划分的性能预算推荐lighthouse://performance/budget-guidelines
categories-scoringLighthouse 审核类别和评分方法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 (必需): 要分析的网站 URL
  • device: 目标设备 ("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"
  }
}

// 创建性能改进计划
{
  "