extract_batch_metadata
Extract EXIF, GPS, IPTC, and XMP metadata from up to 50 images in a single batch operation, with optional color data extraction.
Instructions
Extract metadata from multiple images (max 50). Price: $0.001-0.005 USDC via x402
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| imageUrls | Yes | ||
| options | No | ||
| paymentHeader | No | x402 payment header (if paying for access) | |
| payer | No | Caller wallet address (for freemium tracking) |
Implementation Reference
- src/handlers/extract.ts:55-103 (handler)The main handler function 'handleBatch' that executes the extract_batch_metadata tool logic. It validates payment, then extracts metadata from all image URLs in parallel via Promise.all.
export async function handleBatch( input: BatchInput, paymentHeader?: string, payer?: string ): Promise<{ success: boolean; data?: ImageMetadata[]; price?: number; paymentStatus?: string; freemiumRemaining?: number; error?: string; }> { try { const { imageUrls, options } = input; const tier = getTierFromOptions(options || {}); const price = calculatePrice(tier, imageUrls.length); if (paymentHeader || !checkFreemium(payer).allowed) { const payment = await verifyPayment(paymentHeader, tier, payer); if (!payment.valid) { return { success: false, price, paymentStatus: 'failed', freemiumRemaining: 0, error: payment.error || 'Payment verification failed', }; } } const freemium = checkFreemium(payer); const results = await Promise.all( imageUrls.map(url => extractMetadata(url, options)) ); return { success: true, data: results, price, paymentStatus: freemium.allowed ? 'free' : 'paid', freemiumRemaining: freemium.allowed ? freemium.remaining : 0, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Unknown error', }; } } - src/types.ts:20-25 (schema)Schema definition BatchInputSchema for the batch tool's input validation (array of imageUrls with max 50 items, optional options).
export const BatchInputSchema = z.object({ imageUrls: z.array(z.string()).max(50), options: ExtractOptionsSchema.optional(), }); export type BatchInput = z.infer<typeof BatchInputSchema>; - src/index.ts:66-95 (registration)Tool registration in the MCP server (stdio mode) - defines name, description, and inputSchema for extract_batch_metadata.
{ name: 'extract_batch_metadata', description: `Extract metadata from multiple images (max 50). Price: $${PRICING.basic.price}-${PRICING.premium.price} USDC via x402`, inputSchema: { type: 'object', properties: { imageUrls: { type: 'array', items: { type: 'string' }, maxItems: 50, }, options: { type: 'object', properties: { includeGps: { type: 'boolean' }, includeColor: { type: 'boolean' }, }, }, paymentHeader: { type: 'string', description: 'x402 payment header (if paying for access)', }, payer: { type: 'string', description: 'Caller wallet address (for freemium tracking)', }, }, required: ['imageUrls'], }, }, - src/http-server.ts:41-54 (registration)Tool registration in the HTTP server mode - defines name, description, and inputSchema for extract_batch_metadata.
{ name: 'extract_batch_metadata', description: `Extract metadata from multiple images (max 50). Price: $${PRICING.basic.price}-${PRICING.premium.price} USDC via x402`, inputSchema: { type: 'object', properties: { imageUrls: { type: 'array', items: { type: 'string' }, maxItems: 50 }, options: { type: 'object' }, paymentHeader: { type: 'string' }, payer: { type: 'string' }, }, required: ['imageUrls'], }, }, - src/index.ts:146-151 (registration)Handler dispatch for extract_batch_metadata in stdio MCP server - calls handleBatch with parsed input.
case 'extract_batch_metadata': { const { paymentHeader: _, payer: __, ...rest } = args as Record<string, unknown>; const input = BatchInputSchema.parse(rest); const result = await handleBatch(input, paymentHeader, payer); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }