gps-coordinates
Extract precise latitude and longitude coordinates from image metadata using the exifr library. Supports input formats like paths, URLs, base64, or buffers for offline processing.
Instructions
Extract GPS coordinates (latitude/longitude) from image metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes |
Implementation Reference
- src/tools/index.ts:229-239 (handler)The handler function for the 'gps-coordinates' tool. Loads the image buffer using loadImage, extracts GPS coordinates with exifr.gps, returns success response with GPS data or null, or error if failed.async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const gps = await exifr.gps(buf); return createSuccessResponse(gps || null); } catch (error) { return createErrorResponse(`Error reading GPS data: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools/index.ts:226-228 (schema)Input schema for the gps-coordinates tool, defining the required 'image' parameter using the shared ImageSourceSchema.{ image: ImageSourceSchema },
- src/tools/index.ts:54-60 (schema)Shared Zod schema for ImageSource used in gps-coordinates and other image tools, supporting path, url, base64 data, 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() });
- src/tools/index.ts:223-241 (registration)Registration of the gps-coordinates tool using server.tool, including name, description, schema, handler, and assignment to tools object.// Tool 10: gps-coordinates - extracts GPS coordinates const gpsCoordinatesTool = server.tool('gps-coordinates', "Extract GPS coordinates (latitude/longitude) from image metadata", { image: ImageSourceSchema }, async (args, extra) => { try { const { image } = args; const buf = await loadImage(image); const gps = await exifr.gps(buf); return createSuccessResponse(gps || null); } catch (error) { return createErrorResponse(`Error reading GPS data: ${error instanceof Error ? error.message : String(error)}`); } } ); tools['gps-coordinates'] = gpsCoordinatesTool;