read-exif
Extract EXIF metadata from images to access camera settings, location data, and timestamps for analysis or verification purposes.
Instructions
Read EXIF data from an image with optional tag filtering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | ||
| pick | No |
Implementation Reference
- src/tools/index.ts:95-110 (handler)The handler function that loads the image buffer using loadImage, builds EXIF-specific parsing options with buildExifOptions, extracts metadata using exifr.parse, and returns a standardized success response with the EXIF data or an error response.async (args, extra) => { try { const { image, pick } = args; const buf = await loadImage(image); const opts = buildExifOptions(pick); const meta = await exifr.parse(buf, opts); if (!meta || Object.keys(meta).length === 0) { return createErrorResponse('No EXIF metadata found in image'); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading EXIF data: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools/index.ts:54-60 (schema)Shared Zod schema defining the input 'image' parameter structure, supporting different image source kinds: path, url, base64 data, 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() });
- src/tools/index.ts:88-112 (registration)Registers the read-exif tool on the MCP server instance using server.tool(), providing name, description, input schema (image and optional pick), and the handler function; stores the tool reference in the tools object.// Tool 2: read-exif - reads EXIF data specifically const readExifTool = server.tool('read-exif', "Read EXIF data from an image with optional tag filtering", { image: ImageSourceSchema, pick: z.array(z.string()).optional() }, async (args, extra) => { try { const { image, pick } = args; const buf = await loadImage(image); const opts = buildExifOptions(pick); const meta = await exifr.parse(buf, opts); if (!meta || Object.keys(meta).length === 0) { return createErrorResponse('No EXIF metadata found in image'); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading EXIF data: ${error instanceof Error ? error.message : String(error)}`); } } ); tools['read-exif'] = readExifTool;
- src/tools/segments.ts:75-90 (helper)Helper utility that constructs exifr parsing options specifically for the read-exif tool: enables TIFF (for EXIF), disables other segments, and includes optional specific tag picking./** * Creates options object for the read-exif tool * @param pick Optional array of specific EXIF tags to pick * @returns Options object configured for EXIF reading */ export function buildExifOptions(pick?: string[]): ExifrOptions { return { tiff: true, xmp: false, icc: false, iptc: false, jfif: false, ihdr: false, ...(pick ? { pick } : {}) }; }