Skip to main content
Glama

rotation-info

Extract rotation and flip orientation data from images to analyze and correct image alignment issues using EXIF metadata.

Instructions

Get detailed rotation and flip information from image orientation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes

Implementation Reference

  • The main handler function that loads the image buffer using loadImage and retrieves rotation/flip info using exifr.rotation.
    async (args, extra) => {
      try {
        const { image } = args;
        const buf = await loadImage(image);
        const rotation = await exifr.rotation(buf);
        
        if (!rotation) {
          return createErrorResponse('No rotation metadata found in image');
        }
        
        return createSuccessResponse(rotation);
      } catch (error) {
        return createErrorResponse(`Error reading rotation info: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Registers the 'rotation-info' tool on the MCP server with name, description, input schema, and handler function.
    // Tool 9: rotation-info - gets rotation and flip information
    const rotationInfoTool = server.tool('rotation-info',
      "Get detailed rotation and flip information from image orientation",
      {
        image: ImageSourceSchema
      },
      async (args, extra) => {
        try {
          const { image } = args;
          const buf = await loadImage(image);
          const rotation = await exifr.rotation(buf);
          
          if (!rotation) {
            return createErrorResponse('No rotation metadata found in image');
          }
          
          return createSuccessResponse(rotation);
        } catch (error) {
          return createErrorResponse(`Error reading rotation info: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );
    tools['rotation-info'] = rotationInfoTool;
  • Zod schema defining the input 'image' parameter as ImageSource (path, url, base64, or buffer).
    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 to load image data into buffer from various source types, used 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;
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior3/5

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

There are no annotations, so the description must carry the burden. The verb 'Get' implies a non-destructive read operation, but the description does not disclose return format, side effects, or any exceptional behavior. It adds context about the focus on rotation/flip but lacks deeper behavioral details.

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 sentence with no redundant words. It is front-loaded with the action 'Get' and clearly states the resource, making it 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?

The description gives the core function but lacks context about return values (since no output schema exists) and differentiation from the sibling 'orientation' tool. For a simple getter, it is minimally adequate but does not fully inform the agent about what to expect or when to choose it.

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 input schema describes a single nested 'image' object with kind, url, data, path, and buffer, which is fairly self-explanatory. The description adds that the tool derives info from 'image orientation', but does not explain parameter usage or format details. Schema coverage is 0%, but the schema itself provides structural semantics, so the slight clarification in the description justifies a 3.

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 uses a specific verb 'Get' and a clear resource 'detailed rotation and flip information', which states what the tool does. It distinguishes itself from the sibling 'orientation' by specifying 'detailed rotation and flip', but does not explicitly name that sibling as an alternative.

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 gives no guidance on when to use this tool versus alternatives. It simply states the function, leaving it to the agent to infer that this is for rotation/flip info, without mentioning exclusions or related tools.

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