inspect_exif_detailed
Reads EXIF metadata and provides per-tag references to enable selective removal of sensitive data from images.
Instructions
Read EXIF metadata with per-tag references for selective cleanup.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_path | Yes | ||
| has_exif | Yes | ||
| exif | Yes | ||
| warnings | Yes | ||
| tags | Yes |
Implementation Reference
- MCP tool handler function for 'inspect_exif_detailed'. Wraps read_exif_detailed from the core layer with error handling.
def inspect_exif_detailed(image_path: str) -> InspectExifDetailedResult: """Read EXIF metadata with per-tag references for selective cleanup.""" return run_with_mcp_error_handling( "inspect_exif_detailed", lambda: read_exif_detailed(image_path=image_path), ) - Core implementation of the detailed EXIF read. Loads EXIF dict, flattens into JSON-friendly format, and produces per-tag details via _tag_details().
def read_exif_detailed(image_path: str) -> InspectExifDetailedResult: """Read all EXIF metadata from one image with per-tag references.""" normalized_path, exif_dict = _load_exif_dict(image_path) flattened_exif, warnings = _flatten_exif(exif_dict) return { "image_path": str(normalized_path), "has_exif": _has_any_exif(exif_dict), "exif": flattened_exif, "warnings": warnings, "tags": _tag_details(exif_dict), } - Builds the per-tag detail list used by read_exif_detailed, including stable tag references (ifd, tag_id, field_name, field_key, value).
def _tag_details(exif_dict: dict[str, dict[int, Any]]) -> list[ExifTagDetail]: """Return stable per-tag EXIF details including removal-friendly references.""" details: list[ExifTagDetail] = [] seen_field_names: set[str] = set() for ifd_name in EXIF_IFD_ORDER: for tag_id, raw_value in exif_dict.get(ifd_name, {}).items(): field_name = _tag_name(ifd_name, tag_id) if field_name in STRUCTURAL_TIFF_FIELDS: continue field_key = field_name if field_name in seen_field_names: field_key = f"{ifd_name}.{field_name}" seen_field_names.add(field_name) details.append( { "ifd": ifd_name, "tag_id": tag_id, "field_name": field_name, "field_key": field_key, "value": _convert_exif_value(raw_value), } ) return details - TypedDict schema for InspectExifDetailedResult (return type of inspect_exif_detailed tool).
class InspectExifDetailedResult(TypedDict): """Detailed EXIF inspection result with per-tag references.""" image_path: str has_exif: bool exif: dict[str, Any] warnings: list[str] tags: list[ExifTagDetail] - src/exif_mcp_server/tools/inspect.py:95-100 (registration)Registration of inspect_exif_detailed as an MCP server tool via server.tool() 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)