MCP server for Google PageSpeed Insights API that enables web page performance analysis directly through Claude.
- π Performance Analysis of web pages using Google PageSpeed Insights
- π± Multi-platform Support: mobile and desktop devices
- π Detailed Lighthouse Reports with comprehensive metrics
- π Simplified Reports with key performance indicators
- π― Smart Recommendations with priority scoring and actionable fixes
- πΎ Intelligent Caching to reduce API calls and improve performance
- π Localization - support for multiple languages
- β‘ Quick Installation - one command setup
- π³ Docker Support for containerized deployment
# Set environment variable
export GOOGLE_API_KEY=your-google-api-keycurl -sSL https://raw.githubusercontent.com/ruslanlap/pagespeed-insights-mcp/master/install.sh | bash# Global installation from npm
npm install -g pagespeed-insights-mcp
# Or use without installation
npx pagespeed-insights-mcp
# Specific version
npm install -g [email protected]# First configure authentication (see GITHUB_PACKAGES.md for details)
# Then install globally
npm install -g @ruslanlap/pagespeed-insights-mcp
# Or specific version
npm install -g @ruslanlap/[email protected]Note: This package is available on both npm and GitHub Packages.
- For npm: Use
npm install pagespeed-insights-mcp- For GitHub Packages: Use
npm install @ruslanlap/pagespeed-insights-mcp(requires GitHub authentication)For detailed instructions on installing from GitHub Packages, see GITHUB_PACKAGES.md or visit the GitHub Packages page
The MCP server requires a Google API key to access the PageSpeed Insights API.
# Set environment variable
export GOOGLE_API_KEY=your-google-api-key
# Or pass directly when running
GOOGLE_API_KEY=your-google-api-key npx pagespeed-insights-mcpTo use this MCP server with Claude Desktop, add the following to your Claude Desktop configuration file:
{
"mcpServers": {
"pagespeed": {
"command": "npx",
"args": ["pagespeed-insights-mcp"],
"env": {
"GOOGLE_API_KEY": "your-google-api-key-here"
}
}
}
}Example configuration files are available in the examples directory.
docker build -t pagespeed-insights-mcp .
docker run -e GOOGLE_API_KEY=your-key pagespeed-insights-mcp- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable PageSpeed Insights API:
- Navigate to "APIs & Services" β "Library"
- Search for "PageSpeed Insights API" and enable it
- Create an API key:
- Go to "APIs & Services" β "Credentials"
- Click "Create Credentials" β "API Key"
- Copy the generated key
If you used the install.sh script, the configuration was created automatically.
Add the configuration to your Claude Desktop file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"pagespeed-insights": {
"command": "npx",
"args": ["pagespeed-insights-mcp"],
"env": {
"GOOGLE_API_KEY": "your-google-api-key-here"
}
}
}
}{
"mcpServers": {
"pagespeed-insights": {
"command": "npx",
"args": ["@ruslanlap/pagespeed-insights-mcp"],
"env": {
"GOOGLE_API_KEY": "your-google-api-key-here"
}
}
}
}{
"mcpServers": {
"pagespeed-insights": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--env", "GOOGLE_API_KEY=your-google-api-key-here",
"pagespeed-insights-mcp"
]
}
}
}Restart Claude Desktop after configuration!
After configuration, simply ask Claude any of these commands:
Analyze the performance of https://example.com
Analyze https://example.com for mobile devices with all categories
Get a quick performance report for https://example.com
Analyze https://example.com performance for desktop devices
Perform a full audit of https://example.com including SEO, accessibility, and best practices
Get smart recommendations for improving https://example.com performance
Clear the cache to get fresh data for all subsequent requests
Complete page analysis with all Lighthouse metrics.
Parameters:
url(required): URL of the page to analyzestrategy: "mobile" or "desktop" (default: "mobile")category: array of categories ["performance", "accessibility", "best-practices", "seo", "pwa"]locale: locale for results (default: "en")
Simplified report with key performance metrics.
Generate smart performance recommendations with priority scoring and actionable fixes.
Parameters:
url(required): URL of the page to analyzestrategy: "mobile" or "desktop" (default: "mobile")category: array of categories to analyze (default: ["performance", "accessibility", "best-practices", "seo"])locale: locale for results (default: "en")
Clear the internal cache to force fresh API requests for all subsequent analyses.
answer example from Claude Desktop with pagespeed-insights-mcp π₯π₯π₯
Now I have the full analysis! Here are all the ratings:
| Category | Score | Status |
|---|---|---|
| Performance | 67/100 | π‘ Needs Improvement |
| Accessibility | 92/100 | π’ Good |
| Best Practices | 96/100 | π’ Excellent |
| SEO | 100/100 | π’ Perfect |
| Metric | Value | Score |
|---|---|---|
| First Contentful Paint | 1.2s | π’ Excellent (98/100) |
| Largest Contentful Paint | 2.4s | π‘ Needs Improvement (75/100) |
| Speed Index | 4.8s | π‘ Needs Improvement (67/100) |
| Total Blocking Time | 60ms | π’ Good (94/100) |
| Cumulative Layout Shift | 0 | π’ Perfect (100/100) |
| Audit | Score | Description |
|---|---|---|
| Label Content Name Mismatch | π΄ 0/1 | 2 errors with aria-label |
| Unsized Images | π‘ 0.5/1 | 1 image without dimensions |
| Color Contrast | π’ 1/1 | Sufficient contrast |
| Button Names | π’ 1/1 | Accessible button names |
| Link Names | π’ 1/1 | Accessible link names |
| ARIA Roles | π’ 1/1 | Correct ARIA roles |
| HTML Lang | π’ 1/1 | Valid lang attribute |
| Meta Viewport | π’ 1/1 | Proper viewport |
| Image Alt Text | π’ 1/1 | Correct alt attributes |
| List Items | π’ 1/1 | Proper list structure |
| Audit | Score | Status |
|---|---|---|
| Uses HTTPS | π’ β | HTTPS is used |
| HTTP Status Code | π’ 1/1 | Correct 200 status |
| No Console Errors | π’ 1/1 | No console errors |
| Valid Source Maps | π’ 1/1 | Valid source maps |
| No Notification Requests | π’ 1/1 | No notification requests |
| Charset Declaration | π’ 1/1 | Correct encoding |
| No Inspector Issues | π’ 1/1 | No DevTools issues |
| Audit | Score | Status |
|---|---|---|
| Meta Viewport | π’ 1/1 | Mobile optimized |
| Document Title | π’ 1/1 | Title present |
| Meta Description | π’ 1/1 | Description present |
| HTTP Status Code | π’ 1/1 | Successful status |
| Link Text | π’ 1/1 | Descriptive link texts |
| Crawlability | π’ 1/1 | Available for indexing |
| HTML Lang | π’ 1/1 | Valid document language |
| Hreflang | π’ 1/1 | Correct hreflang attributes |
| Issue | Affects | Potential Savings |
|---|---|---|
| Improperly sized images | LCP, FCP | 1,069 KB, 170ms |
| Inefficient caching | Overall speed | 1,445 KB |
| Forced Reflows | Smoothness | 46.8ms |
| JavaScript execution time | TBT | 338ms |
| Metric | Value |
|---|---|
| Server Response Time | 120ms (π’ Good) |
| Network RTT | Minimal |
| Main Thread Work | 0.9s |
| DOM Size | 453 elements (optimal) |
- π΄ High Priority:
- Optimize image sizes (save 1+ MB)
- Fix aria-label mismatches for accessibility
- π‘ Medium Priority:
- Improve caching policy (TTL >600s)
- Add width/height attributes for images
- π’ Low Priority:
- Optimize forced reflows in JavaScript
Overall Rating: Good with potential for improvement
- SEO: Perfect (100/100) π
- Best Practices: Excellent (96/100) π
- Accessibility: Good (92/100) β
- Performance: Needs attention (67/100)
β οΈ
The site has excellent SEO optimization and follows best practices, but needs image optimization to improve performance.
Parameters:
url(required): URL of the page to analyzestrategy: "mobile" or "desktop" (default: "mobile")
# Development mode
npm run dev
# Build project
npm run build
# Run built server
npm startEnsure the GOOGLE_API_KEY environment variable is set in your Claude Desktop configuration.
Check if PageSpeed Insights API is enabled in your Google Cloud project.
Ensure the URL includes the protocol (http:// or https://).
MIT
For bug reports or feature requests, please create an issue in the repository.