Skip to main content
Glama

a11y-toolkit: Text-over-image contrast

a11y_contrast_image
Read-onlyIdempotent

Sample the real background behind text to compute contrast ratios, AA pass percentage, and detect hostile zones in images with photos or gradients.

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 (zona_peor). 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.

Input Schema

TableJSON 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.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and non-destructiveHint. The description goes beyond this by detailing the computational behavior—sampling real background pixels, producing specific ratio metrics, and performing 3x3 grid hostile-zone detection. It does not contradict annotations and adds meaningful context about what the tool actually computes.

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

Conciseness5/5

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

The description is two sentences, front-loaded with the core purpose, and wastes no words. It uses compact arrow notation to list outputs and ends with a clear usage directive. Every sentence contributes to understanding or selecting the tool.

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 with no output schema, the description sufficiently outlines the expected outputs (worst/median/p95 ratio, % area passing AA, hostile-zone detection). It also covers usage context and the key parameter recommendation. Minor gaps like exact output key names or error handling are not critical given the provided detail.

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 parameters (lang, path, region, sample, text_color) have individual descriptions. The tool description redundantly recommends region='x,y,w,h', which mirrors the schema's 'strongly recommended' note. No additional parameter meaning is provided beyond the schema, so a baseline score of 3 is appropriate.

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 clearly states the tool performs pixel-level contrast sampling of the real background behind text, computing worst/median/p95 ratios, % area passing AA, and hostile-zone detection. It explicitly contrasts with 'pair-only checkers' and names the sibling a11y_contrast_pair, making its unique purpose unmistakable.

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 gives an explicit directive: 'Use instead of a11y_contrast_pair whenever the background is a photo/gradient.' It also recommends setting region as 'x,y,w,h' for accurate sampling, providing actionable guidance on when and how to invoke the tool.

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