Color contrast wcag

color-contrast-wcag · version 1.0.0 · Geometry, location & color · free, no key needed

Compute WCAG 2.x relative luminance, contrast ratio, and AA/AAA pass flags for two opaque sRGB colors.

Use when you need to: compute WCAG color contrast · check text color accessibility · calculate contrast ratio between colors.

Decide before calling

Read the versioned contract and the supported scope below. Reuse color-contrast-wcag@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use color-contrast-wcag@1.0.0 for compute WCAG color contrast. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "foreground": "#000000",
  "background": "#FFFFFF"
}

Response:

{
  "result": {
    "foreground": {
      "hex": "#000000",
      "r": 0,
      "g": 0,
      "b": 0,
      "relative_luminance": "0.000000"
    },
    "background": {
      "hex": "#FFFFFF",
      "r": 255,
      "g": 255,
      "b": 255,
      "relative_luminance": "1.000000"
    },
    "contrast_ratio": "21.00",
    "passes": {
      "aa_normal": true,
      "aa_large": true,
      "aaa_normal": true,
      "aaa_large": true
    }
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "color-contrast-wcag",
  "version": "1.0.0",
  "input": {
    "foreground": "#000000",
    "background": "#FFFFFF"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/color-contrast-wcag/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"foreground":"#000000","background":"#FFFFFF"}'

The machine-readable contract is at /v1/tools/color-contrast-wcag/versions/1.0.0.

CLI

node cli.mjs run color-contrast-wcag 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.