Skip to main content
Glama

Check text/background contrast against WCAG

checkContrast

Calculate contrast ratio between foreground and background colors to verify WCAG 2.x legibility. Returns ratio and AA/AAA pass status; supports large text flag.

Instructions

Check whether a foreground color is legible on a background color per WCAG 2.x contrast ratios. Returns the ratio (1-21) and whether it passes AA and AAA. Set large=true for text >=18pt (or 14pt bold). This is the legibility axis, separate from color-blindness.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
largeNoTrue if text is >=18pt or 14pt bold (default false)
backgroundYesBackground hex color, e.g. #ffffff
foregroundYesText/foreground hex color, e.g. #767676

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations, the description carries the burden, and it does disclose the return contract (ratio 1-21 plus AA/AAA pass status) and that large=true changes the verdict. It omits edge behavior such as invalid hex input, but for a side-effect-free computation this is solid disclosure with no contradictions.

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?

Three tight sentences, front-loaded with purpose and return value, then the one non-obvious parameter rule and the disambiguation note. Nothing is padded, though the sibling clarification is thinner than it could be.

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?

No output schema exists, so the description must explain returns — and it does (ratio range plus AA/AAA outcome). Parameters are fully covered by the schema. Complete enough for a simple read-only check tool, with only minor gaps around invalid input handling.

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 the baseline is 3. The description restates the large=true threshold semantics that the schema already documents ('True if text is >=18pt or 14pt bold') and adds no new format or validation detail for foreground/background.

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

Purpose4/5

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

States a specific verb and resource: 'Check whether a foreground color is legible on a background color per WCAG 2.x contrast ratios.' It also positions itself as 'the legibility axis, separate from color-blindness,' which routes away from simulateColor. It does not, however, disambiguate from the arguably closer sibling checkPalette, so sibling differentiation is partial.

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

Usage Guidelines3/5

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

Usage is implied rather than stated: the tool is for contrast/legibility checks, and the color-blindness aside implicitly tells the agent when NOT to reach for it. There is no explicit 'use X instead when Y' rule, and the overlap with checkPalette is left for the agent to infer.

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