Skip to main content
Glama

read-icc

Extract ICC color profile metadata from images to analyze color spaces and ensure accurate color representation across devices.

Instructions

Read ICC metadata from an image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • Handler function that executes the 'read-icc' tool logic. Loads the image buffer, configures exifr options for ICC segment, parses metadata, and returns ICC data or appropriate error.
    async (args, extra) => {
      try {
        const { image } = args;
        const buf = await loadImage(image);
        const opts = buildSegmentOptions(segment);
        const meta = await exifr.parse(buf, opts);
        
        const segmentKey = segment.toLowerCase();
        if (!meta || !meta[segmentKey]) {
          return createErrorResponse(`No ${segment} metadata found in image`);
        }
        
        return createSuccessResponse(meta);
      } catch (error) {
        return createErrorResponse(`Error reading ${segment} data: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Registration block for segment-specific tools, including 'read-icc'. Maps 'read-icc' to 'ICC' segment and registers the tool with MCP server, schema, and handler.
    const segmentTools = [
      { name: 'read-icc', segment: 'ICC' },
      { name: 'read-iptc', segment: 'IPTC' },
      { name: 'read-jfif', segment: 'JFIF' },
      { name: 'read-ihdr', segment: 'IHDR' }
    ] as const;
    
    segmentTools.forEach(({ name, segment }) => {
      const segmentTool = server.tool(name,
        `Read ${segment} metadata from an image`,
        {
          image: ImageSourceSchema
        },
        async (args, extra) => {
          try {
            const { image } = args;
            const buf = await loadImage(image);
            const opts = buildSegmentOptions(segment);
            const meta = await exifr.parse(buf, opts);
            
            const segmentKey = segment.toLowerCase();
            if (!meta || !meta[segmentKey]) {
              return createErrorResponse(`No ${segment} metadata found in image`);
            }
            
            return createSuccessResponse(meta);
          } catch (error) {
            return createErrorResponse(`Error reading ${segment} data: ${error instanceof Error ? error.message : String(error)}`);
          }
        }
      );
      tools[name] = segmentTool;
    });
  • Zod schema defining the 'image' input parameter structure used by the 'read-icc' tool.
    // Define a Zod schema for the ImageSource type that's directly usable with McpServer.tool
    const ImageSourceSchema = z.object({
      kind: z.enum(['path', 'url', 'base64', 'buffer']),
      path: z.string().optional(),
      url: z.string().optional(),
      data: z.string().optional(),
      buffer: z.string().optional()
    });
  • Helper function that builds exifr options specifically enabling the ICC segment parsing, used in the read-icc handler.
    export function buildSegmentOptions(segment: 'ICC' | 'IPTC' | 'JFIF' | 'IHDR'): ExifrOptions {
      const options: ExifrOptions = {
        tiff: false,
        xmp: false,
        icc: false,
        iptc: false,
        jfif: false,
        ihdr: false,
      };
      
      const key = segment.toLowerCase() as 'icc' | 'iptc' | 'jfif' | 'ihdr';
      options[key] = true;
      
      return options;
    }
  • Helper function to load image from various sources (path, url, base64, buffer) into a buffer suitable for exifr parsing, called in the handler.
    export async function loadImage(src: ImageSourceType): Promise<Buffer | Uint8Array> {
      try {
        switch (src.kind) {
          case 'path':
            if (!src.path) {
              throw new Error('Path is required for kind="path"');
            }
            return await fs.promises.readFile(src.path);
          
          case 'url':
            if (!src.url) {
              throw new Error('URL is required for kind="url"');
            }
            
            if (src.url.startsWith('file://')) {
              // Handle file:// URLs by converting to filesystem path
              const filePath = fileURLToPath(src.url);
              return await fs.promises.readFile(filePath);
            } else {
              // Handle HTTP/HTTPS URLs
              const response = await fetch(src.url);
              if (!response.ok) {
                throw new Error(`Failed to fetch URL: ${response.status} ${response.statusText}`);
              }
              return new Uint8Array(await response.arrayBuffer());
            }
          
          case 'base64':
            if (!src.data) {
              throw new Error('Data is required for kind="base64"');
            }
            
            // Check for potential oversized base64 string (>30MB)
            if (src.data.length > 40000000) { // ~30MB in base64
              throw new Error('PayloadTooLarge: Base64 data exceeds 30MB limit');
            }
            
            // Handle data URIs or raw base64
            if (src.data.startsWith('data:')) {
              const base64Data = src.data.split(',')[1];
              return Buffer.from(base64Data, 'base64');
            } else {
              return Buffer.from(src.data, 'base64');
            }
          
          case 'buffer':
            if (!src.buffer) {
              throw new Error('Buffer is required for kind="buffer"');
            }
            return Buffer.from(src.buffer, 'base64');
          
          default:
            // This should never happen due to type constraints, but TypeScript needs it
            throw new Error(`Unsupported image source kind: ${(src as any).kind}`);
        }
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to load image: ${error.message}`);
        }
        throw error;
      }
    }
Behavior2/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 states 'read' implies a non-destructive operation, but doesn't disclose behavioral traits like error handling (e.g., if no ICC data is found), performance aspects, or output format. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 with zero waste. It's front-loaded with the core purpose, making it easy to parse quickly. Every word earns its place by directly conveying the tool's function.

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

Completeness2/5

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

Given the complexity (1 nested parameter, no output schema, no annotations), the description is incomplete. It doesn't explain what ICC metadata entails, how results are returned, or error conditions. For a tool that reads specialized metadata, more context is needed to use it effectively without trial and error.

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?

The description adds no parameter semantics beyond the input schema, which has 0% description coverage. With 1 parameter (a nested object for 'image'), the schema defines the structure but not the meaning. The baseline is 3 because schema coverage is low (<50%), but the description doesn't compensate by explaining what 'image' represents or how to use the 'kind' enum options.

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 states the verb 'read' and the resource 'ICC metadata from an image', which is specific and actionable. It distinguishes this tool from siblings like 'read-exif' or 'read-xmp' by focusing on ICC metadata, though it doesn't explicitly contrast with them.

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 guidance on when to use this tool versus alternatives like 'read-metadata' (which might include ICC) or other sibling tools. It lacks context about prerequisites, such as needing an image with ICC data, or exclusions for when it's not applicable.

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/stass/exif-mcp'

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