Skip to main content
Glama
deepakkumardewani

Color Scheme Generator MCP Server

generate_analogic_scheme

Generate harmonious color schemes by creating adjacent colors on the color wheel from a seed color for design projects.

Instructions

Generates an analogic color scheme with adjacent colors on the color wheel

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 handler function that executes the generate_analogic_scheme tool logic. It extracts color and count from args, calls the generateColorScheme helper with 'analogic' mode, and returns the result as JSON text content.
    async (args) => {
      const { color, count } = args;
      const result = await generateColorScheme(color, "analogic", count);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Shared Zod schema for input validation of all color scheme tools, including color (string) and optional count (number). Used by generate_analogic_scheme.
    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)"),
    };
  • Registration of the generate_analogic_scheme tool via server.tool, including name, description, schema reference, and inline handler. Called from registerTools().
    function registerAnalogicScheme() {
      server.tool(
        "generate_analogic_scheme",
        "Generates an analogic color scheme with adjacent colors on the color wheel",
        colorSchemeInputShape,
        async (args) => {
          const { color, count } = args;
          const result = await generateColorScheme(color, "analogic", count);
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        }
      );
    }
  • Primary helper function implementing the core logic: parses color, constructs URL for TheColorAPI with given mode ('analogic'), fetches and formats the color scheme response.
    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;
      }
    }
  • Supporting helper to detect and normalize color input format (hex, rgb, hsl) for the API request.
    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("#", "") };
    }
  • Invocation of registerAnalogicScheme within the main registerTools function.
    registerAnalogicScheme();
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the core behavior (generating a color scheme) but lacks details on output format, whether it's deterministic, error handling, or performance traits. It's adequate but minimal for a generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the key action and differentiator. Every word earns its place with no redundancy or fluff, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (generation with parameters), no annotations, and no output schema, the description is minimally complete. It covers the purpose and basic behavior but lacks details on output (e.g., format of returned colors) or advanced usage, leaving gaps for the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description adds no parameter-specific semantics beyond what the schema provides, meeting the baseline for high coverage without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Generates') and resource ('an analogic color scheme'), and distinguishes it from siblings by specifying 'adjacent colors on the color wheel' (unlike complement, triad, quad, or monochrome schemes). It provides a precise functional definition.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through 'adjacent colors on the color wheel,' suggesting when to use it (for harmonious, analogous palettes) versus alternatives like complement or triad schemes. However, it lacks explicit guidance on when-not-to-use or named alternatives, leaving some interpretation to the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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