MCP Color Server
Enables comprehensive color manipulation, conversion between 22+ formats (HEX, RGB, HSL, CMYK, LAB, etc.), palette generation, gradient creation, and accessibility compliance checking. Supports framework-specific outputs for CSS, Swift, Android, Flutter, and Tailwind with high-precision conversions and visualization capabilities.
README
MCP Color Server
A comprehensive Model Context Protocol (MCP) server that provides advanced color manipulation, palette generation, gradient creation, and visualization capabilities to AI applications.
Features
- Comprehensive Color Format Support: Convert between 22+ formats including HEX, RGB, HSL, HSV, HWB, CMYK, LAB, XYZ, LCH, OKLAB, OKLCH, and named colors
- Framework Integration: Native support for CSS variables, SCSS, Tailwind classes, Swift UIColor, Android Color, and Flutter Color formats
- High-Precision Conversion: Configurable precision up to 10 decimal places for scientific and professional applications
- Palette Generation: Create harmonious color palettes based on color theory principles
- Gradient Creation: Generate linear, radial, and conic gradients with advanced interpolation
- Accessibility Compliance: WCAG 2.1 AA/AAA contrast checking and colorblind simulation
- Visualization Generation: Create interactive HTML and high-quality PNG visualizations
- Theme Generation: Generate complete design system themes with semantic color mapping
- Performance Optimized: Sub-100ms response times for all color operations with intelligent caching
Installation
Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn package manager
Install Dependencies
npm install
Development Setup
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Lint code
npm run lint
# Format code
npm run format
Usage
As an MCP Server
The color server implements the Model Context Protocol and can be used with any MCP-compatible client.
Configuration
Add to your MCP client configuration:
{
"mcpServers": {
"color": {
"command": "node",
"args": ["path/to/mcp-color-server/dist/index.js"]
}
}
}
Available Tools
convert_color: Convert colors between different formatsanalyze_color: Analyze color properties (brightness, contrast, temperature)generate_harmony_palette: Create color palettes based on harmony principlesgenerate_gradient: Create CSS gradients with advanced optionscheck_contrast: Verify WCAG accessibility compliancecreate_palette_html: Generate interactive HTML visualizationscreate_palette_png: Generate high-quality PNG images
Supported Color Formats
Input Formats
The MCP Color Server accepts colors in any of these formats:
Standard Web Formats
- HEX:
#FF0000,#F00,FF0000,F00 - RGB:
rgb(255, 0, 0),255, 0, 0,255 0 0,[255, 0, 0] - RGBA:
rgba(255, 0, 0, 0.5) - HSL:
hsl(0, 100%, 50%),0, 100%, 50% - HSLA:
hsla(0, 100%, 50%, 0.8) - HSV/HSB:
hsv(0, 100%, 100%),hsb(0, 100%, 100%) - HSVA:
hsva(0, 100%, 100%, 0.7)
Advanced Color Spaces
- HWB:
hwb(0, 0%, 0%) - CMYK:
cmyk(0%, 100%, 100%, 0%) - LAB:
lab(53.23, 80.11, 67.22) - XYZ:
xyz(41.24, 21.26, 1.93) - LCH:
lch(53.23, 104.55, 40.85) - OKLAB:
oklab(0.628, 0.225, 0.126) - OKLCH:
oklch(0.628, 0.258, 29.23)
Named Colors
- CSS Named Colors:
red,blue,forestgreen,lightsteelblue, etc.
Output Formats
Convert to any of these formats with configurable precision:
Web Development
{
"color": "#FF0000",
"output_format": "hex"
}
// Result: "#ff0000"
{
"color": "#FF0000",
"output_format": "rgb"
}
// Result: "rgb(255, 0, 0)"
{
"color": "#FF0000",
"output_format": "hsl",
"precision": 1
}
// Result: "hsl(0.0, 100.0%, 50.0%)"
CSS Variables
{
"color": "#FF0000",
"output_format": "css-var",
"variable_name": "primary-color"
}
// Result: "--primary-color: #ff0000;"
{
"color": "#FF0000",
"output_format": "scss-var",
"variable_name": "accent_color"
}
// Result: "$accent_color: #ff0000;"
Mobile Development
{
"color": "#FF0000",
"output_format": "swift",
"precision": 3
}
// Result: "UIColor(red: 1.000, green: 0.000, blue: 0.000, alpha: 1.000)"
{
"color": "#FF0000",
"output_format": "android"
}
// Result: "Color.parseColor(\"#FFFF0000\")"
{
"color": "#FF0000",
"output_format": "flutter"
}
// Result: "Color(0xFFFF0000)"
Framework Integration
{
"color": "#FF0000",
"output_format": "tailwind"
}
// Result: "red-500"
Scientific/Professional
{
"color": "#FF0000",
"output_format": "lab",
"precision": 6
}
// Result: "lab(53.230000, 80.110000, 67.220000)"
{
"color": "#FF0000",
"output_format": "oklab",
"precision": 8
}
// Result: "oklab(0.62800000, 0.22500000, 0.12600000)"
Usage Examples
Basic Color Conversion
// Convert HEX to RGB
{
"tool": "convert_color",
"parameters": {
"color": "#FF0000",
"output_format": "rgb"
}
}
// Convert RGB to HSL with high precision
{
"tool": "convert_color",
"parameters": {
"color": "rgb(255, 128, 64)",
"output_format": "hsl",
"precision": 4
}
}
Advanced Color Space Conversions
// Convert to LAB color space for perceptual uniformity
{
"tool": "convert_color",
"parameters": {
"color": "#FF8040",
"output_format": "lab",
"precision": 3
}
}
// Convert to OKLCH for modern color workflows
{
"tool": "convert_color",
"parameters": {
"color": "hsl(25, 100%, 69%)",
"output_format": "oklch",
"precision": 5
}
}
Framework-Specific Outputs
// Generate Swift UIColor
{
"tool": "convert_color",
"parameters": {
"color": "#2563eb",
"output_format": "swift",
"precision": 3
}
}
// Generate Tailwind CSS class
{
"tool": "convert_color",
"parameters": {
"color": "#ef4444",
"output_format": "tailwind"
}
}
// Generate CSS custom property
{
"tool": "convert_color",
"parameters": {
"color": "#10b981",
"output_format": "css-var",
"variable_name": "success-color"
}
}
Performance Characteristics
- Single Conversions: < 100ms response time
- Batch Operations: < 20ms average per conversion
- High Precision: Up to 10 decimal places without performance impact
- Memory Efficient: Optimized for concurrent operations
- Caching: Intelligent caching for frequently converted colors
Direct Usage
import { ColorServer } from './src/server.js';
const server = new ColorServer();
// Server usage examples will be added as implementation progresses
Development
Project Structure
mcp-color-server/
├── src/ # Source code
│ ├── server.ts # Main MCP server implementation
│ ├── tools/ # Tool implementations
│ ├── validation/ # Input validation schemas
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── tests/ # Test files
├── docs/ # Documentation
├── examples/ # Usage examples
└── dist/ # Compiled output
Code Quality
This project maintains high code quality standards with automated Git hooks:
- Pre-commit Hooks: Automatic linting, formatting, and type checking on staged files
- Pre-push Hooks: Full test suite with 90%+ coverage requirements and build verification
- Commit Message Validation: Enforces conventional commit format
- Zero-Defect Policy: No TypeScript errors, ESLint warnings, or failing tests allowed
See Husky Setup Documentation for detailed information about our Git hooks.
- TypeScript: Strict mode enabled with comprehensive type checking
- ESLint: Enforces code style and catches potential issues
- Prettier: Automatic code formatting
- Jest: Comprehensive test suite with 90%+ coverage requirement
- Continuous Integration: Automated testing and quality checks
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
Testing
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverage
# Run specific test file
npm test -- server.test.ts
Building
# Clean previous build
npm run clean
# Build for production
npm run build
# Type check without building
npm run type-check
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Code of Conduct
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: docs/
Roadmap
See our project roadmap for planned features and improvements.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。