PageSpeed MCP Server

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Allows AI assistants to access Google's PageSpeed Insights API for detailed performance analysis of websites, including metrics like Core Web Vitals, performance scores, accessibility, best practices, and SEO audits

PageSpeed MCP 服务器

一个模型上下文协议 (MCP) 服务器,可通过 PageSpeed Insights 功能扩展 AI 助手功能。该服务器充当 AI 模型与 Google PageSpeed Insights API 之间的桥梁,从而实现对网站的详细性能分析。

概述

PageSpeed MCP 服务器旨在增强 AI 助手的功能,使其能够执行全面的 Web 性能分析。集成后,AI 模型可以请求并解读任何给定 URL 的详细性能指标、核心 Web 指标以及其他关键 Web 性能数据。

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 PageSpeed Server:

npx -y @smithery/cli install mcp-pagespeed-server --client claude

手动安装

npm install pagespeed-mcp-server

配置

将 PageSpeed MCP 添加到您的 AI 助手(在本例中为 claude)的配置文件中:

{ "pagespeed": { "command": "node", "args": ["path/to/mcp-pagespeed-server/dist/index.js"] } }

详细功能

绩效指标分析

  • 首次内容绘制 (FCP)
  • 最大内容绘制 (LCP)
  • 交互时间(TTI)
  • 总阻塞时间(TBT)
  • 累积布局偏移 (CLS)
  • 速度指数
  • 第一个字节的时间(TTFB)

最佳实践评估

  • HTTPS 使用情况
  • JavaScript错误监控
  • 浏览器控制台警告
  • 已弃用的 API 使用情况
  • 图像长宽比分析
  • 链接安全检查

SEO分析

  • 元描述验证
  • Robots.txt 验证
  • 结构化数据验证
  • 可抓取链接验证
  • 元标签评估
  • 移动友好性

无障碍审计

  • ARIA 属性验证
  • 颜色对比度检查
  • 标题层次分析
  • Alt 文本验证
  • 焦点管理评估
  • 键盘导航测试

资源优化

  • 图像优化建议
  • JavaScript 捆绑分析
  • CSS 优化建议
  • 缓存策略验证
  • 资源最小化检查
  • 渲染阻塞资源识别

API 响应结构

MCP 服务器提供详细的 JSON 响应,包括:

{ "lighthouseResult": { "categories": { "performance": { /* Performance metrics */ }, "accessibility": { /* Accessibility results */ }, "best-practices": { /* Best practices audit */ }, "seo": { /* SEO findings */ } }, "audits": { // Detailed audit results for each category }, "timing": { // Performance timing data }, "stackPacks": { // Technology-specific advice } } }

高级用法

自定义配置

您可以通过提供其他参数来定制 PageSpeed 分析:

{ "strategy": "mobile", // or "desktop" "category": ["performance", "accessibility", "best-practices", "seo"], "locale": "en", "threshold": { "performance": 90, "accessibility": 100, "best-practices": 90, "seo": 90 } }

错误处理

MCP 服务器包含强大的错误处理功能:

  • 无效的 URL
  • 网络超时
  • API 速率限制
  • 参数无效
  • 服务器端错误

要求

网络要求

  • 稳定的网络连接
  • 访问 Google 的 PageSpeed Insights API

平台支持

  • Windows(x64、x86)
  • Linux(x64)
  • macOS(x64、arm64)

集成示例

基本集成

const PageSpeedMCP = require('pagespeed-mcp-server'); const mcp = new PageSpeedMCP(); await mcp.analyze('https://example.com');

带有自定义选项

const results = await mcp.analyze('https://example.com', { strategy: 'mobile', categories: ['performance', 'accessibility'], locale: 'en-US' });

故障排除

常见问题

  1. 连接超时
    • 检查互联网连接
  2. API 速率限制
    • 使用 API 密钥来获得更高的限制
  3. 内存问题
    • 调整 Node.js 内存限制

发展

从源代码构建

git clone https://github.com/phialsbasement/mcp-pagespeed-server cd mcp-pagespeed-server npm install npm run build

运行测试

npm run test

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 提交你的更改
  4. 推送到分支
  5. 创建拉取请求

支持

获取帮助

  • GitHub 问题:报告错误和功能请求

执照

MIT 许可证 - 详情请参阅许可证文件

ID: tgfbq4e51o