gps-coordinates
Extract GPS coordinates (latitude and longitude) from image metadata to identify photo locations. Supports various image formats including paths, URLs, and encoded data.
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. It loads the image into a buffer using loadImage, extracts GPS data using exifr.gps(), and returns a standardized success response with the coordinates or null, or an error response.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:54-60 (schema)Shared Zod schema defining the 'image' input parameter structure (ImageSourceType) used by the 'gps-coordinates' 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/tools/index.ts:223-241 (registration)Registration of the 'gps-coordinates' tool on the MCP server, including description, input schema reference, and handler function.// 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;