Skip to main content
Glama
XC-MCP: XCode CLI wrapper

XC-MCP: XCode CLI wrapper

by conorluddy

Compare Screenshots (Pixel Diff)

visual-diff
Idempotent

Compare two PNG screenshots pixel-by-pixel to detect visual regressions, then write a highlighted diff image and a JSON pass/fail report.

Instructions

visual-diff

algorithm: skill uses the reference script’s grayscale noise cutoff (>10); pixelmatch is the default. Both write diff.png, side-by-side.png, and the JSON report.

Compare two PNG screenshots pixel-by-pixel using pixelmatch to detect visual regressions. Writes a highlighted diff image and a JSON report to the output directory.

What it does

Reads two PNG files, compares them pixel-by-pixel, and:

  • Reports the number and percentage of differing pixels

  • Determines pass/fail against a configurable threshold

  • Writes diff.png with highlighted differences (red pixels where images differ)

  • Writes diff-report.json with full metrics

Parameters

  • baselinePath (string, required): Path to the baseline (reference) PNG

  • currentPath (string, required): Path to the current (test) PNG

  • outputDir (string, optional): Directory for diff.png and diff-report.json. Defaults to the directory containing currentPath

  • threshold (number, optional): Maximum acceptable ratio of different pixels (0.01 = 1%). Default: 0.01

Returns

Text summary and structuredContent:

  • differentPixels: Count of pixels that differ

  • differencePercentage: Ratio of different pixels to total pixels (0–1)

  • passed: true if differencePercentage <= threshold

Artifacts Written

  • diff.png: Diff image highlighting changed pixels (pixelmatch output)

  • diff-report.json: JSON with baseline, current, dimensions, totalPixels, differentPixels, differencePercentage, thresholdPercentage, passed

Errors

Throws McpError(InvalidRequest) for:

  • Missing baseline or current file

  • Dimension mismatch between images

  • PNG read failures

Examples

Basic diff

await visualDiffTool({
  baselinePath: '/tmp/before.png',
  currentPath: '/tmp/after.png'
})

Custom output directory and strict threshold

await visualDiffTool({
  baselinePath: '/tmp/before.png',
  currentPath: '/tmp/after.png',
  outputDir: '/tmp/diffs',
  threshold: 0.001
})

Zero-tolerance regression check

await visualDiffTool({
  baselinePath: '/snapshots/login-baseline.png',
  currentPath: '/snapshots/login-current.png',
  threshold: 0
})

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "baselinePath": "<baselinePath>",
      "currentPath": "<currentPath>"
    },
    "name": "visual-diff"
  }
}

Input Schema

NameRequiredDescriptionDefault
algorithmNo
outputDirNo
thresholdNo
currentPathYes
baselinePathYes

Output Schema

NameRequiredDescriptionDefault
passedYes
differentPixelsYes
differencePercentageYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv5.0.0
    • addedInput schema / properties / algorithm
      Added value: +{
      +  "enum": [
      +    "pixelmatch",
      +    "skill"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / threshold / maximum
      Added value: +1
    • addedInput schema / properties / threshold / minimum
      Added value: +0
  2. Addedv4.1.0

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare non-read-only, idempotent, non-destructive, closed-world; the description adds genuinely new behavior — files are written to outputDir (defaulting to currentPath's directory), dimension mismatches and PNG read failures throw McpError(InvalidRequest), and the pass/fail rule is differencePercentage <= threshold. A minor internal inconsistency remains: the preamble claims both algorithms write 'side-by-side.png', but the Artifacts Written section lists only diff.png and diff-report.json.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well structured with headed sections that are skimmable, but it repeats itself: 'Writes a highlighted diff image and a JSON report to the output directory' echoes the 'What it does' bullets, and a stray preamble line about algorithms sits detached above the summary. Three code examples for a five-parameter tool is more than earns its place, especially when none exercises the algorithm parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that writes artifacts, the description covers outputs, defaults, error conditions, and pass/fail semantics in detail, and an output schema exists so return-value enumeration is redundant but harmless. The gaps are the undocumented algorithm enum semantics and the side-by-side.png ambiguity, both of which could cause a mis-invocation or surprise artifact.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must carry the burden — and it documents baselinePath, currentPath, outputDir (with the default), and threshold (range meaning, 0.01 = 1%, default) clearly. The fifth parameter, algorithm, is only covered by a cryptic preamble line ('skill uses the reference script's grayscale noise cutoff (>10); pixelmatch is the default') and is absent from the Parameters section and from the otherwise thorough examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a concrete verb and resource: 'Compare two PNG screenshots pixel-by-pixel using pixelmatch to detect visual regressions.' No sibling tool in the list does image diffing (screenshot, accessibility-audit, app-state-capture are adjacent but distinct), so the agent can route correctly from the name and first sentence alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The examples make the intended contexts explicit — basic before/after diff, strict threshold, and 'zero-tolerance regression check' with threshold 0 — which tells the agent when this tool applies. It never states when not to use it or names an alternative tool for related needs (e.g. accessibility-audit for a11y regressions), so it stops short of full when/when-not guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.