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()
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions output formats but fails to describe critical behaviors like error handling for images without thumbnails, performance or size limits, or authentication needs. This leaves significant gaps for a tool that processes images.

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 core purpose without unnecessary words. Every part earns its place by specifying the action, resource, and output, 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.

Completeness2/5

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

Given the complexity with nested objects, 0% schema coverage, no output schema, and no annotations, the description is incomplete. It doesn't cover parameter details, behavioral traits, or output specifics, making it inadequate for a tool that handles image processing with multiple input options.

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 but adds minimal parameter semantics. It implies 'image' is required and 'url' affects output format, but doesn't explain the 'image' object's structure, 'kind' enum meanings, or how 'url' parameter influences the result, leaving key parameters poorly documented.

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 action ('extract'), resource ('embedded thumbnail from image'), and output format ('base64 data or URL'), providing a specific purpose. However, it doesn't differentiate from sibling tools like 'read-exif' or 'read-metadata' that might also handle image data extraction, leaving room for ambiguity in sibling distinction.

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?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites, such as needing an image with an embedded thumbnail, and doesn't mention sibling tools like 'read-exif' that might overlap in functionality, offering no usage boundaries.

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