Skip to main content
Glama

read-xmp

Extract XMP metadata from images to access embedded information, with support for extended XMP segments when needed.

Instructions

Read XMP metadata from an image with option for extended XMP segments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYes
extendedNo

Implementation Reference

  • The core handler function that implements the logic for the 'read-xmp' tool. It destructures the input arguments, loads the image into a buffer, builds XMP-specific parsing options, extracts metadata using the exifr library, checks for XMP presence, and returns a standardized success or error response.
    async (args, extra) => { try { const { image, extended } = args; const buf = await loadImage(image); const opts = buildXmpOptions(extended); const meta = await exifr.parse(buf, opts); if (!meta || !meta.xmp) { return createErrorResponse('No XMP metadata found in image'); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading XMP data: ${error instanceof Error ? error.message : String(error)}`); } }
  • Registers the 'read-xmp' tool with the MCP server instance using server.tool(), providing the tool name, description, input schema, and handler function. Also stores a reference in the tools object for testing purposes.
    // Tool 3: read-xmp - reads XMP data const readXmpTool = server.tool('read-xmp', "Read XMP metadata from an image with option for extended XMP segments", { image: ImageSourceSchema, extended: z.boolean().optional() }, async (args, extra) => { try { const { image, extended } = args; const buf = await loadImage(image); const opts = buildXmpOptions(extended); const meta = await exifr.parse(buf, opts); if (!meta || !meta.xmp) { return createErrorResponse('No XMP metadata found in image'); } return createSuccessResponse(meta); } catch (error) { return createErrorResponse(`Error reading XMP data: ${error instanceof Error ? error.message : String(error)}`); } } ); tools['read-xmp'] = readXmpTool;
  • Zod schema defining the standardized ImageSource input parameter used by the 'read-xmp' tool (and other image tools). Supports path, URL, base64, or buffer inputs.
    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 that creates exifr parsing options specifically tailored for XMP metadata extraction, enabling only XMP parsing and optionally multi-segment support for extended XMP.
    /** * Creates options object for the read-xmp tool * @param extended Whether to read extended XMP segments * @returns Options object configured for XMP reading */ export function buildXmpOptions(extended?: boolean): ExifrOptions { return { tiff: false, xmp: true, icc: false, iptc: false, jfif: false, ihdr: false, multiSegment: extended ?? false }; }

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