Skip to main content
Glama

Check color contrast

check_color_contrast
Read-onlyIdempotent

Use this when the user wants to know whether a text, icon or border colour has enough contrast against a background: a WCAG contrast checker for one colour pair (e.g. "does white text on #F59E0B pass WCAG AA", "contrast ratio of #767676 on white", "what text color for this background"). Returns the computed WCAG 2.x ratio (truncated to 2 decimals, rounded down), AA/AAA results for normal text, large text and UI components, a verdict for a given font size, APCA Lc as draft information, and the nearest passing colours for AA and AAA (darker and lighter, same OKLCH hue and chroma). Accepts hex, 8-digit hex with alpha, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), color(display-p3 ...) and CSS colour names; wide-gamut colours are clipped to sRGB with a note. Does not read colours from images or web pages, resolve CSS variables or currentColor, or check gradients as a whole (check each stop). For 3 or more colours use check_palette_contrast.

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": "check_color_contrast"
  }
}

Input Schema

NameRequiredDescriptionDefault
boldNoOptional: true when that text is bold (font-weight 700+), e.g. true. Bold text from 18.66px counts as large text.
adjustNoWhich colour the suggested fixes change, e.g. foreground. auto (default) changes the more colourful of the two, so brand colours keep their hue.
backgroundYesBackground colour behind it, e.g. #FFFFFF, white or #1E293B. A translucent background is composited over white.
foregroundYesText, icon or border colour, e.g. #767676, #1E6FD980 (8-digit hex with alpha), rgb(118, 118, 118), hsl(214 76% 48%), oklch(55% 0.18 255) or a CSS colour name such as navy. Translucent colours are composited over the background.
font_size_pxNoOptional text size in CSS pixels for a single verdict on that text, e.g. 16. 18pt = 24px; 14pt = about 18.66px.

Output Schema

NameRequiredDescriptionDefault
apcaYes
kindYes
wcagYes
fixesYes
ratioYes
requestYes
warningsYes
ratio_4dpYes
your_textYes
backgroundYes
foregroundYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true and destructiveHint=false, so safety is covered; the description adds genuine value with return-shape detail (ratio truncated/rounded down, AA/AAA buckets, APCA draft, nearest passing colours in OKLCH) and colour-handling rules (alpha compositing, wide-gamut clipping to sRGB with a note). That is useful but largely restates what the output schema already carries.

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?

Front-loaded with the trigger condition and kept to a single dense paragraph where every clause carries information. It is on the long side and the enumeration of colour formats could be trimmed given the schema examples, but nothing is filler.

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 pure-function checker with an output schema, the description supplies everything needed: trigger cases, input format tolerance, compositing and gamut caveats, and what the results contain. No ambiguity remains about whether a given input is in scope.

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 per-parameter meaning (bold, adjust, font_size_px, foreground/background) is already fully documented in the schema. The description's contribution is the list of accepted colour notations, which does extend the schema's examples, but it does not explain adjust or bold behaviour beyond what the schema states.

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 concrete verb+resource (WCAG contrast checker for one colour pair) and immediately scopes it to text/icon/border against a background, with example user phrasings. It also names the sibling boundary explicitly: 'For 3 or more colours use check_palette_contrast.'

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?

Gives concrete trigger phrasing ('does white text on #F59E0B pass WCAG AA', 'what text color for this background') and explicit exclusions (no reading from images or pages, no CSS variables/currentColor, no whole-gradient checks). It routes multi-colour cases to check_palette_contrast, so the agent never has to guess between 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