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), or what a color is in another format. 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"}. Also returns each color in hex, rgb, hsl and oklch with its nearest CSS name.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "foreground": "<foreground>",
      "background": "<background>"
    },
    "name": "swatch_check_contrast"
  }
}

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. Added

TDQS

A4.3/5.0
Behavior5/5

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

Annotations already establish that this is a safe, read-only, idempotent, non-destructive, closed-world operation, and the description goes well beyond that by disclosing the full return payload: exact ratio, AA/AAA verdicts per text size and UI component, APCA contrast, a plain note, and converted color formats. It also states the accepted input color syntaxes and gives a worked example, so nothing about behavior needs to be guessed.

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?

It is front-loaded with the trigger condition and then moves to return values, with no filler sentences. The trade-off is a single long run-on sentence with many parenthetical clauses, which makes it dense to parse even though every clause carries information.

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, so the description carries the return-value burden, and it does: it enumerates every verdict returned, the ratio, APCA, the note, and the color-format conversions. Combined with the input example and accepted color syntaxes, an agent has everything needed to call it and interpret the result.

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 two parameters are already documented with examples, making 3 the baseline. The description adds real meaning by widening the accepted syntaxes to include hsl() and CSS names and by explaining that foreground is a 'text (or icon) color' contrasted against background, which clarifies the role relationship beyond the schema's field-level examples.

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?

The description pairs a specific verb (check) with a specific resource (WCAG contrast between a text and background color) and enumerates the concrete verdicts produced (AA/AAA pass or fail for normal text, large text, UI components, plus APCA). It never distinguishes itself from the closest siblings (swatch_fix_contrast, swatch_check_pairs), so it stops short of the sibling-differentiation bar for a 5.

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?

The 'Use when the user asks whether...' clause gives a clear, concrete trigger (readable/accessible, passes WCAG AA or AAA, enough contrast for text/button/badge/link) and even covers the secondary format-conversion trigger. There is no when-not guidance and no named alternative for the fix or multi-pair cases, which are handled by siblings.

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