Skip to main content
Glama

Check the WCAG contrast of a text and background color

swatch_check_contrast
Read-onlyIdempotent

Use when the user asks whether a color combination is readable or accessible, passes WCAG AA or AAA, or has enough contrast (text on a background, button, badge, link color). Returns the exact contrast ratio, pass or fail for normal text, large text and UI components at AA and AAA, the APCA lightness contrast and a plain note. Colors can be hex, rgb(), hsl() or CSS names. Example: {"foreground": "#777777", "background": "#ffffff"}. Language models cannot compute this reliably, so call it instead of guessing.

Input Schema

NameRequiredDescriptionDefault
backgroundYesBackground color, e.g. "#ffffff".
foregroundYesText (or icon) color, e.g. "#767676" or "rgb(20 20 20)" or "tomato".

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare this is a safe, idempotent, closed-world read, so the safety profile is covered. The description goes further and discloses the return payload in detail: exact contrast ratio, pass/fail for normal text, large text and UI components at both AA and AAA, plus APCA lightness contrast and a plain note. That is meaningful output context not available anywhere in the structured data.

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 usage trigger, followed by return contents, accepted formats, an inline example, and a closing rationale for not guessing. Every sentence carries distinct information and nothing is padded.

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?

There is no output schema, and the description compensates by specifying exactly what comes back. With only two well-documented parameters and annotations covering safety, an agent has everything needed to select and call this correctly.

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 labels foreground as text/icon color and background as the backdrop. The description adds accepted input formats — hex, rgb(), hsl() and CSS color names — extending beyond the schema examples (which omit hsl()), and supplies a worked example object.

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 — checking the WCAG contrast ratio of a foreground/background color pair — and the title reinforces it. It is clearly distinguishable from siblings like swatch_fix_contrast or swatch_pick_text_color, which act on the result rather than reporting it.

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?

It gives an explicit trigger: 'Use when the user asks whether a color combination is readable or accessible, passes WCAG AA or AAA, or has enough contrast,' and enumerates concrete scenarios (text on background, button, badge, link). It also justifies itself against the alternative of the model guessing. What it lacks is a pointer to the sibling to call when the check fails (e.g., swatch_fix_contrast).

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources