@danielsogl/lighthouse-mcp

中文文档
2.0.1发布于 2026/08/16MITTypeScriptES Module构建来源已验证近 30 天下载 9277

一个全面的"模式背景协议"(MCP)服务器,利用Google灯塔提供网络性能审计,无障碍测试,SEO分析,安全评估,以及核心网络维度监测. 允许 LLMs 和 AI 代理 执行 详细 We

中文使用文档
文档目录39 节
  1. 关键特性
  2. 所需经费
  3. 开始
  4. 持久性色谱配置文件( Login会话)
  5. CLI 选项
  6. E2E 烟雾试验(文件)
  7. E2E 烟雾试验(从现有染色体开始)
  8. 在 VS 代码中安装
  9. 在光标中安装
  10. 在 Windsurf 安装
  11. 在 Claude 桌面中安装
  12. 可用的工具
  13. 审计工具
  14. 性能工具
  15. 分析工具
  16. QQ 安全工具
  17. 可用的提示
  18. 分析提示
  19. * 可用资源
  20. 战略提示
  21. 快速参数细节
  22. 参数细节
  23. 共同参数
  24. 具体参数
  25. 使用实例
  26. 基本业绩审计
  27. 核心网络活性分析
  28. 安全评估
  29. 资源优化
  30. 使用参考资源
  31. 使用分析提示
  32. 使用大小写
  33. 建筑
  34. 测试
  35. 捐款
  36. 许可证
  37. • 警卫
  38. ++ 辅助
  39. 承认

灯塔 MCP 服务器

NPM Version License: MIT Node Version CI Coverage Sponsor

一个模型背景协议(MCP)服务器,利用Google灯塔提供全面的网络性能审计和分析能力. 该服务器使LLMs和AI代理能够进行详细的网站性能评估,访问审核,SEO分析,安全检查和Core Web Virtuals监测.

Lighthouse MCP server

关键特性

  • 绩效分析: 完成灯塔审计,包括核心网络生命、业绩分数和优化建议
  • QQ 无障碍审计: WCAG 合规检查和无障碍分数分析
  • SEO分析:搜索引擎优化审计和最佳做法建议
  • 安全评估:HTTPS、CSP和安全脆弱性扫描
  • 资源分析: JavaScript, CSS, 图像和字体优化机会
  • 移动对桌面: 使用节流选项对设备进行比较分析
  • 核心网络维度: LCP、INP、CLS监测并进行阈值检查
  • 绩效预算: 自定义性能阈值和预算监测
  • 代理浏览:灯塔13,一个页面如何为AI代理服务的审计(WebMCP工具,代理访问树,llms.txt)
  • * 结构化产出: 每个工具声明一个 outputSchema 并验证返回 structuredContent,因此客户端可以得到输入的数据,而不是 JSON 字符串来解析
  • 参考资源:为网络性能、无障碍性、标准环境和安全制定准则和最佳做法

所需经费

  • 节点.js 22.0.0或更新
  • Chrome/铬浏览器(由灯塔自动管理)
  • VS 代码、 光标、 Windsurf、 Claude 桌面或任何其他 MCP 客户端

开始

使用下列配置之一,与您首选的客户端安装灯塔 MCP 服务器:

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

持久性色谱配置文件( Login会话)

需要验证的会话时,以持续Chrome剖面进行发射并运行标题:

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

您可以通过额外的克罗姆旗 --chrome-flag,例如 --chrome-flag=--disable-gpu。 。 。 . 如果旗帜值开始于 -- 并匹配已知选项名, 首选 --chrome-flag=... 以避免将其解析为顶级选项. Profile模式禁用灯塔的存储重置,因此饼干和本地存储在运行之间持续存在. 若为 --user-data-dir 指向缺失目录,它将被创建并作为新配置处理. 设定 --profile-path 路径 chrome://version (例如:. .../Default) (中文(简体) ). 注意:Chrome远程调试需要非默认用户数据目录,因此重用专用配置目录而不是系统默认. 也可以通过 --user-data-dir + 键 --profile-directory 如果你愿意的话 分开来. 附随 --chrome-port 单靠它不会保存存储; 包含一个保存会话的配置标记 .

CLI 选项

支持 MCP 服务器运行时旗 :

  • --profile-path <path>: 使用来自 chrome://version (自动识别用户数据 dir + profile name)
  • --user-data-dir <path>: 为持久性会话重新使用 Chrome 配置目录
  • --profile-directory <name>: 在用户数据目录中选择配置
  • --chrome-path <path>: 通往Chrome/Chrome可执行文件的明确路径(覆盖自动检测;也尊重 CHROME_PATH 环境变量)
  • --chrome-flag <flag> 或者说 --chrome-flag=<flag>:通过外克罗梅旗(可重复)
  • --chrome-port <port> 或者说 --remote-debugging-port <port>: 附加到已启用远程调试的 Chrome 实例
  • --headless: 强制无头模式
  • --no-headless: 向导模式

日志

灯塔木来作斯德. 服务器保持这个 error 所以它不会淹没你的MCP 客户端日志; 设置 LIGHTHOUSE_LOG_LEVEL 改为 silent, (中文(简体) ), info 或者说 verbose 调试时 (例如Chrome未能发射).

LIGHTHOUSE_LOG_LEVEL=verbose npx @danielsogl/lighthouse-mcp@latest

WSL2 / 自定义色调路径

如果错误的Chrome 二进制被取出(例如Windows Chrome代替了WSL2上的Linux 二进制),则明确设置路径:

# Via CLI flag
npx @danielsogl/lighthouse-mcp@latest --chrome-path /usr/bin/google-chrome

# Via environment variable
CHROME_PATH=/usr/bin/google-chrome npx @danielsogl/lighthouse-mcp@latest

在您的 MCP 配置中 :

{
  "mcpServers": {
    "lighthouse": {
      "command": "npx",
      "args": ["@danielsogl/lighthouse-mcp@latest", "--chrome-path", "/usr/bin/google-chrome"]
    }
  }
}

E2E 烟雾试验(文件)

使用持续配置文件进行真正的审计( 必要时使用现有配置文件目录并登录一次):

npm run smoke:profile -- --url https://example.com \
  --profile-path "<profile-path>" \
  --no-headless

E2E 烟雾试验(从现有染色体开始)

启用远程调试启动 Chrome :

/path/to/GoogleChromeExecutable \
  --remote-debugging-port=9222 \
  --user-data-dir /path/to/chrome-profile

替换 /path/to/GoogleChromeExecutable 与您的平台的 Chrome / Chromium 二进制路径 .

然后把灯塔放在这个例子上:

npm run smoke:profile -- --url https://example.com --chrome-port 9222

为了保存附加时的存储, 通过配置路径, 灯塔保持 cookie/ 本地存储 :

npm run smoke:profile -- --url https://example.com \
  --chrome-port 9222 \
  --profile-path "<profile-path>"

在 VS 代码中安装

Install in VS Code

Install in VS Code Insiders

手动 VS 代码安装

您也可以使用 VS 代码 CLI 安装灯塔 MCP 服务器 :

# For VS Code
code --add-mcp '{"name":"lighthouse","command":"npx","args":["-y","@danielsogl/lighthouse-mcp@latest"]}'

# For VS Code Insiders
code-insiders --add-mcp '{"name":"lighthouse","command":"npx","args":["-y","@danielsogl/lighthouse-mcp@latest"]}'

在安装后,灯塔MCP服务器将可用于您在VS代码中的GitHub Copilot代理.

在光标中安装

Install MCP Server

手动光标安装

转到 Cursor Settings → MCP → Add new MCP Server名称为“灯塔”,使用 command 带有命令的类型 npx @danielsogl/lighthouse-mcp@latest数字 :

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

在 Windsurf 安装

Install in Windsurf

人工 Windsurf 安装

跟着风起云起的MCP 文档。使用以下配置:

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

在 Claude 桌面中安装

克劳德桌面安装

跟随 MCP 安装 指南,使用以下配置:

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

可用的工具

灯塔MCP服务器提供了下列网络综合分析工具:

审计工具

工具说明参数
run_audit全面审计灯塔url, (中文(简体) ), categories?, (中文(简体) ), device?, (中文(简体) ), throttling?
get_accessibility_score获得无障碍分数和建议url, (中文(简体) ), device?, (中文(简体) ), includeDetails?
get_seo_analysis获得高级管理办公室的分析和建议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?

QQ 安全工具

工具说明参数
get_security_audit进行全面的安全审计url, (中文(简体) ), device?, (中文(简体) ), checks?

可用的提示

灯塔MCP服务器包含可重复使用的提示,帮助LLMS提供结构化的分析和建议:

分析提示

提示说明参数
analyze-audit-results灯塔审计结果分析auditResults, (中文(简体) ), focusArea?
compare-audits审计结果前后的比较beforeAudit, (中文(简体) ), afterAudit, (中文(简体) ), changesImplemented?
optimize-core-web-vitals获取核心网络维度优化建议coreWebVitals, (中文(简体) ), framework?, (中文(简体) ), constraints?
optimize-resources获取资源优化建议resourceAnalysis, (中文(简体) ), loadingStrategy?, (中文(简体) ), criticalUserJourneys?

* 可用资源

灯塔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-scoring灯塔审计类别和评分方法lighthouse://audits/categories-scoring
framework-guides特定框架优化指南lighthouse://frameworks/optimization-guides

战略提示

提示说明参数
create-performance-plan制定全面的绩效改进计划currentMetrics, (中文(简体) ), targetGoals?, (中文(简体) ), timeframe?
create-performance-budget创建自定义的绩效预算建议currentMetrics, (中文(简体) ), businessGoals?, (中文(简体) ), userBase?
seo-recommendations提出改善机会均等的建议seoAudit, (中文(简体) ), websiteType?, (中文(简体) ), targetAudience?
accessibility-guide创建无障碍改进指南accessibilityAudit, (中文(简体) ), complianceLevel?, (中文(简体) ), userGroups?

快速参数细节

  • auditResults: JSON 来自灯塔工具的审计结果
  • focusArea: 重点(b)的具体类别"performance", (中文(简体) ), "accessibility", (中文(简体) ), "seo", (中文(简体) ), "best-practices", (中文(简体) ), "agentic-browsing"(中文(简体) )
  • beforeAudit 编号 : afterAudit: 灯塔在变更前后的审计结果
  • changesImplemented: 说明在审计之间所作的变动
  • currentMetrics: 审计的现有业绩计量
  • targetGoals:具体业绩指标或业务目标
  • timeframe: 实施改进的时间表
  • framework: 前端框架或技术堆栈
  • constraints技术或商业制约因素
  • websiteType:网站类型(如:电子商务,博客,公司)
  • targetAudience目标受众或市场信息
  • complianceLevel: 遵守《公约》的情况"AA" 或者说 "AAA"(中文(简体) )
  • userGroups: 考虑无障碍的具体用户群体

参数细节

共同参数

  • url (必须): 用于分析的网站 URL
  • device: 目标设备("desktop" 或者说 "mobile",默认值 : "desktop"(中文(简体) )
  • includeDetails: 包含详细的审计信息(默认: false(中文(简体) )
  • throttling: 启用网络/CPU节奏( 默认 ): false(中文(简体) )

具体参数

  • categories- 灯塔类别供审计["performance", "accessibility", "best-practices", "seo", "agentic-browsing"](中文(简体) )
  • threshold: 度量衡的自定义阈值(例如, {"lcp": 2.5, "inp": 200, "cls": 0.1}(中文(简体) )
  • budget: 执行预算限制(例如, {"performanceScore": 90, "largestContentfulPaint": 2500}(中文(简体) )
  • resourceTypes: 分析的资源类型(["images", "javascript", "css", "fonts", "other"](中文(简体) )
  • minBytes: 用于分析的最小文件大小阈值( 默认 : 2048(中文(简体) )
  • checks: 进行安全检查(["https", "csp", "hsts", "origin-isolation", "clickjacking", "trusted-types", "third-party-cookies", "deprecations"](中文(简体) )

使用实例

基本业绩审计

// Get overall performance score
{
  "tool": "get_performance_score",
  "arguments": {
    "url": "https://example.com",
    "device": "mobile"
  }
}

核心网络活性分析

// Check Core Web Vitals with custom thresholds
{
  "tool": "get_core_web_vitals",
  "arguments": {
    "url": "https://example.com",
    "device": "mobile",
    "includeDetails": true,
    "threshold": {
      "lcp": 2.5,
      "inp": 200,
      "cls": 0.1
    }
  }
}

安全评估

// Comprehensive security audit
{
  "tool": "get_security_audit",
  "arguments": {
    "url": "https://example.com",
    "checks": ["https", "csp", "hsts"]
  }
}

资源优化

// Find optimization opportunities
{
  "tool": "analyze_resources",
  "arguments": {
    "url": "https://example.com",
    "resourceTypes": ["images", "javascript"],
    "minSize": 1024
  }
}

使用参考资源

获取内在准则和最佳做法:

// Get Core Web Vitals thresholds
{
  "resource": {
    "uri": "lighthouse://performance/core-web-vitals-thresholds"
  }
}

// Access WCAG accessibility guidelines
{
  "resource": {
    "uri": "lighthouse://accessibility/wcag-guidelines"
  }
}

// Get framework-specific optimization guides
{
  "resource": {
    "uri": "lighthouse://frameworks/optimization-guides"
  }
}

使用分析提示

// Analyze audit results with focused recommendations
{
  "prompt": "analyze-audit-results",
  "arguments": {
    "auditResults": "{...lighthouse audit json...}",
    "focusArea": "performance"
  }
}

// Create a performance improvement plan
{
  "prompt": "create-performance-plan",
  "arguments": {
    "currentMetrics": "{...current performance metrics...}",
    "targetGoals": "Achieve 90+ performance score and sub-2s LCP",
    "timeframe": "3 months"
  }
}

// Compare before/after audit results
{
  "prompt": "compare-audits",
  "arguments": {
    "beforeAudit": "{...before audit results...}",
    "afterAudit": "{...after audit results...}",
    "changesImplemented": "Implemented lazy loading and image optimization"
  }
}

使用大小写

  • 业绩监测: 自动性能跟踪和核心网络生命监测
  • 无障碍遵守: WCAG 2.1 合规检查和补救指导
  • SEO 优化: 技术审计和搜索引擎优化建议
  • 安全评估:脆弱性扫描和安全最佳做法验证
  • 资源优化: 组合分析和优化机会识别
  • 预算:自动执行情况预算监测和警报
  • CI/CD 一体化: 自动质量门和性能回归检测

建筑

服务器使用 :

测试

npm run test:run      # unit tests
npm run test:coverage # unit tests with coverage
npm run test:e2e      # end-to-end tests

端到端套件会建起服务器,用真实的MCP客户端在stdio上发射 运行实际的灯塔审计 相对于一个固定的页面 循环。 这需要克罗梅 待安装; 设置 CHROME_PATH 如果它住的地方不标准.

捐款

欢迎捐款! 请读我们的 贡献指南 详细情况如下:

  • 代码样式和标准
  • 测试要求
  • 请求程序
  • 开发设置

许可证

这个项目根据麻省理工学院许可证颁发——见 自由主义 详细文件.

• 警卫

关于安全问题,请参见我们 安全政策。 。 。 .

++ 辅助

承认

  • Google灯塔团队的优秀审计引擎
  • 示范上下文协议规格
  • 持续激励和贡献的开源社区

由 QQ 创建 丹尼尔·索格

版本与发布记录

@danielsogl/lighthouse-mcp 共发布 28 个版本,首次发布于 2025/06/01;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.1latest2026/08/162 个月前
2.0.02026/08/162 个月前
1.3.02025/12/2810 个月前
1.2.212025/12/0511 个月前
1.2.202025/10/131.1 年前
1.2.192025/10/061.1 年前

关于 @danielsogl/lighthouse-mcp 的常见问题

@danielsogl/lighthouse-mcp 是什么?

一个全面的"模式背景协议"(MCP)服务器,利用Google灯塔提供网络性能审计,无障碍测试,SEO分析,安全评估,以及核心网络维度监测. 允许 LLMs 和 AI 代理 执行 详细 We

如何安装 @danielsogl/lighthouse-mcp?

在项目目录运行 npm install @danielsogl/lighthouse-mcp,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 lighthouse-mcp-server,可以用 npx lighthouse-mcp-server 直接运行。

@danielsogl/lighthouse-mcp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@danielsogl/lighthouse-mcp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@danielsogl/lighthouse-mcp 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@danielsogl/lighthouse-mcp 可以商用吗?

@danielsogl/lighthouse-mcp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@danielsogl/lighthouse-mcp 的下载量有多少?

根据 npm 官方下载统计,@danielsogl/lighthouse-mcp 在 2026/10/12 – 2026/11/10 这 30 天内被下载 9,277 次,日均约 309 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@danielsogl/lighthouse-mcp 还在维护吗?

最新版本 2.0.1 发布于 2026/08/16(2 个月前);至今共发布 28 个版本,其中过去 12 个月发布了 4 个;首次发布于 2025/06/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。