Fix contrast
colors_fixRestore 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
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | Minimum contrast ratio to reach. 4.5 = WCAG AA text (default), 3 = large text or UI parts, 7 = AAA text. | |
| keepHue | No | Keep the original hue (within 15 degrees) so the color still reads as the same one. Default true. | |
| background | Yes | The background color it sits on. Any CSS color. | |
| foreground | Yes | The text color that is too low in contrast. Any CSS color. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | No | ||
| found | Yes | ||
| ratio | No | ||
| target | Yes | ||
| changed | Yes | ||
| originalRatio | Yes |