Skip to main content
Glama

check_contrast

Computes WCAG contrast ratios between foreground and background colors and returns PASS/FAIL verdicts for normal and large text to verify AA compliance.

Instructions

Computes mathematical WCAG 2.x relative luminance contrast ratio between foreground and background colors. Non-destructive, read-only computation with no side effects, network access, or authentication. Automatically normalizes 3-digit hex (#fff -> #ffffff), 6-digit hex, and 8-digit hex (ignoring alpha). On malformed hex input, returns a descriptive error specifying expected hexadecimal syntax without throwing unhandled exceptions.

When to use: Call whenever selecting color pairs for text, UI containers, buttons, or badges to verify WCAG AA compliance (>= 4.5:1 for normal body text, >= 3.0:1 for large or bold text >= 18pt). When NOT to use: Do not use for retrieving comprehensive brand styling or palettes; use get_brand_design instead. Returns: Mathematical ratio (e.g. 21.00:1), RGB conversions, PASS/FAIL verdicts for normal and large text, and luminance adjustment suggestions.

Input Schema

NameRequiredDescriptionDefault
backgroundYesHex color for surface or container. Accepts 3-digit (#000), 6-digit (#08090a), or 8-digit hex strings with or without leading '#'. Case-insensitive. Required.
foregroundYesHex color for text or iconography. Accepts 3-digit (#fff), 6-digit (#ffffff), or 8-digit hex strings with or without leading '#'. Case-insensitive. Required.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.1.2
    • changedInput schema / properties / background / description
      Previous value: -"Hex color code for the surface or background container. Accepts 3-digit (#000) or 6-digit (#08090a) hex strings, with or without leading '#' (e.g. '#08090a', '#181726', '#000000')."New value: +"Hex color for surface or container. Accepts 3-digit (#000), 6-digit (#08090a), or 8-digit hex strings with or without leading '#'. Case-insensitive. Required."
    • changedInput schema / properties / foreground / description
      Previous value: -"Hex color code for the foreground text or icon. Accepts 3-digit (#fff) or 6-digit (#ffffff) hex strings, with or without leading '#' (e.g. '#FFFFFF', 'f97316', '#38bdf8')."New value: +"Hex color for text or iconography. Accepts 3-digit (#fff), 6-digit (#ffffff), or 8-digit hex strings with or without leading '#'. Case-insensitive. Required."
  2. Changed2 schema fields changedv0.1.2
    • changedInput schema / properties / background / description
      Previous value: -"Hex color of the background (e.g. '#000000' or '#120726')"New value: +"Hex color code for the surface or background container. Accepts 3-digit (#000) or 6-digit (#08090a) hex strings, with or without leading '#' (e.g. '#08090a', '#181726', '#000000')."
    • changedInput schema / properties / foreground / description
      Previous value: -"Hex color of the text (e.g. '#FFFFFF' or '#777777')"New value: +"Hex color code for the foreground text or icon. Accepts 3-digit (#fff) or 6-digit (#ffffff) hex strings, with or without leading '#' (e.g. '#FFFFFF', 'f97316', '#38bdf8')."
  3. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

With no annotations supplied, the description carries the full burden and does so: it declares the operation non-destructive and read-only, states there is no network access or authentication requirement, and describes malformed-input behavior (descriptive error rather than unhandled exception). It also discloses input normalization rules and the exact return contents.

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?

Front-loaded with the core operation, then cleanly sectioned into when-to-use, when-not-to-use, and returns. No filler sentences; each block serves a distinct decision the caller must make.

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 a two-parameter, non-destructive utility with no output schema, everything an agent needs is present: purpose, thresholds, routing to the sibling tool, input normalization, error behavior, and a description of the returned ratio and verdicts.

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 and the schema already documents accepted hex forms for both parameters. The description adds genuine meaning beyond that, notably that 8-digit hex has its alpha channel ignored and that normalization is automatic — details the schema does not state.

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 ('Computes ... WCAG 2.x relative luminance contrast ratio between foreground and background colors') and explicitly distinguishes itself from the sibling get_brand_design. An agent can tell instantly this is a two-color math check, not a palette lookup.

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?

Provides an explicit 'When to use' block tied to concrete scenarios (text, containers, buttons, badges) with the AA thresholds spelled out, plus a 'When NOT to use' block that names the alternative tool (get_brand_design) and the condition that selects it.

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