MCP Image Compare Server

MCP Image Compare Server

Enables pixel-perfect image comparison and visual regression testing via tools to compare local images, screenshots, and URLs with detailed diff statistics.

Category
访问服务器

README

MCP Image Compare Server

npm version License: MIT Node.js Version

Tiếng Việt | English

A Model Context Protocol (MCP) server for pixel-perfect image comparison using Pixelmatch from Mapbox. Compare images, capture and compare screenshots, detect visual differences with precision.

Features

  • 🎯 Pixel-perfect comparison - Detect even single-pixel differences
  • 🎨 Perceptual color difference - YIQ color space for human-like perception
  • 🔍 Anti-aliasing detection - Smart detection and exclusion of anti-aliased pixels
  • 📊 Detailed statistics - Pixel count, percentage, dimensions
  • 🖼️ Visual diff output - Color-coded difference visualization
  • 🌐 Web screenshot support - Compare with live websites
  • 📁 Multiple formats - PNG and JPEG support
  • Fast & lightweight - ~60-80KB package size

Quick Start

Installation

# Install globally
npm install -g mcp-image-compare-server

# Install Chromium for screenshots
npx playwright install chromium

Configuration

For Claude Desktop

Add to your Claude Desktop config file:

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "image-compare": {
      "command": "npx",
      "args": ["-y", "mcp-image-compare-server"]
    }
  }
}

Restart Claude Desktop after configuration.

For Cursor

Add to your Cursor MCP settings file:

Windows: %APPDATA%\Cursor\User\globalStorage\mcp.json
macOS: ~/Library/Application Support/Cursor/User/globalStorage/mcp.json
Linux: ~/.config/Cursor/User/globalStorage/mcp.json

{
  "mcpServers": {
    "image-compare": {
      "command": "npx",
      "args": ["-y", "mcp-image-compare-server"]
    }
  }
}

Or through Cursor settings:

  1. Open Cursor Settings (Ctrl+, or Cmd+,)
  2. Search for "MCP"
  3. Click "Edit in settings.json"
  4. Add the configuration above

Restart Cursor after configuration.

Usage

Ask in Claude Desktop or Cursor:

Compare image1.png and image2.png

That's it! 🎉

Tools

1. compare_images

Compare two local image files.

Parameters:

  • image1_path (string, required) - Path to first image
  • image2_path (string, required) - Path to second image
  • diff_output_path (string, optional) - Where to save diff image
  • threshold (number, optional) - Comparison threshold (0-1), default 0.1
  • includeAA (boolean, optional) - Include anti-aliased pixels, default false

Example:

{
  "image1_path": "./screenshots/before.png",
  "image2_path": "./screenshots/after.png",
  "diff_output_path": "./diff-result.png",
  "threshold": 0.1
}

2. compare_image_with_url

Compare a local image with a screenshot from a URL.

Parameters:

  • image_path (string, required) - Path to local image
  • url (string, required) - URL to capture and compare
  • diff_output_path (string, optional) - Where to save diff image
  • threshold (number, optional) - Comparison threshold (0-1), default 0.1
  • includeAA (boolean, optional) - Include anti-aliased pixels, default false

Example:

{
  "image_path": "./design-mockup.png",
  "url": "https://example.com",
  "threshold": 0.15
}

3. compare_urls

Compare screenshots from two different URLs.

Parameters:

  • url1 (string, required) - First URL to capture
  • url2 (string, required) - Second URL to capture
  • diff_output_path (string, optional) - Where to save diff image
  • threshold (number, optional) - Comparison threshold (0-1), default 0.1
  • includeAA (boolean, optional) - Include anti-aliased pixels, default false

Example:

{
  "url1": "https://staging.example.com",
  "url2": "https://production.example.com"
}

Output Format

All tools return JSON with detailed statistics:

{
  "success": true,
  "diffPixels": 1234,
  "totalPixels": 921600,
  "percentDiff": 0.13,
  "width": 1280,
  "height": 720,
  "diffImagePath": "/path/to/diff.png",
  "message": "Comparison completed: 1234 pixels differ (0.13%)"
}

Fields:

  • success - Operation status (true/false)
  • diffPixels - Number of different pixels
  • totalPixels - Total pixels in image
  • percentDiff - Percentage difference
  • width - Image width in pixels
  • height - Image height in pixels
  • diffImagePath - Path to generated diff image
  • message - Human-readable result message
  • error - Error message (if failed)

Use Cases

Visual Regression Testing

Compare UI before and after updates to catch unintended changes.

I have two screenshots:
- before-update.png
- after-update.png

Compare them and tell me what changed.

Cross-browser Testing

Compare rendering across different browsers to ensure consistency.

Design Review

Compare design mockups with actual implementation.

Compare design-mockup.png with https://myapp.com/landing

A/B Testing

Compare different versions of the same page.

Compare:
- https://myapp.com/variant-a
- https://myapp.com/variant-b

Mobile vs Desktop

Compare responsive layouts across different viewports.

Configuration

Threshold Values

The threshold parameter (0-1) controls comparison sensitivity:

  • 0.0 - Very sensitive, detects smallest differences
  • 0.1 - Default, good balance for most cases
  • 0.3 - Less sensitive, ignores minor differences
  • 1.0 - Least sensitive, only major differences

Anti-aliasing

When includeAA = false (default), the server automatically detects and ignores anti-aliased pixels, reducing false positives from different rendering engines.

Diff Image Colors

  • Red: Different pixels
  • Yellow: Anti-aliased pixels (if includeAA = true)
  • Faded: Matching pixels (reduced opacity)

Installation Methods

Method 1: NPM Global (Recommended)

npm install -g mcp-image-compare-server
npx playwright install chromium

Configure Claude Desktop:

{
  "command": "npx",
  "args": ["-y", "mcp-image-compare-server"]
}

Method 2: NPX (No Installation)

Configure Claude Desktop:

{
  "command": "npx",
  "args": ["-y", "mcp-image-compare-server"]
}

First run will download the package automatically.

Method 3: From Source

git clone https://github.com/leky90/mcp-image-compare-server.git
cd mcp-image-compare-server
npm install
npx playwright install chromium
npm run build

Configure Claude Desktop or Cursor:

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

Replace /absolute/path/to/mcp-image-compare-server with your actual path.

System Requirements

  • Node.js: 18.0.0 or higher
  • npm: 8.0.0 or higher
  • OS: Windows 10+, macOS 10.15+, Linux (Ubuntu 20.04+)
  • Disk: ~500MB (includes Chromium browser)
  • RAM: 2GB minimum

Troubleshooting

Server doesn't connect

  1. Verify config path is correct
  2. Ensure you ran npm run build
  3. Restart Claude Desktop or Cursor completely
  4. Check the MCP logs for errors

"Browser not found" error

npx playwright install chromium

Screenshot timeout

For slow websites, the default 30-second timeout will handle most cases. If issues persist, please report.

Out of memory

For very large images:

  • Resize images before comparison
  • Use lower resolution images
  • Increase Node.js memory: node --max-old-space-size=4096 dist/index.js

Development

Building from Source

npm install
npm run build

Running Locally

npm start
# or
npm run dev

Testing

See CONTRIBUTING.md for development guidelines.

Tech Stack

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

Changelog

See CHANGELOG.md for version history.

License

MIT License - see LICENSE file for details.

Acknowledgments

Built with:

Support


Made with ❤️ using TypeScript and MCP

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选