Skip to main content
Glama

Check color contrast

check_color_contrast
Read-onlyIdempotent

Check text and background color contrast against WCAG AA or AAA, report pass/fail, and suggest brand-aligned replacement colors when text fails.

Instructions

Check text contrast against the WCAG AA threshold (4.5:1, or 3:1 for large text); the AAA verdict is shown only when you pass level: "AAA". Either pass a foreground / background color pair, or pass url + selector to read the element's own text color, background (composited from the nearest painted ancestors), font size and weight from the live page; explicit colors win over the page. A gradient or image background is reported as an error, never a guessed ratio. When it fails, suggests BRAND-aligned replacements — extracts the actual brand palette from the url page using our scanner (CSS vars + most-used colors), or use a provided brandColors array. No url and no brandColors = ratio + pass/fail only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoLive page: with `selector`, the colors are read from that element; on a failing pair, the brand palette is extracted from it (uses our scanner — CSS vars + dominant colors).
levelNoConformance level to judge. Default "AA". "AAA" adds the enhanced-contrast (1.4.6) verdict and AAA palette suggestions.
isBoldNoWhether text is bold (default false, or the element's computed weight with url + selector)
fontSizeNoFont size in px (default 16, or the element's computed size with url + selector)
selectorNoCSS selector of the text element on `url` (e.g. the `selector` from a scan_page issue)
backgroundNoBackground color (hex or rgb). Optional with url + selector.
foregroundNoForeground color (hex or rgb). Optional with url + selector.
brandColorsNoPre-supplied brand palette. Skips URL extraction if provided.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.8.0
    • addedInput schema / properties / level
      Added value: +{
      +  "description": "Conformance level to judge. Default \"AA\". \"AAA\" adds the enhanced-contrast (1.4.6) verdict and AAA palette suggestions.",
      +  "enum": [
      +    "AA",
      +    "AAA"
      +  ],
      +  "type": "string"
      +}
  2. Changed7 schema fields changedv1.7.0
    • changedInput schema / properties / background / description
      Previous value: -"Background color (hex or rgb)"New value: +"Background color (hex or rgb). Optional with url + selector."
    • changedInput schema / properties / fontSize / description
      Previous value: -"Font size in px (default 16)"New value: +"Font size in px (default 16, or the element's computed size with url + selector)"
    • changedInput schema / properties / foreground / description
      Previous value: -"Foreground color (hex or rgb)"New value: +"Foreground color (hex or rgb). Optional with url + selector."
    • changedInput schema / properties / isBold / description
      Previous value: -"Whether text is bold (default false)"New value: +"Whether text is bold (default false, or the element's computed weight with url + selector)"
    • addedInput schema / properties / selector
      Added value: +{
      +  "description": "CSS selector of the text element on `url` (e.g. the `selector` from a scan_page issue)",
      +  "type": "string"
      +}
    • changedInput schema / properties / url / description
      Previous value: -"Live URL to extract brand palette from (uses our scanner — CSS vars + dominant colors)."New value: +"Live page: with `selector`, the colors are read from that element; on a failing pair, the brand palette is extracted from it (uses our scanner — CSS vars + dominant colors)."
    • removedInput schema / required
      Removed value: -[
      -  "foreground",
      -  "background"
      -]
  3. First observedv1.3.1

TDQS

A4.6/5.0
Behavior5/5

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

Adds substantial context beyond the annotations: the AA threshold values, AAA verdict only when level is 'AAA', error behavior for gradient/image backgrounds, brand-aligned replacement suggestions, and the scanner-based palette extraction. These details matter for correct use and interpretation.

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?

Dense but front-loaded: the core purpose and thresholds come first, then invocation modes, then edge cases and suggestions. Every clause adds useful information, though the single paragraph has many semicolon-separated ideas that could be slightly broken up.

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

Completeness5/5

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

For an 8-parameter tool with no output schema and rich behavior, the description covers thresholds, input modes, precedence rules, error handling, and output shapes (ratio + pass/fail, AAA verdict, brand suggestions). It gives the agent enough to call the tool correctly and anticipate results.

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 100%, so the baseline is 3. The description goes further by explaining precedence between explicit colors and live-page extraction, the compositing of background from nearest painted ancestors, and that brandColors skips URL extraction, adding meaningful behavioral semantics to the parameters.

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 specific verb and resource: 'Check text contrast against the WCAG AA threshold (4.5:1, or 3:1 for large text)'. It also distinguishes itself from siblings by referencing the selector from a scan_page issue and by scoping the tool to contrast checking rather than page-wide auditing.

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?

Explicitly describes the two main invocation modes: pass a foreground/background pair, or pass url + selector to read colors from the live page. It also clarifies precedence ('explicit colors win over the page') and the fallback behavior when neither url nor brandColors is provided. No explicit when-not-to-use guidance or named alternative tools.

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