Skip to main content
Glama
nextframedev

EXIF MCP Server

by nextframedev

strip_selected_exif_fields

Remove specified EXIF fields from an image. Select which fields to strip and save to a new file or overwrite the original.

Instructions

Remove selected EXIF fields from a single image path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_pathYes
field_namesYes
output_pathNo
overwriteNo
dry_runNo
include_comparisonNo
write_reportNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_pathYes
output_pathYes
removed_fieldsYes
removed_tag_countYes
notesYes
dry_runYes
comparisonYes
report_pathYes

Implementation Reference

  • The MCP tool handler function 'strip_selected_exif_fields' — wraps the core logic via 'strip_exif_fields_from_file' with MCP error handling. Accepts parameters: image_path, field_names, output_path, overwrite, dry_run, include_comparison, write_report.
    def strip_selected_exif_fields(
        image_path: str,
        field_names: list[str],
        output_path: str | None = None,
        overwrite: bool = False,
        dry_run: bool = False,
        include_comparison: bool = False,
        write_report: bool = False,
    ) -> StripSelectedExifResult:
        """Remove selected EXIF fields from a single image path."""
    
        return run_with_mcp_error_handling(
            "strip_selected_exif_fields",
            lambda: strip_exif_fields_from_file(
                image_path=image_path,
                field_names=field_names,
                output_path=output_path,
                overwrite=overwrite,
                dry_run=dry_run,
                include_comparison=include_comparison,
                write_report=write_report,
            ),
        )
  • The core implementation 'strip_exif_fields_from_file' — validates the image path, normalizes field names, matches tags via EXIF reader, removes selected fields using 'strip_selected_metadata', and builds the result dict (StripSelectedExifResult).
    def strip_exif_fields_from_file(
        image_path: str,
        field_names: list[str],
        output_path: str | None = None,
        overwrite: bool = False,
        dry_run: bool = False,
        include_comparison: bool = False,
        write_report: bool = False,
    ) -> StripSelectedExifResult:
        """Remove selected EXIF fields from a single file without hidden side effects."""
    
        source_path = validate_image_path(image_path)
        selected_fields = _normalized_selected_fields(field_names)
        target_path, notes = _resolve_output_path(source_path, output_path, overwrite)
        before_exif = _read_exif_map(source_path) if include_comparison or write_report else {}
        matched_tags = _matched_tag_details(source_path, selected_fields)
        remove_tags = [{"ifd": tag["ifd"], "id": tag["tag_id"]} for tag in matched_tags]
        removed_fields = sorted({tag["field_key"] for tag in matched_tags})
        removed_tag_count = len(remove_tags)
    
        if dry_run:
            notes.append("Dry run only; no files were written.")
        else:
            if removed_tag_count > 0:
                image_bytes = source_path.read_bytes()
                cleaned_bytes, removed_count = strip_selected_metadata(
                    image_bytes,
                    source_path.name,
                    remove_groups=[],
                    remove_tags=remove_tags,
                )
                if removed_count == -1:
                    raise ExifWriteError(
                        "Failed to selectively remove EXIF fields while preserving the remaining "
                        "EXIF metadata."
                    )
                _write_image_bytes(source_path, target_path, cleaned_bytes)
            elif target_path != source_path:
                _write_image_bytes(source_path, target_path, source_path.read_bytes())
    
        if removed_tag_count > 0:
            notes.append(
                "Dry run would remove selected EXIF fields from the output image."
                if dry_run
                else "Removed selected EXIF fields from the written image."
            )
        else:
            notes.append(
                "Dry run found no matching EXIF fields to remove."
                if dry_run
                else "Source image did not contain the selected EXIF fields."
            )
    
        result: StripSelectedExifResult = {
            "source_path": str(source_path),
            "output_path": str(target_path),
            "removed_fields": removed_fields,
            "removed_tag_count": removed_tag_count,
            "notes": notes,
        }
        if dry_run:
            result["dry_run"] = True
    
        if include_comparison or write_report:
            if dry_run:
                after_exif = {
                    field_name: value
                    for field_name, value in before_exif.items()
                    if field_name not in set(removed_fields)
                }
            else:
                after_exif = _read_exif_map(target_path)
            comparison = _comparison_from_exif_maps(before_exif, after_exif)
            if include_comparison:
                result["comparison"] = comparison
            if write_report:
                if dry_run:
                    notes.append("Dry run skipped writing the sidecar JSON report.")
                else:
                    report_path = _sidecar_report_path(target_path)
                    report_payload: dict[str, Any] = {
                        "source_path": str(source_path),
                        "output_path": str(target_path),
                        "removed_fields": removed_fields,
                        "removed_tag_count": removed_tag_count,
                        "dry_run": False,
                        "notes": notes,
                        "comparison": comparison,
                    }
                    _write_json_report(report_path, report_payload, overwrite=overwrite)
                    result["report_path"] = str(report_path)
                    notes.append("Wrote sidecar JSON report.")
    
        return result
  • The 'StripSelectedExifResult' TypedDict schema — defines the return type for the strip_selected_exif_fields tool, including source_path, output_path, removed_fields, removed_tag_count, notes, dry_run, comparison, and report_path.
    class StripSelectedExifResult(TypedDict):
        """Contract for selective EXIF field removal from one image."""
    
        source_path: str
        output_path: str
        removed_fields: list[str]
        removed_tag_count: int
        notes: list[str]
        dry_run: NotRequired[bool]
        comparison: NotRequired["ExifComparison"]
        report_path: NotRequired[str]
  • Registration of 'strip_selected_exif_fields' as an MCP tool via 'server.tool()(strip_selected_exif_fields)' in the 'register_clean_tools' function.
    def register_clean_tools(server: Any) -> None:
        """Register single-file cleanup tools on the provided MCP server instance."""
    
        server.tool()(strip_exif)
        server.tool()(strip_selected_exif_fields)
  • Top-level tool registration calling 'register_clean_tools(server)' which registers 'strip_selected_exif_fields' (and other clean tools) on the MCP server.
    def register_all_tools(server: Any) -> None:
        """Register the initial EXIF tool set on an MCP server instance."""
    
        register_inspection_tools(server)
        register_privacy_tools(server)
        register_clean_tools(server)
        register_batch_tools(server)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description must disclose side effects and dependencies. It only states 'Remove' without explaining if the operation is destructive (overwrite behavior), if it supports dry runs, or what the output structure is.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. However, given the complexity of 7 parameters, slightly more detail would improve usability without sacrificing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description fails to cover the tool's behavior for parameters like overwrite, dry_run, or write_report, and does not mention return values despite an existing output schema. Updates to the image or file structure are unclear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and no parameter explanations in the description, the agent gains limited insight beyond parameter names. The description does not elaborate on 'field_names' format, nor on flags like overwrite, dry_run, or include_comparison.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Remove'), the resource ('selected EXIF fields'), and the scope ('a single image path'), effectively distinguishing it from batch sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like batch_strip_selected_exif_fields or inspection tools. The usage context is only implied by the 'single image' qualifier.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nextframedev/exif_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server