Skip to main content
Glama
Colors MCP Server

Colors MCP Server

by HtetOoWaiYan

Fix contrast

colors_fix
Read-onlyIdempotent

Restore readable text contrast by adjusting a foreground color to the closest same-hue shade that meets a target ratio against a fixed background, returning the hex value and verified ratio.

Instructions

Make a text color readable: returns the closest color (same hue) that reaches the target contrast ratio on the given background. Use after a contrast check fails, or to pick an accessible text color. The background stays fixed. Returns one hex color and its verified ratio.

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

Input Schema

NameRequiredDescriptionDefault
targetNoMinimum contrast ratio to reach. 4.5 = WCAG AA text (default), 3 = large text or UI parts, 7 = AAA text.
keepHueNoKeep the original hue (within 15 degrees) so the color still reads as the same one. Default true.
backgroundYesThe background color it sits on. Any CSS color.
foregroundYesThe text color that is too low in contrast. Any CSS color.

Output Schema

NameRequiredDescriptionDefault
colorNo
foundYes
ratioNo
targetYes
changedYes
originalRatioYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.1.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive, so the safety profile is covered. The description still adds real value: it discloses the transformation policy (closest color, same hue), that the background is left unchanged, and that a verified ratio is returned alongside the hex.

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?

Three short sentences, front-loaded with the core behavior, followed by usage and the return contract. No filler or repetition.

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 single-result computation with a full schema and an output schema, this covers purpose, trigger, constraints, and return shape adequately. Only minor gaps remain, such as what happens when the target is unreachable.

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 all four parameters are already documented, including target, keepHue, background, and foreground. The description reinforces 'target contrast ratio' and 'given background' and clarifies the background stays fixed, but adds no format or syntax detail beyond the schema. Baseline 3 applies.

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 and resource: returns the closest same-hue color reaching a target contrast ratio against a given background. It is clearly distinguishable from colors_check (verification) and colors_adjust (general adjustment) by the explicit 'make readable / nearest compliant color' framing.

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?

Gives concrete trigger conditions: 'Use after a contrast check fails, or to pick an accessible text color.' That covers the main entry points without naming an explicit alternative or exclusion, so it stops short of a 5.

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