L

Lighthouse-MCP 灯塔性能优化工具

@priyankark/lighthouse-mcp
0 Stars 383 次浏览 priyankark 更新于 2026-08-23

允许像 Cursor/Cline/GitHub Copilot 这样的人工智能助手使用 Google 的灯塔工具来衡量您网页的性能指标。然后,您可以运行代理循环,让助手优化这些指标!

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "lighthouse": {
      "args": [
        "lighthouse-mcp"
      ],
      "autoApprove": [],
      "command": "npx",
      "disabled": false
    }
  }
}

可用工具 (2 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

run_audit 4 个参数 需填 1 项

Run a Lighthouse audit on a URL

必填参数:url

get_performance_score 2 个参数 需填 1 项

Get just the performance score for a URL

必填参数:url

服务介绍

Lighthouse MCP Server

一个围绕 Google 的 Lighthouse 工具构建的 MCP 服务器,用于帮助测量网页的各种性能指标。

Lighthouse MCP Server Screenshot

功能

  • 对任何 URL 运行全面的 Lighthouse 审计
  • 获取性能评分和指标
  • 配置设备模拟(移动/桌面)
  • 控制网络限速
  • 选择特定的审计类别

安装

选项 1:使用 npx(推荐)

您可以直接使用 npx 运行工具,而无需安装:

npx lighthouse-mcp

选项 2:全局安装

全局安装包:

npm install -g lighthouse-mcp

然后运行它:

lighthouse-mcp

选项 3:本地开发

  1. 克隆此仓库
  2. 安装依赖项:
    npm install
    
  3. 构建项目:
    npm run build
    
  4. 运行服务器:
    npm start
    

MCP 配置

通过 npm 安装(全局或 npx)

在您的 MCP 设置配置文件中添加以下内容:

{
  "mcpServers": {
    "lighthouse": {
      "command": "npx",
      "args": ["lighthouse-mcp"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

使用本地开发版本

在您的 MCP 设置配置文件中添加以下内容:

{
  "mcpServers": {
    "lighthouse": {
      "command": "node",
      "args": ["/absolute/path/to/lighthouse-mcp/build/index.js"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

/absolute/path/to/lighthouse-mcp 替换为此项目的实际路径。

可用工具

run_audit

对 URL 运行全面的 Lighthouse 审计。

参数:

  • url(必需):要审计的 URL
  • categories(可选):要审计的类别数组(默认为全部)
    • 选项:"performance", "accessibility", "best-practices", "seo", "pwa"
  • device(可选):要模拟的设备(默认为 "mobile")
    • 选项:"mobile", "desktop"
  • throttling(可选):是否应用网络限速(默认为 true)

示例:

{
  "url": "https://example.com",
  "categories": ["performance", "accessibility"],
  "device": "desktop",
  "throttling": false
}

get_performance_score

仅获取 URL 的性能评分。

参数:

  • url(必需):要审计的 URL
  • device(可选):要模拟的设备(默认为 "mobile")
    • 选项:"mobile", "desktop"

示例:

{
  "url": "https://example.com",
  "device": "mobile"
}

示例用法

一旦配置了 MCP 服务器,您可以使用 Claude:

What's the performance score for example.com?

Claude 将使用 get_performance_score 工具来分析网站并返回结果。

要求

  • Node.js 16+
  • Chrome/Chromium 浏览器(用于 Lighthouse)

推荐

相关 MCP 服务