Skip to main content
Glama
paladini

devutils-mcp-server

color_convert

Convert color values between HEX, RGB, and HSL formats for web development and design workflows.

Instructions

Convert colors between HEX, RGB, and HSL formats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
colorYesColor value (e.g., '#FF5733', 'rgb(255,87,51)', 'hsl(11,100%,60%)')

Implementation Reference

  • The 'color_convert' tool implementation, including registration, input validation schema, and the handler function that processes the conversion logic.
    server.tool(
      "color_convert",
      "Convert colors between HEX, RGB, and HSL formats.",
      {
        color: z
          .string()
          .describe(
            "Color value (e.g., '#FF5733', 'rgb(255,87,51)', 'hsl(11,100%,60%)')"
          ),
      },
      async ({ color }) => {
        try {
          let r: number, g: number, b: number;
    
          const hexMatch = color.match(
            /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i
          );
          const rgbMatch = color.match(
            /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/i
          );
          const hslMatch = color.match(
            /hsl\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/i
          );
    
          if (hexMatch) {
            r = parseInt(hexMatch[1], 16);
            g = parseInt(hexMatch[2], 16);
            b = parseInt(hexMatch[3], 16);
          } else if (rgbMatch) {
            r = parseInt(rgbMatch[1]);
            g = parseInt(rgbMatch[2]);
            b = parseInt(rgbMatch[3]);
          } else if (hslMatch) {
            const h = parseInt(hslMatch[1]) / 360;
            const s = parseInt(hslMatch[2]) / 100;
            const l = parseInt(hslMatch[3]) / 100;
    
            if (s === 0) {
              r = g = b = Math.round(l * 255);
            } else {
              const hue2rgb = (p: number, q: number, t: number) => {
                if (t < 0) t += 1;
                if (t > 1) t -= 1;
                if (t < 1 / 6) return p + (q - p) * 6 * t;
                if (t < 1 / 2) return q;
                if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
                return p;
              };
              const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
              const p = 2 * l - q;
              r = Math.round(hue2rgb(p, q, h + 1 / 3) * 255);
              g = Math.round(hue2rgb(p, q, h) * 255);
              b = Math.round(hue2rgb(p, q, h - 1 / 3) * 255);
            }
          } else {
            return {
              content: [
                {
                  type: "text" as const,
                  text: "Error: Unrecognized color format. Use HEX (#FF5733), RGB (rgb(255,87,51)), or HSL (hsl(11,100%,60%)).",
                },
              ],
              isError: true,
            };
          }
    
          // RGB to HSL
          const rn = r / 255, gn = g / 255, bn = b / 255;
          const max = Math.max(rn, gn, bn), min = Math.min(rn, gn, bn);
          const l = (max + min) / 2;
          let h = 0, s = 0;
    
          if (max !== min) {
            const d = max - min;
            s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
            switch (max) {
              case rn: h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6; break;
              case gn: h = ((bn - rn) / d + 2) / 6; break;
              case bn: h = ((rn - gn) / d + 4) / 6; break;
            }
          }
    
          const result = {
            hex: `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`.toUpperCase(),
            rgb: `rgb(${r}, ${g}, ${b})`,
            hsl: `hsl(${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%)`,
            r, g, b,
            h: Math.round(h * 360),
            s: Math.round(s * 100),
            l: Math.round(l * 100),
          };
    
          return {
            content: [
              { type: "text" as const, text: JSON.stringify(result, null, 2) },
            ],
          };
        } catch (e) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error: ${e instanceof Error ? e.message : String(e)}`,
              },
Behavior2/5

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

With no annotations provided, the description carries the full disclosure burden but fails to specify critical behavioral traits: it doesn't explain what the output format is (since there is no target_format parameter, it's unclear if it returns all formats or detects input), doesn't mention validation behavior for invalid colors, and omits any error handling or precision details.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words. It is appropriately front-loaded with the action noun. While it lacks completeness, its brevity reflects purposeful conciseness rather than the under-specification seen in tautological descriptions.

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?

For a single-parameter utility tool with complete schema coverage, the description covers the minimum viable information. However, given the lack of output schema and the ambiguity around what format(s) the tool returns (critical for a conversion tool), the description falls short of being fully complete.

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?

With 100% schema description coverage, the parameter 'color' is already well-documented in the schema with clear examples. The description mentions the supported formats (HEX, RGB, HSL) which aligns with but doesn't significantly augment the schema's examples. Baseline 3 is appropriate when schema coverage is high.

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

Purpose4/5

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

The description clearly identifies the action (Convert), resource (colors), and specific formats supported (HEX, RGB, HSL). It effectively distinguishes this from sibling conversion tools like byte_convert or case_convert by specifying color-specific formats, though it doesn't explicitly state 'web color' or note unsupported formats like CMYK.

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

Usage Guidelines2/5

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

The description provides no explicit guidance on when to use this tool versus alternatives, nor does it mention prerequisites (e.g., valid color syntax) or when to avoid it. While the usage is somewhat implied by the name and parameter examples, there are no explicit when/when-not instructions.

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/paladini/devutils-mcp-server'

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