Skip to main content
Glama

ui-diff-mcp

Compares an expected screen (a mockup, or an earlier screenshot) with an actual screenshot, for coding agents that can see images. It does the parts a model is bad at, deterministically, and hands the pictures back so the agent judges them itself:

  1. Even out: both screens are scaled to one width; the aspect-ratio difference is reported. A status bar at the top is found and skipped.

  2. Line up: each horizontal strip of the expected screen is matched to where it sits in the actual one (one smooth path over all strips, then a sideways correction per strip), so content that only moved is reported as a shift, not as dozens of changes.

  3. Match size: when offsets grow steadily down the screen, the device draws everything larger (it is narrower in dp than the mockup, e.g. 360 dp against 402 dp). The actual is shrunk by the measured factor and compared again, ignoring the one-pixel fringe resizing leaves on edges. The better of the two comparisons is kept.

  4. Box what still differs: a pixel diff after lining up, grouped into numbered boxes. A box whose content reappears a little to the side or below is reported under moved, not as a change.

  5. Show it: compare.png (expected | actual | changes, boxes numbered) and a full-resolution zoom per box (zoom-N.png, expected left, actual right).

No models, no GPU, no network. A typical phone screen takes about 5 seconds on the Pi.

Tools

Tool

What it does

compare_screens

expectedPath, actualPath, optional outDir, ignoreTop (fraction, default "auto" = skip a detected status bar, 0 = compare everything), ignoreBottom, threshold (colour tolerance, default 0.12), maxShift (default 0.12), scale (how much larger the actual draws content, e.g. 402/360; default "auto", "width" turns it off), inlineImages (default 4). Returns the JSON below plus the overview and zooms as JPEG images (the PNGs on disk stay full quality).

capture_android_screen

Screenshot of the phone over adb → PNG, with widthDp and a warning for black (off) screens. Uses UI_DIFF_ADB_EXECUTABLE, else ~/.local/bin/phone-adb (pins the Samsung), else adb.

Result JSON: expected/actual sizes, aspectMismatchPct, changedPct (after lining up), unalignedChangedPct, scaleApplied, ignoredTop, shifts[] (fromY, toY, shiftPx, shiftPct, shiftXPx, in expected pixels), regions[] (id, x, y, w, h, changedPct), moved[] (x, y, w, h, dx, dy), images, and plain-language notes.

Related MCP server: MCP Design Comparison Server

Use

npm install && npm run build
# MCP (stdio):
claude mcp add ui-diff -- node /home/agent-runner/projects/ui-diff-mcp/dist/src/index.js
# Or straight from a shell:
npx tsx src/cli.ts compare expected.png actual.png [outDir] --ignore-top=0.04
npx tsx src/cli.ts capture out.png

How to read a result:

  • Start with notes. When the reference was made for a different screen width the actual is compared at matching size (scaleApplied); the strip the narrower screen doesn't reach shows grey and isn't checked. A reference at the device width (360 dp on the Samsung) is still cleanest.

  • Then look at compare.png and the zooms, and judge each box against the project's rubric (/home/agent-runner/projects/_ui-review/RUBRIC.md).

  • For catching regressions in CI, prefer golden tests (Flutter matchesGoldenFile, Playwright toHaveScreenshot). This tool is for looking at a difference, not for gating builds.

How well it works

eval/run.ts <screenshots> <out> plants known changes into copies of real screenshots and scores the comparisons; eval/widths.ts <out> <url>... renders pages at 402 px and as a 360 dp phone at 3x and scores those. The screenshots stay outside the repo. On 19 screens of the owner's apps (November 2026), every planted colour change, removal, nudge, addition and resized patch was found, with at most one false box on average. Known weak spots: a section pushed down near the bottom (15 of 19 clean), JPEG noise on mockups (a stray box on 3 of 19), and a whole screen drawn larger, where the change is found but about 5 more boxes come from text drawn at a different size. When a web page reflows at a narrower width, the boxes mark the reflow (wrapped chips, cut-off text), which is a real difference but can crowd out a small mistake.

Why it is this small

Until November 2026 this repo was an 18,700-line pipeline: a 3B element locator on a remote GPU, per-element crop audits by many free vision models, and a large finding-consolidation layer. Runs took 8–20 minutes and around 68 model calls, and produced dozens of findings per screen (47 on Ravlo's Today screen). A single look by a current frontier model at a side-by-side found the same designer-relevant differences in about a minute. What models still get wrong is scale, alignment and small shifts, so that is all this tool does. The old pipeline is kept under the tag archive/full-pipeline-2026-11.

Available Tools

7 tools
capture_mobile_screenB

Captures a screenshot from a connected mobile device using adb or ios-simctl.

Inputs: target (required). Returns: capture, imagePath

compare_ui_imagesC

Compares an expected mobile mockup image against an actual mobile screenshot using only deterministic methods (no visual models).

Inputs: actualImagePath (required), expectedImagePath (required), mode, runLabel, +1 more. Returns: runId, status, summary, warnings, +11 more

discover_ui_diffsC

Runs full UI diff analysis, including visual model-based target discovery and classification. Compares expected mockup against actual screenshot.

Inputs: actualImagePath (required), expectedImagePath (required), mode, runLabel, +1 more. Returns: runId, status, summary, warnings, +11 more

get_ui_diff_run_statusB

Returns the status of a background UI diff run started by start_ui_diff_run.

Inputs: runId (required), projectRoot (required). Returns: error, label, runId, status, +7 more

read_ui_diff_reportB

Reads and returns a previously generated UI diff report JSON file.

Inputs: reportPath (required). Returns: report

start_ui_diff_runA

Starts a UI diff run in the background without holding the MCP request open. Returns a runId to poll with get_ui_diff_run_status. Use this for large or slow audits like Calorix full scans.

Inputs: actualImagePath (required), expectedImagePath (required), mode, label, +2 more. Returns: runId, status, message

ui_diff_model_healthA

Checks health of all visual models used by the diff pipeline.

Inputs: no named parameters. Returns: results, checkedAt

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 7 tools

    Disambiguation4/5

    Tools are mostly distinct but compare_ui_images and discover_ui_diffs both compare screenshots; descriptions clarify deterministic vs model-based, but could cause temporary confusion.

    Naming Consistency2/5

    Naming is inconsistent: some tools start with verbs (capture, compare, discover, get, read, start) while ui_diff_model_health is a noun phrase. Also mixing ui_diff and ui_diffs, and get vs read.

    Tool Count5/5

    7 tools is well-scoped for UI diffing: capture, two compare modes, background run management (start, status, report), and health check. No unnecessary tools.

    Completeness4/5

    Covers core workflow: capture, compare (sync/async), background run, report retrieval, model health. Minor gap: no tool to list or cancel runs, but not critical.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Analyzes app screenshots to identify UI/UX issues, compare designs with implementations, and provide actionable fixes using GPT-4o/GPT-5.2 vision capabilities. Supports single/batch analysis, design comparison, and automated report generation for iOS, Android, web, and desktop platforms.
      MIT
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Converts UI screenshots into validated, editable Flutter widgets, with visual diff comparison and preview.
      -