Skip to main content
Glama

a11y-toolkit: Text-over-image contrast

a11y_contrast_image
Read-onlyIdempotent

Checks WCAG contrast for text over photos or gradients by sampling the actual background pixels, returning worst, median, and p95 ratios, AA pass area, and hostile zones.

Instructions

TEXT OVER IMAGE contrast: pixel-level sampling of the real background behind the text box → worst/median/p95 ratio, % of area passing AA, and automatic hostile-zone detection on a 3×3 grid (worst_zone). What pair-only checkers cannot do. region="x,y,w,h" recommended. — Use instead of a11y_contrast_pair whenever the background is a photo/gradient. Returns JSON: {worst_ratio, median_ratio, p95_ratio, area_passes_aa_normal_text_4_5, worst_zone, sampled_pixels}.

Input Schema

NameRequiredDescriptionDefault
langNoOutput language (default en)
pathYesLocal path to the screenshot/image the text sits on (PNG/JPG/PPM)
regionNoText bounding box as "x,y,width,height" in pixels (strongly recommended: defines what to sample)
sampleNoPixel step: 4 samples every 4px (auto-raised for huge regions)
text_colorYesThe text color as rendered over the image (must be opaque)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv4.0.0
    • addedInput schema / properties / lang / description
      Added value: +"Output language (default en)"
    • addedInput schema / properties / path / description
      Added value: +"Local path to the screenshot/image the text sits on (PNG/JPG/PPM)"
    • addedInput schema / properties / region / description
      Added value: +"Text bounding box as \"x,y,width,height\" in pixels (strongly recommended: defines what to sample)"
    • addedInput schema / properties / sample / description
      Added value: +"Pixel step: 4 samples every 4px (auto-raised for huge regions)"
    • addedInput schema / properties / text_color / description
      Added value: +"The text color as rendered over the image (must be opaque)"
  2. First observedv2.3.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint/idempotentHint/non-destructive, so safety is covered; the description instead adds behavioral substance — that sampling is pixel-level over the real rendered background, that a 3×3 hostile-zone grid is computed, and the shape of the result. It stops short of noting failure/edge behavior (e.g. what happens without region, or with translucent text_color), keeping it below a 5.

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

Conciseness4/5

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

Front-loaded with the distinguishing capability and the sibling routing in the first two sentences; the return-field list is justified because no output schema exists. The telegraphic arrow/em-dash style is dense but readable, with only slight redundancy around region.

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 5-parameter, no-output-schema tool the description is essentially complete: capability, inlining of the return fields, and the sibling decision rule are all present. The remaining minor gap is that it doesn't say what happens when region is omitted despite the sampling depending on it.

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

Parameters3/5

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

Schema description coverage is 100%, so all five parameters are already documented, and the description adds only the reminder that region is "x,y,w,h" and recommended — which restates the schema's own 'strongly recommended' note. Baseline 3 is correct when the schema does the semantic work.

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?

The description states a specific verb and resource ('TEXT OVER IMAGE contrast: pixel-level sampling of the real background behind the text box') and enumerates exactly what the tool produces (worst/median/p95 ratio, % area passing AA, worst_zone). It explicitly positions itself against a named sibling, so an agent can distinguish it from a11y_contrast_pair without opening the schema.

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

Usage Guidelines5/5

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

It names the alternative outright — 'Use instead of a11y_contrast_pair whenever the background is a photo/gradient' — which is an explicit when/when-not rule with the selector condition stated. It also advises when to pass region ('recommended'), covering the main invocation choice.

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