has_gps_exif
Check whether an image contains GPS or location EXIF fields. Determines if location data is embedded in the image's metadata.
Instructions
Check whether an image contains GPS/location EXIF fields.
This tool is read-only and must not modify the target file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_path | Yes | ||
| has_gps | Yes | ||
| gps_fields_present | Yes |
Implementation Reference
- MCP tool handler for has_gps_exif - delegates to detect_gps_exif via error-handling wrapper
def has_gps_exif(image_path: str) -> HasGpsExifResult: """Check whether an image contains GPS/location EXIF fields. This tool is read-only and must not modify the target file. """ return run_with_mcp_error_handling( "has_gps_exif", lambda: detect_gps_exif(image_path=image_path), ) - Core helper - loads EXIF and returns whether GPS fields are present
def detect_gps_exif(image_path: str) -> HasGpsExifResult: """Detect whether GPS EXIF fields are present on the image.""" normalized_path, exif_dict = _load_exif_dict(image_path) gps_fields_present = _gps_field_names(exif_dict) return { "image_path": str(normalized_path), "has_gps": bool(gps_fields_present), "gps_fields_present": gps_fields_present, } - TypedDict schema defining the return type of has_gps_exif
class HasGpsExifResult(TypedDict): """Contract for the has_gps_exif MCP tool.""" image_path: str has_gps: bool gps_fields_present: list[str] - src/exif_mcp_server/tools/inspect.py:95-102 (registration)Registration of has_gps_exif as an MCP tool on the server via decorator
def register_inspection_tools(server: Any) -> None: """Register inspection tools on the provided MCP server instance.""" server.tool()(inspect_exif) server.tool()(has_gps_exif) server.tool()(inspect_exif_detailed) server.tool()(find_images_with_gps_exif) server.tool()(find_images_with_exif_fields) - Helper that extracts human-readable GPS field names from the EXIF GPS IFD
def _gps_field_names(exif_dict: dict[str, dict[int, Any]]) -> list[str]: """Return stable readable names for GPS fields present in EXIF metadata.""" gps_fields = [_tag_name("GPS", tag_id) for tag_id in exif_dict.get("GPS", {})] return sorted(gps_fields)