Contrast Checker Mcp

io.github.ogSINGH由 GitHub 账号 ogSINGH 发布v1.0.1更新于 Oct 24, 2026

MCP - WCAG 2.1 color contrast checker - contrast ratios, compliance and accessible color suggestions

已验证STDIO仅桌面开发者工具媒体与设计

概览

AI 生成的概览

一个本地 MCP 服务器,让助手检查 WCAG 2.1 颜色对比度、判断无障碍合规性,并给出可访问的替代颜色建议。

可以做什么
检查前景色与背景色的对比度,并给出 WCAG 2.1 AA/AAA 的通过或未通过结果,包括带透明度时的合成有效颜色与解析后的颜色值。建议一个满足 AA 或 AAA 目标、且尽量接近原色相的前景色或背景色替换方案。将颜色字符串解析为 hex、rgb 和 hsl 格式。支持 hex、rgb/rgba、hsl/hsla 以及 CSS 命名颜色。
适用场景
适合在设计或审查界面配色、文字与背景时,快速获得与 WebAIM 一致的 WCAG 2.1 无障碍检查结果和具体的修改建议,无需离开助手。
运行要求
以 stdio 方式作为本地进程运行,通常通过 npm 包 contrast-checker-mcp 用 npx 启动,因此需要 Node.js 以及获取该软件包的网络访问。未声明任何认证、环境变量或请求头。
安装前请注意
属于只读计算工具,不会修改文件或向第三方发送数据。结果仅供参考,仍应结合自身的无障碍要求进行确认。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Contrast Checker Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

contrast-checker-mcp

An MCP server that provides color contrast checking tools for AI assistants. Verify WCAG 2.1 accessibility compliance, compute contrast ratios with alpha transparency support, and get accessible color suggestions — all via the standard Model Context Protocol.

Contrast calculations match WebAIM's contrast checker — including alpha compositing, WCAG 0.03928 sRGB threshold, and truncated (not rounded) ratios.

Tools

check_contrast

Check the contrast ratio between two colors and evaluate WCAG 2.1 compliance.

Inputs:

  • foreground — Foreground color (e.g. #333, rgb(0,0,0), rgba(0,0,0,0.5), navy)
  • background — Background color (e.g. #fff, rgb(255,255,255), white)

Output: Contrast ratio, WCAG 2.1 pass/fail results (AA normal, AA large, AAA normal, AAA large), parsed color values. When the foreground has alpha, shows the effective composited color used for the calculation.

suggest_accessible_color

Suggest a replacement color that meets a WCAG contrast target, keeping the hue as close to the original as possible.

Inputs:

  • foreground — Foreground color
  • background — Background color
  • target_level — "AA" or "AAA" (default: "AA")
  • fix — "foreground" or "background" (default: "foreground")

Output: A suggested replacement color (in hex, rgb, hsl) that meets the target level, along with the new contrast ratio.

parse_color

Parse a color string and return it in multiple formats.

Inputs:

  • color — Color to parse (e.g. #ff6600, rgb(255,102,0), tomato)

Output: The color in hex, rgb, and hsl formats.

Supported Color Formats

  • Hex: #rgb, #rrggbb, #rgba, #rrggbbaa
  • RGB: rgb(r, g, b), rgba(r, g, b, a)
  • HSL: hsl(h, s%, l%), hsla(h, s%, l%, a)
  • CSS named colors: red, cornflowerblue, rebeccapurple, etc.

Setup

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{  "mcpServers": {    "contrast-checker": {      "command": "npx",      "args": ["-y", "contrast-checker-mcp"]    }  }}

Claude Code

bash
claude mcp add contrast-checker npx -y contrast-checker-mcp

Cursor / VS Code

Add to .cursor/mcp.json or .vscode/mcp.json:

json
{  "servers": {    "contrast-checker": {      "command": "npx",      "args": ["-y", "contrast-checker-mcp"]    }  }}

From source

bash
git clone https://github.com/ogSINGH/contrast-checker-mcp.gitcd contrast-checker-mcpnpm installnpm run buildnode dist/index.js

Examples

Black on white — 21:1 ratio, all WCAG levels pass:

check_contrast({ foreground: "#000000", background: "#ffffff" })

Semi-transparent text — alpha composited onto background before checking:

check_contrast({ foreground: "rgba(0,0,0,0.5)", background: "#ffffff" })→ effective color #808080, ratio 3.94:1

Fix a failing color pair:

suggest_accessible_color({  foreground: "#777777",  background: "#ffffff",  target_level: "AA"})→ suggests #757575 (4.61:1)

License

Apache-2.0

来源:README.md,提交 03d231e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分