Skip to main content
Glama

Ajustar color para cumplir contraste

color-contrast-fix
Read-onlyIdempotent

Encuentra el color más cercano (variando solo la luminosidad OKLCH) que alcanza un contraste WCAG objetivo contra un fondo. Cuándo: hay que calcular con exactitud colores, contrastes o paletas, p. ej. para revisar accesibilidad. No para: calcular la relación de contraste WCAG entre dos colores (color-contrast). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.

EN: Finds the closest color to a foreground (changing only OKLCH lightness, keeping hue) that reaches a target WCAG contrast ratio against a background, trying darker and lighter directions. When: color values, contrast or palettes have to be computed exactly, e.g. for accessibility checks. Not for: computing the WCAG contrast ratio of two colors (color-contrast). Side effects: none (read-only, no network access, no stored state). [EN completo / full EN: inputSchema.description]

Input Schema

NameRequiredDescriptionDefault
backgroundYesBackground (string; required; up to 100 chars).
foregroundYesColor to adjust (string; required; up to 100 chars).
target_ratioNoTarget ratio (number; optional; default 4.5; min 1; max 21).

Output Schema

NameRequiredDescriptionDefault
colorNo
ratioNo
changedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / background / examples
      Added value: +[
      +  "#ffffff"
      +]
    • addedInput schema / properties / foreground / examples
      Added value: +[
      +  "#777777"
      +]
  2. Changed1 schema field changed
    • addedInput schema / description
      Added value: +"EN: Finds the closest color to a foreground (changing only OKLCH lightness, keeping hue) that reaches a target WCAG contrast ratio against a background, trying darker and lighter directions. When: color values, contrast or palettes have to be computed exactly, e.g. for accessibility checks. Not for: computing the WCAG contrast ratio of two colors (color-contrast). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB."
  3. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare read-only, no-network, idempotent and non-destructive, and the description reinforces this ('sin red, sin estado guardado') plus adds genuinely new constraints: 64 KB input cap, 1 s per call, 1 MB result cap. The determinism claim largely restates idempotentHint, so it is confirmatory rather than new, keeping this below 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Content is front-loaded and well ordered (what → when/not → effects → limits), but the same text is duplicated in Spanish and English and ends with an awkward artifact ('[EN completo / full EN: inputSchema.description]') that adds no information. Roughly half the length is redundant.

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?

With an output schema present, return-value details need not be described, and when/when-not, side effects, determinism and resource limits are all covered. One gap: it never says what happens when the target ratio is unreachable (e.g. ratio 21 for a given pair) — a failure mode an agent calling this tool should anticipate.

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 coverage is 100% with per-parameter descriptions, defaults and min/max for target_ratio, so the schema already carries parameter meaning. The description adds conceptual context (lightness-only adjustment, WCAG target) but no format details for foreground/background beyond the schema examples.

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 specific verb+resource: finds the closest color to a foreground by varying only OKLCH lightness (keeping hue) until a target WCAG contrast ratio against a background is met, trying darker and lighter directions. The mechanism is precise enough that an agent can predict the output transformation, and it is clearly distinguished from color-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?

Explicit 'Cuándo' (compute color values/contrast/palettes exactly, e.g. accessibility checks) and explicit 'No para' naming the sibling color-contrast for merely measuring the ratio between two colors. The routing decision between the two tools is fully determined.

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