Skip to main content
Glama
deepakkumardewani

Color Scheme Generator MCP Server

generate_monochrome_dark_scheme

Generate a dark monochrome color scheme from a seed color for design projects, specifying the number of colors to create.

Instructions

Generates a dark monochrome color scheme

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
colorYesThe seed color in hex (098765), RGB (0,71,171), or HSL (215,100%,34%) format
countNoNumber of colors to generate (3-10, default: 5)

Implementation Reference

  • The inline async handler for the 'generate_monochrome_dark_scheme' tool. Destructures input args, invokes the generateColorScheme helper with 'monochrome-dark' mode, formats the result as JSON text content.
    async (args) => { const { color, count } = args; const result = await generateColorScheme(color, "monochrome-dark", count); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
  • Shared Zod input schema used by 'generate_monochrome_dark_scheme' and other color scheme tools: requires 'color' string, optional 'count' integer (3-10, default 5).
    const colorSchemeInputShape = { color: z .string() .describe( "The seed color in hex (098765), RGB (0,71,171), or HSL (215,100%,34%) format" ), count: z .number() .int() .min(3) .max(10) .default(5) .optional() .describe("Number of colors to generate (3-10, default: 5)"), };
  • The registration function that calls server.tool to register 'generate_monochrome_dark_scheme' with description, schema, and handler. Invoked by registerTools().
    function registerMonochromeDarkScheme() { server.tool( "generate_monochrome_dark_scheme", "Generates a dark monochrome color scheme", colorSchemeInputShape, async (args) => { const { color, count } = args; const result = await generateColorScheme(color, "monochrome-dark", count); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } ); }
  • Core helper function that implements the color scheme generation logic: parses seed color, calls The Color API with specified mode ('monochrome-dark' for this tool), parses/formats the JSON response into a structured object with colors array.
    async function generateColorScheme( color: string, mode: string, count: number = 5 ) { const { param, value } = parseColorInput(color); const url = `https://www.thecolorapi.com/scheme?${param}=${value}&mode=${mode}&count=${count}&format=json`; try { const response = await fetch(url); if (!response.ok) { throw new Error( `Color API request failed: ${response.status} ${response.statusText}` ); } const data: any = await response.json(); if (!data.colors || !Array.isArray(data.colors)) { throw new Error("Invalid response from Color API"); } // Format the response for better readability const colors = data.colors.map((color: any, index: number) => ({ position: index + 1, hex: color.hex?.value || "N/A", rgb: color.rgb ? `rgb(${color.rgb.r}, ${color.rgb.g}, ${color.rgb.b})` : "N/A", hsl: color.hsl ? `hsl(${color.hsl.h}, ${color.hsl.s}%, ${color.hsl.l}%)` : "N/A", name: color.name?.value || "Unknown", })); return { scheme_mode: mode, seed_color: data.seed?.hex?.value || value, color_count: colors.length, colors: colors, }; } catch (error) { console.error(`Error generating ${mode} color scheme:`, error); throw error; } }
  • Helper to parse and normalize seed color input into API-compatible {param, value} for hex, RGB, or HSL formats.
    function parseColorInput(color: string): { param: string; value: string } { const cleanColor = color.trim(); // Check for hex format if (cleanColor.startsWith("#")) { return { param: "hex", value: cleanColor.substring(1) }; } else if (/^[0-9A-Fa-f]{6}$/.test(cleanColor)) { return { param: "hex", value: cleanColor }; } // Check for RGB format if ( cleanColor.toLowerCase().includes("rgb") || /^\d+,\d+,\d+$/.test(cleanColor) ) { const rgbMatch = cleanColor.match(/(\d+),\s*(\d+),\s*(\d+)/); if (rgbMatch) { return { param: "rgb", value: `${rgbMatch[1]},${rgbMatch[2]},${rgbMatch[3]}`, }; } } // Check for HSL format if (cleanColor.toLowerCase().includes("hsl") || cleanColor.includes("%")) { const hslMatch = cleanColor.match(/(\d+),\s*(\d+)%,\s*(\d+)%/); if (hslMatch) { return { param: "hsl", value: `${hslMatch[1]},${hslMatch[2]}%,${hslMatch[3]}%`, }; } } // Default to hex if format is unclear return { param: "hex", value: cleanColor.replace("#", "") }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deepakkumardewani/color-scheme-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server