MCP (Model Context Protocol) server providing accessibility analysis tools for WCAG 2.1 conformance.
This MCP server provides programmatic tools for color contrast analysis according to WCAG 2.1 standards. It's designed to be used with Claude Desktop and as part of the AccessLint marketplace plugin for Claude Code.
Install and configure the MCP server in your Claude Desktop configuration:
{
"mcpServers": {
"accesslint": {
"command": "npx",
"args": ["-y", "@accesslint/mcp"]
}
}
}Or install globally:
npm install -g @accesslint/mcpThen configure with:
{
"mcpServers": {
"accesslint": {
"command": "accesslint-mcp"
}
}
}This MCP server is automatically included when you install the AccessLint plugin from the marketplace:
# In Claude Code, the plugin includes this MCP server
# No separate installation neededCalculate the WCAG contrast ratio between two colors.
Parameters:
foreground(string, required): Foreground color in hex (#RGB, #RRGGBB), rgb(r,g,b), or rgba(r,g,b,a) formatbackground(string, required): Background color in the same formats
Returns:
{
"foreground": "#7c8aff",
"background": "#ffffff",
"ratio": 2.8
}Example:
calculate_contrast_ratio({
foreground: "#7c8aff",
background: "#ffffff"
})Analyze a color pair for WCAG conformance with detailed pass/fail information.
Parameters:
foreground(string, required): Foreground colorbackground(string, required): Background colorcontentType(enum, optional): Type of content being checked"normal-text"(default): Regular text content (requires 4.5:1 for AA)"large-text": Large text 18pt+ or 14pt+ bold (requires 3:1 for AA)"ui-component": UI component boundaries, icons (requires 3:1 for AA)
level(enum, optional): WCAG conformance level"AA"(default): Level AA conformance"AAA": Level AAA conformance
Returns:
{
"foreground": "#7c8aff",
"background": "#ffffff",
"ratio": 2.8,
"passes": {
"normalText": false,
"largeText": false,
"uiComponent": false
},
"requirement": {
"level": "AA",
"contentType": "normal-text",
"minimumRatio": 4.5,
"guideline": "1.4.3 Contrast (Minimum)"
},
"meetsRequirement": false
}Example:
analyze_color_pair({
foreground: "#4c5dcc",
background: "#ffffff",
contentType: "normal-text",
level: "AA"
})Get accessible color alternatives that meet WCAG requirements while preserving design intent.
Parameters:
foreground(string, required): Current foreground colorbackground(string, required): Current background colortargetRatio(number, required): Target contrast ratio (e.g., 4.5 for normal text, 3.0 for large text)preserve(enum, optional): Which color to preserve"both"(default): Suggest adjustments to either foreground or background"foreground": Only suggest background color changes"background": Only suggest foreground color changes
Returns:
{
"original": {
"foreground": "#7c8aff",
"background": "#ffffff"
},
"targetRatio": 4.5,
"suggestions": [
{
"color": "#4c5dcc",
"ratio": 4.6,
"adjustedProperty": "foreground"
},
{
"color": "#e8ebff",
"ratio": 4.52,
"adjustedProperty": "background"
}
]
}Example:
suggest_accessible_color({
foreground: "#7c8aff",
background: "#ffffff",
targetRatio: 4.5,
preserve: "both"
})- Normal text: 4.5:1 minimum for Level AA
- Large text (18pt+ or 14pt+ bold): 3:1 minimum for Level AA
Important: Text in UI components (buttons, inputs, etc.) must meet TEXT contrast requirements, not UI component thresholds.
- Visual boundaries (borders, outlines): 3:1 minimum for Level AA
- Component states (focus, hover, selected): 3:1 minimum for Level AA
- Icons without text: 3:1 minimum for Level AA
The AccessLint reviewer and refactor agents have access to these tools via the MCP protocol. Tools are automatically prefixed with mcp__accesslint__ when used in agent contexts.
Example in reviewer agent:
// Analyze colors found in component
const analysis = await mcp__accesslint__analyze_color_pair({
foreground: "#7c8aff",
background: "#ffffff",
contentType: "normal-text"
});
if (!analysis.meetsRequirement) {
// Get accessible alternatives
const suggestions = await mcp__accesslint__suggest_accessible_color({
foreground: "#7c8aff",
background: "#ffffff",
targetRatio: 4.5
});
// Report findings...
}npm run buildCompiles TypeScript to JavaScript in the dist/ directory.
npm run watchAutomatically recompile on file changes during development.
mcp-server/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── color-utils.ts # Color parsing and conversion
│ └── wcag-contrast.ts # WCAG contrast analysis logic
├── dist/ # Compiled JavaScript (committed to git)
├── package.json
└── tsconfig.json
This MCP server is automatically configured when the AccessLint plugin is installed. The configuration in plugins/accesslint/.mcp.json tells Claude Code how to start the server:
{
"mcpServers": {
"accesslint": {
"command": "node",
"args": ["${CLAUDE_PLUGIN_ROOT}/mcp-server/dist/index.js"]
}
}
}- Hex:
#RGB,#RRGGBB(e.g.,#f00,#ff0000) - RGB:
rgb(r, g, b)(e.g.,rgb(255, 0, 0)) - RGBA:
rgba(r, g, b, a)(alpha channel is ignored for contrast calculations)
Implements the official WCAG 2.1 relative luminance and contrast ratio formulas:
- Convert to sRGB: RGB values normalized to 0-1 range
- Apply gamma correction: Account for non-linear perception
- Calculate relative luminance:
L = 0.2126 * R + 0.7152 * G + 0.0722 * B - Compute contrast ratio:
(L1 + 0.05) / (L2 + 0.05)where L1 is lighter
When suggesting accessible colors, the algorithm:
- Converts colors to HSL (Hue, Saturation, Lightness)
- Preserves hue and saturation to maintain design intent
- Uses binary search to find optimal lightness value
- Returns the adjustment closest to original that meets target ratio
MIT
AccessLint