Lighthouse MCP
Lighthouse MCP 服务器
一个模型上下文协议(MCP)服务器,利用 Google Lighthouse 提供全面的网页性能审计和分析能力。该服务器使 LLM 和 AI 代理能够执行详细的网站性能评估、可访问性审计、SEO 分析、安全检查以及 Core Web Vitals 监控。
🌟 主要特性
🚀 性能分析:完整的 Lighthouse 审计,包括 Core Web Vitals、性能评分和优化建议
♿ 可访问性审计:WCAG 合规性检查和可访问性评分分析
🔍 SEO 分析:搜索引擎优化审计和最佳实践建议
🔒 安全评估:HTTPS、CSP 和安全漏洞扫描
📊 资源分析:JavaScript、CSS、图片和字体优化机会
📱 移动端与桌面端对比:跨设备对比分析,支持网络节流选项
⚡ Core Web Vitals:LCP、INP、CLS 监控及阈值检查
🎯 性能预算:自定义性能阈值和预算监控
🤖 代理浏览:Lighthouse 13 审计,评估页面为 AI 代理服务的质量(WebMCP 工具、代理可访问性树、llms.txt)
🧩 结构化输出:每个工具都声明了
outputSchema并返回经过验证的structuredContent,客户端获得的是类型化数据,而非需要解析的 JSON 字符串📚 参考资源:内置的网页性能、可访问性、SEO 和安全方面的指南与最佳实践
Related MCP server: mcp-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"]
}
}
}持久化 Chrome 配置文件(登录会话)
如果需要经过身份验证的会话,请使用持久化 Chrome 配置文件并以有头模式启动:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": [
"@danielsogl/lighthouse-mcp@latest",
"--profile-path",
"<profile-path>",
"--no-headless"
]
}
}
}你可以使用 --chrome-flag 传递额外的 Chrome 标志,例如 --chrome-flag=--disable-gpu。
如果标志值以 -- 开头且与已知选项名称匹配,请优先使用 --chrome-flag=... 以避免被解析为顶层选项。
配置文件模式会禁用 Lighthouse 的存储重置,以便 cookie 和本地存储在多次运行之间得以保留。
如果 --user-data-dir 指向不存在的目录,该目录将被创建并视为全新配置文件。
将 --profile-path 设置为 chrome://version 中显示的配置文件路径(例如 .../Default)。
注意:Chrome 的远程调试要求使用非默认的用户数据目录,因此请复用专用的配置文件目录,而不是系统默认目录。
如果你愿意,也可以分别传递 --user-data-dir 和 --profile-directory。
仅使用 --chrome-port 附加不会保留存储;请包含配置文件标志以保持会话。
CLI 选项
MCP 服务器支持的运行时标志:
--profile-path <path>:使用chrome://version中的配置文件路径(自动推导用户数据目录和配置文件名称)--user-data-dir <path>:复用 Chrome 配置文件目录以实现持久化会话--profile-directory <name>:在用户数据目录中选择一个配置文件--chrome-path <path>:Chrome/Chromium 可执行文件的显式路径(覆盖自动检测;也遵循CHROME_PATH环境变量)--chrome-flag <flag>或--chrome-flag=<flag>:透传额外的 Chrome 标志(可重复)--chrome-port <port>或--remote-debugging-port <port>:附加到已启用远程调试的现有 Chrome 实例--headless:强制无头模式--no-headless:强制有头模式
日志
Lighthouse 将日志输出到 stderr。服务器将其保持在 error 级别,以免淹没你的 MCP
客户端的日志;调试时(例如 Chrome 启动失败时)可将 LIGHTHOUSE_LOG_LEVEL 设置为 silent、info 或 verbose。
LIGHTHOUSE_LOG_LEVEL=verbose npx @danielsogl/lighthouse-mcp@latestWSL2 / 自定义 Chrome 路径
如果检测到了错误的 Chrome 二进制文件(例如在 WSL2 上检测到 Windows 版 Chrome 而非 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"]
}
}
}端到端冒烟测试(配置文件)
使用持久化配置文件运行真实审计(如有需要,请使用现有配置文件目录并登录一次):
npm run smoke:profile -- --url https://example.com \
--profile-path "<profile-path>" \
--no-headless端到端冒烟测试(附加到现有 Chrome)
启动已启用远程调试的 Chrome:
/path/to/GoogleChromeExecutable \
--remote-debugging-port=9222 \
--user-data-dir /path/to/chrome-profile将 /path/to/GoogleChromeExecutable 替换为你所在平台的 Chrome/Chromium 二进制文件路径。
然后将 Lighthouse 附加到该实例:
npm run smoke:profile -- --url https://example.com --chrome-port 9222附加时如需保留存储,请传入配置文件路径,以便 Lighthouse 保留 cookie/本地存储:
npm run smoke:profile -- --url https://example.com \
--chrome-port 9222 \
--profile-path "<profile-path>"在 VS Code 中安装
你也可以使用 VS Code CLI 安装 Lighthouse 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"]}'安装完成后,Lighthouse MCP 服务器即可在 VS Code 中与你的 GitHub Copilot 代理配合使用。
在 Cursor 中安装
前往 Cursor 设置 → MCP → 添加新的 MCP 服务器。将其命名为 "lighthouse",使用 command 类型,命令为 npx @danielsogl/lighthouse-mcp@latest:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}在 Windsurf 中安装
请遵循 Windsurf MCP 文档。使用以下配置:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}在 Claude Desktop 中安装
请遵循 MCP 安装指南,使用以下配置:
{
"mcpServers": {
"lighthouse": {
"command": "npx",
"args": ["@danielsogl/lighthouse-mcp@latest"]
}
}
}🔧 可用工具
Lighthouse MCP 服务器提供以下工具,用于全面的网页分析:
🏁 审计工具
工具 | 描述 | 参数 |
| 运行全面的 Lighthouse 审计 |
|
| 获取可访问性评分和建议 |
|
| 获取 SEO 分析和建议 |
|
⚡ 性能工具
工具 | 描述 | 参数 |
| 获取整体性能评分 |
|
| 获取 Core Web Vitals 指标 |
|
| 跨设备对比性能 |
|
| 对照性能预算进行检查 |
|
| 查找 LCP 优化机会 |
|
🔍 分析工具
工具 | 描述 | 参数 |
| 查找未使用的 JavaScript 代码 |
|
| 分析所有网站资源 |
|
🔒 安全工具
工具 | 描述 | 参数 |
| 执行全面的安全审计 |
|
💬 可用提示词
Lighthouse MCP 服务器包含可复用的提示词,帮助 LLM 提供结构化的分析和建议:
📊 分析提示词
提示词 | 描述 | 参数 |
| 分析 Lighthouse 审计结果 |
|
| 对比前后审计结果 |
|
| 获取 Core Web Vitals 优化建议 |
|
| 获取资源优化建议 |
|
📚 可用资源
Lighthouse MCP 服务器提供内置的参考资源,包含基本指南和最佳实践:
资源 | 描述 | URI |
| Core Web Vitals 性能阈值 |
|
| 性能优化技术及其影响 |
|
| WCAG 2.1 无障碍指南和问题 |
|
| SEO 最佳实践和优化机会 |
|
| Web 安全最佳实践和漏洞 |
|
| 按站点类型划分的性能预算建议 |
|
| Lighthouse 审计类别和评分方法 |
|
| 特定框架的优化指南 |
|
🎯 策略提示词
提示词 | 描述 | 参数 |
| 生成全面的性能改进计划 |
|
| 创建自定义性能预算建议 |
|
| 生成 SEO 改进建议 |
|
| 创建无障碍改进指南 |
|
🔧 提示词参数详情
auditResults:来自 Lighthouse 工具的 JSON 审计结果focusArea:要关注的特定类别("performance"、"accessibility"、"seo"、"best-practices"、"agentic-browsing")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", "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"
}
}Core Web Vitals 分析
// 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"
}
}🎯 使用场景
性能监控:自动化性能跟踪和 Core Web Vitals 监控
无障碍合规:WCAG 2.1 合规检查和修复指导
SEO 优化:技术 SEO 审计和搜索引擎优化建议
安全评估:漏洞扫描和安全最佳实践验证
资源优化:包体分析和优化机会识别
性能预算:自动化性能预算监控和告警
CI/CD 集成:自动化质量门禁和性能回归检测
🏗️ 架构
该服务器基于以下技术构建:
Model Context Protocol SDK:用于 MCP 服务器实现
Google Lighthouse:用于 Web 性能审计
Chrome Launcher:用于浏览器自动化
TypeScript:用于类型安全和更好的开发者体验
Zod:用于运行时模式验证
🧪 测试
npm run test:run # unit tests
npm run test:coverage # unit tests with coverage
npm run test:e2e # end-to-end tests端到端测试套件会构建服务器,通过 stdio 与真实的 MCP 客户端启动它,并针对在回环地址上提供的测试页面运行实际的 Lighthouse 审计。该套件需要安装 Chrome;如果 Chrome 位于非标准位置,请设置 CHROME_PATH。
🤝 贡献
欢迎贡献!请阅读我们的贡献指南,了解以下详细信息:
代码风格和标准
测试要求
拉取请求流程
开发环境设置
📜 许可证
本项目根据 MIT 许可证授权 - 详情请参阅 LICENSE 文件。
🔒 安全
如有安全问题,请参阅我们的安全策略。
📞 支持
🐛 错误报告:GitHub Issues
💬 讨论:GitHub Discussions
📧 电子邮件:security@codingrules.ai
🙏 致谢
Google Lighthouse 团队提供了出色的审计引擎
Anthropic 制定了 Model Context Protocol 规范
开源社区持续提供灵感和贡献
由 Daniel Sogl 用 ❤️ 构建
Available Tools
11 toolsanalyze_resourcesAnalyze Page ResourcesARead-only
Analyze website resources (images, JS, CSS, fonts) for optimization opportunities
Inputs: url (required), device, minSize, resourceTypes. Returns: url, device, filters, summary, +3 more
check_performance_budgetCheck Performance BudgetBRead-only
Check if website performance meets specified budget thresholds
Inputs: url (required), budget (required), device. Returns: data, summary, recommendations
compare_mobile_desktopCompare Mobile vs DesktopARead-only
Compare website performance between mobile and desktop devices
Inputs: url (required), categories, throttling, includeDetails. Returns: data, summary, recommendations
find_unused_javascriptFind Unused JavaScriptBRead-only
Find unused JavaScript code to reduce bundle size
Inputs: url (required), device, minBytes. Returns: url, device, summary, timestamp, +3 more
get_accessibility_scoreGet Accessibility ScoreBRead-only
Get the accessibility score and recommendations for a website
Inputs: url (required), device, includeDetails. Returns: data, summary, recommendations
get_core_web_vitalsGet Core Web VitalsARead-only
Get Core Web Vitals metrics for a website
Inputs: url (required), device, threshold, includeDetails. Returns: data, summary, recommendations
get_lcp_opportunitiesGet LCP OpportunitiesBRead-only
Get LCP optimization opportunities for a website
Inputs: url (required), device, threshold, includeDetails. Returns: data, summary, recommendations
get_performance_scoreGet Performance ScoreCRead-only
Get the performance score for a website
Inputs: url (required), device. Returns: data, summary, recommendations
get_security_auditGet Security AuditARead-only
Perform security audit checking HTTPS, CSP, and other security measures
Inputs: url (required), checks, device. Returns: data, summary, recommendations
get_seo_analysisGet SEO AnalysisCRead-only
Get SEO analysis and recommendations for a website
Inputs: url (required), device, includeDetails. Returns: data, summary, recommendations
run_auditRun Lighthouse AuditBRead-only
Run a comprehensive Lighthouse audit on a website
Inputs: url (required), device, categories, throttling. Returns: data, summary, recommendations
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
There is significant overlap between run_audit and the specific getter tools (accessibility, SEO, performance), as run_audit likely encompasses all of those. Additionally, get_lcp_opportunities, find_unused_javascript, and analyze_resources all target performance optimization with unclear boundaries.
Most tools follow a clear verb_noun pattern (e.g., get_*, run_audit, compare_mobile_desktop, check_performance_budget). Minor deviations include run_audit vs. get_security_audit (both use 'audit' but different verbs) and find_unused_javascript/analyze_resources not using 'get_' prefix, but the overall convention is consistent.
With 11 tools, the set is well-scoped for a website auditing server. Each tool covers a distinct aspect of Lighthouse auditing (performance, SEO, accessibility, security, resources), and the count is within the ideal 3-15 range without feeling bloated.
The tool surface covers major Lighthouse categories (performance, accessibility, SEO, security, Core Web Vitals, resources) and includes useful extras like budget checks and mobile/desktop comparison. However, it lacks explicit best practices and PWA audits, which are standard Lighthouse categories, creating minor gaps.
Maintenance
Related MCP Connectors
Free MCP server that audits any public URL: technical SEO, Core Web Vitals, indexing checks.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Website QA for your coding agent: audit SEO, performance, security, accessibility over MCP.
Your agent needs to crawl a site and say what is wrong with it — broken tags, duplicate content, pages nothing can index, resources that never load. **What you can ask for** • "Crawl this site and list every page with a duplicate title or missing description." • "Which pages are non-indexable, and why?" • "Run Lighthouse on these URLs and give me the failing audits." • "Show the internal link graph and the orphan pages." • "Give me this page's raw HTML and its microdata." **How to use it** Point any MCP client at https://mcp.aisa.one/seo-onpage/mcp and sign in with OAuth — there is no key to create or paste. 20 tools: submit a crawl and read its summary, pages, resources, links and waterfall; duplicate content and duplicate tags; keyword density; non-indexable and uncrawlable resources; parsed content, raw HTML, microdata, screenshots and Lighthouse. **Why this rather than the source** A crawler you drive from the agent, with the audit results as structured data rather than a PDF. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the broken pages here, then ask the same agent what those pages used to rank for — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/seo/mcp for all of it at once — rankings, keywords, backlinks, site health and AI-answer visibility across DataForSEO, Semrush and Ahrefs.
Related MCP Servers
- AlicenseAqualityDmaintenanceA comprehensive MCP server providing 15 web tools including search, scraping, screenshots, SEO audits, and DNS/SSL checks through a single installation. It delivers clean, LLM-optimized outputs so AI agents can focus on reasoning rather than parsing raw HTML.156 npmMIT
- AlicenseAqualityDmaintenanceEnables AI agents to perform comprehensive SEO audits on web pages, including meta tags, headings, links, images, performance, and more, via a CLI or MCP server.182MIT
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for SEO, performance, GEO, and UX audits with 37 tools covering technical SEO, Lighthouse performance, AI search optimization, content analysis, accessibility, security, and more.1MIT
- AlicenseAqualityDmaintenanceAn MCP server that audits websites for accessibility (WCAG 2.1 AA/EAA), performance, SEO, design quality, and mobile responsiveness, providing actionable scores, grades, and prioritized fixes.6MIT