Skip to main content
Glama

thumbnail

Extract embedded thumbnails from images as base64 data or URLs using the exif-mcp server. Supports input as paths, URLs, base64, or buffers for efficient metadata retrieval.

Instructions

Extract embedded thumbnail from image as base64 data or URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes
urlNo

Implementation Reference

  • The handler function that executes the thumbnail tool logic: loads image buffer, extracts thumbnail with exifr.thumbnail, converts to base64 data URL or base64.
    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 via server.tool and 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;
  • ImageSourceSchema defining the 'image' input parameter used by the thumbnail tool (and others).
    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() });
  • src/server.ts:19-20 (registration)
    Top-level call to registerTools which includes the thumbnail tool registration.
    // Register all tools registerTools(server);
  • ThumbnailSchema matching the thumbnail tool's input schema (defined but not directly used in tool registration).
    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() });

Other Tools

Related 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