Skip to main content
Glama

thumbnail

Extract embedded thumbnail images from photos as base64 data or URLs using the exif-mcp server's metadata analysis capabilities.

Instructions

Extract embedded thumbnail from image as base64 data or URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes
urlNo

Implementation Reference

  • Executes the thumbnail extraction logic: loads image buffer, extracts thumbnail using exifr, converts to base64 data URL or base64, handles errors with standardized responses.
    async (args, extra) => {
      try {
        const { image, url } = args;
        const buf = await loadImage(image);
        const thumbnail = await exifr.thumbnail(buf);
        
        if (!thumbnail) {
          return createErrorResponse('No thumbnail found in image');
        }
        
        // Convert to base64 data URL by default
        if (!url) {
          const base64 = Buffer.from(thumbnail).toString('base64');
          const mimeType = 'image/jpeg'; // Thumbnails are typically JPEG
          const dataUrl = `data:${mimeType};base64,${base64}`;
          return createSuccessResponse({ dataUrl });
        }
        
        // For browsers, object URLs would be created, but we can't do that in Node
        // So we'll just return the base64 data
        const base64 = Buffer.from(thumbnail).toString('base64');
        return createSuccessResponse({ base64 });
      } catch (error) {
        return createErrorResponse(`Error extracting thumbnail: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Registers the 'thumbnail' tool with the MCP server instance, defining its description, input schema, and handler function. Stores reference in tools object.
    // Tool 11: thumbnail - extracts embedded thumbnail
    const thumbnailTool = server.tool('thumbnail',
      "Extract embedded thumbnail from image as base64 data or URL",
      {
        image: ImageSourceSchema,
        url: z.boolean().optional()
      },
      async (args, extra) => {
        try {
          const { image, url } = args;
          const buf = await loadImage(image);
          const thumbnail = await exifr.thumbnail(buf);
          
          if (!thumbnail) {
            return createErrorResponse('No thumbnail found in image');
          }
          
          // Convert to base64 data URL by default
          if (!url) {
            const base64 = Buffer.from(thumbnail).toString('base64');
            const mimeType = 'image/jpeg'; // Thumbnails are typically JPEG
            const dataUrl = `data:${mimeType};base64,${base64}`;
            return createSuccessResponse({ dataUrl });
          }
          
          // For browsers, object URLs would be created, but we can't do that in Node
          // So we'll just return the base64 data
          const base64 = Buffer.from(thumbnail).toString('base64');
          return createSuccessResponse({ base64 });
        } catch (error) {
          return createErrorResponse(`Error extracting thumbnail: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );
    tools['thumbnail'] = thumbnailTool;
  • Zod schema for ImageSource used in thumbnail (and other) tool input parameters.
    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()
    });
  • Dedicated Zod schema for thumbnail tool input (matches inline schema, though unused).
    export const ThumbnailSchema = z.object({
      image: 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()
      }),
      url: z.boolean().optional()
    });

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for disclosing behavior. It states that the tool extracts a thumbnail, which is a read operation, but it does not mention failure modes (e.g., what happens if no thumbnail exists), whether it returns the first/largest thumbnail, or any rate limits or permission requirements. This leaves significant behavioral uncertainty.

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, clear sentence with no filler words. It is concise and front-loads the core action (extract thumbnail) and output format, though it could benefit from a brief note about the input parameter to be more structured.

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 tool has two parameters (one nested), no output schema, and no annotations, the description is too sparse to be complete. It does not explain the return value structure, error handling (e.g., missing thumbnail), or how to choose among the image kind options. The sibling tools all operate on image metadata, and this description does not help the agent understand how this extraction fits into a workflow.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for parameter meaning. It hints at the 'url' boolean by mentioning 'base64 data or URL', but it does not explain the 'image' object structure, its 'kind' enum, or how to specify the source image. The schema field names are self-explanatory but the description adds minimal clarification beyond them.

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 uses a specific verb ('Extract') with a clear resource ('embedded thumbnail') and output format ('as base64 data or URL'). This clearly distinguishes it from sibling metadata readers like read-metadata or read-exif, which focus on metadata fields rather than extracting image data.

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 when an embedded thumbnail is needed, but does not explicitly state when to use this tool versus the sibling metadata tools, nor does it mention any exclusions or alternatives. It provides no direct comparison or guidance for selecting between similar tools.

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