Skip to main content
Glama

a11y-toolkit: Nearest passing color

a11y_suggest_color
Read-onlyIdempotent

Suggests the nearest opaque foreground color that meets the target WCAG contrast ratio against a given background, returning the adjusted color, its ratio, and whether it lightens or darkens.

Instructions

Nearest opaque color (RGB distance) to fg that reaches the target ratio against bg (4.5 default). Returns the color, its ratio and whether it lightens or darkens. — The fixer companion to a11y_contrast_pair failures.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bgYesThe background it must pass against
fgYesThe failing foreground color to fix
targetNoRatio to reach: 4.5 normal text, 3.0 large text/UI, 7.0 AAA (default 4.5)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv4.0.0
    • addedInput schema / properties / bg / description
      Added value: +"The background it must pass against"
    • addedInput schema / properties / fg / description
      Added value: +"The failing foreground color to fix"
    • addedInput schema / properties / target / description
      Added value: +"Ratio to reach: 4.5 normal text, 3.0 large text/UI, 7.0 AAA (default 4.5)"
  2. First observedv2.3.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint. The description goes beyond those by explaining the algorithm (opaque, RGB distance), the default target ratio of 4.5, and what the function returns (color, ratio, lightens/darkens). There is no contradiction with annotations.

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?

The description is two compact sentences that front-load the core algorithm, then state the return value shape and the relationship to a11y_contrast_pair. No filler or redundant words; every clause earns its place.

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?

For a read-only, 3-parameter tool with 100% schema coverage and strong annotations, the description adequately explains the behavior and return values despite the lack of an output schema. It does not specify the accepted color-string format or edge cases (e.g., impossible targets), which is a minor gap but not a major one.

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?

Input schema coverage is 100%, with useful descriptions for fg, bg, and target including valid ratio values. The description adds algorithmic context ('nearest opaque', 'RGB distance') but mostly repeats the default 4.5 already present in the schema. It does not add input format or extra parameter meaning, so baseline 3 is appropriate.

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 clearly states a specific operation: find the nearest opaque color to fg that reaches the target ratio against bg. It also names the return type (color, ratio, lighten/darken) and explicitly frames itself as the fixer companion to a11y_contrast_pair, distinguishing it from the sibling tools.

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 explicitly tells the agent when to use this tool: as the fixer companion to a11y_contrast_pair failures. It does not explicitly list when not to use it or compare against a11y_autofix, so it is clear but lacks exclusion guidance.

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