metadata_mcp

metadata_mcp

Reads and writes metadata across images, audio, video, documents, and text files using ExifTool, mutagen, and inline handlers, supporting bulk operations with glob patterns.

Category
访问服务器

README

metadata_mcp

Author: Jim Lehmer
License: MIT

A Model Context Protocol (MCP) server that reads and writes file metadata across a broad range of formats. Connect it to any MCP-compatible LLM client (Claude Desktop, Claude Code, etc.) and ask the model to read or write metadata on images, audio, video, documents, and text files — no knowledge of ExifTool, mutagen, or YAML required.


Why the name?

This server started as a thin ExifTool wrapper. It has since grown backends for audio formats ExifTool can't write (mutagen) and text-based formats with no binary metadata section (HTML, Markdown). "exiftool_mcp" no longer described it; "metadata_mcp" does.


Backend Architecture

The server dispatches automatically to the right backend based on file extension. You never need to specify which backend to use.

Format(s) read_metadata write_metadata backend
JPEG, TIFF, PNG, HEIC, WebP, RAW, GIF… ExifTool ExifTool
PDF ExifTool ExifTool
MP4, MOV, MKV, AVI… ExifTool ExifTool
MP3 ExifTool mutagen — ID3v2 frames
OGG, Opus ExifTool mutagen — Vorbis comment tags
HTML, HTM — <meta name="..."> injection in <head>
MD, Markdown — YAML frontmatter block

ExifTool

Handles the widest range of formats. Required for reading metadata from any format and for writing to images, video, and PDF. Must be installed separately and on PATH.

mutagen

Used for audio formats ExifTool can write only partially or not at all. Installed as a Python dependency in the server venv. Tag names are mapped to the appropriate ID3v2 frame (MP3) or used verbatim as Vorbis comment keys (OGG/Opus).

ID3v2 tag name map (MP3):

Tag name (case-insensitive) ID3v2 frame
Comment COMM
Title TIT2
Artist TPE1
AlbumArtist TPE2
Album TALB
TrackNumber / Track TRCK
Genre TCON
Date / Year TDRC
Description TIT3
Encoder TSSE
Copyright TCOP

In-process text handlers

For formats with no binary metadata section:

  • HTML: injects or updates a <meta name="..." content="..."> tag before </head>. The ExifTool tag name is mapped to a standard HTML meta name (Comment → description, etc.); unknown tags are lowercased and used verbatim.
  • Markdown: writes or updates a YAML frontmatter block (--- ... ---) at the top of the file. The tag name is lowercased directly as the YAML key — no fixed mapping, any attribute works.

Bulk Operations

ExifTool-backed tools accept glob patterns and directory paths natively — ExifTool handles the expansion. This covers read_metadata, set_copyright, strip_metadata, set_author, set_description, set_gps, copy_metadata, and write_metadata for images/video/PDF.

For write_metadata on audio (MP3/OGG/Opus) and text (HTML/Markdown) formats, the server expands globs in Python before dispatching to the format-specific backend. All bulk operations happen in a single tool call — no loop needed.

# Read metadata from every photo — one call, no loop
read_metadata(path="photos/*.jpg")

# Set copyright on every photo — one call, no loop
set_copyright(path="photos/*.jpg", copyright="© 2026 Jim Lehmer")

# Strip metadata from every export — one call, no loop
strip_metadata(path="exports/*.jpg")

# Write ID3 tags to every MP3 — one call, no loop
write_metadata(path="music/*.mp3", tags={"Artist": "Jim Lehmer", "Album": "Demo"})

# Write EXIF to every JPEG — one call, no loop
write_metadata(path="photos/*.jpg", tags={"Copyright": "© 2026"})

# Recursive operation via passthrough
exiftool_passthrough(arguments=["-r", "-all=", "exports/"])

Tools

read_metadata

Read all metadata tags from any file. Uses ExifTool.

Parameter Type Description
path str File to read

write_metadata

Write arbitrary tag=value pairs to a file. Backend is chosen automatically.

Parameter Type Description
path str File to write
tags dict Tag names and values, e.g. {"Comment": "holiday trip", "Author": "Jim"}

set_copyright

Set Copyright tag on a file or directory (ExifTool). Recursive flag available.

Parameter Type Default Description
path str required File or directory path
copyright str required Copyright text
recursive bool False Apply to all files in directory recursively

set_author

Set Author tag (ExifTool).

Parameter Type Description
path str File path
author str Author name

set_description

Set Description tag (ExifTool).

Parameter Type Description
path str File path
description str Description text

set_gps

Set GPS coordinates (ExifTool).

Parameter Type Default Description
path str required File path
latitude float required GPS latitude
longitude float required GPS longitude
latitudeRef str "N" "N" or "S"
longitudeRef str "E" "E" or "W"
altitude float optional Altitude in metres
altitudeRef str "above" "above" or "below"

copy_metadata

Copy metadata from source to destination (ExifTool).

Parameter Type Default Description
source str required Source file
dest str required Destination file
only list[str] optional Restrict to these tag names

strip_metadata

Strip all metadata from a file or directory (ExifTool).

Parameter Type Default Description
path str required File or directory path
recursive bool False Apply recursively

exiftool_passthrough

Run arbitrary ExifTool CLI commands for operations not covered by the tools above.

Parameter Type Description
arguments list[str] Raw ExifTool CLI arguments (omit exiftool itself)

Requirements

  • Python 3.10+
  • ExifTool installed and on PATH
  • Python packages: mcp[cli], mutagen (see requirements.txt)

Installation

git clone https://github.com/dullroar/metadata_mcp.git
cd metadata_mcp

python -m venv .venv
source .venv/bin/activate      # macOS/Linux
# .venv\Scripts\activate       # Windows

pip install -r requirements.txt

MCP Client Configuration

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "metadata": {
      "command": "/path/to/metadata_mcp/.venv/bin/python",
      "args": ["/path/to/metadata_mcp/server.py"]
    }
  }
}

Claude Code

claude mcp add metadata -- /path/to/metadata_mcp/.venv/bin/python /path/to/metadata_mcp/server.py

HTTP/SSE mode

python server.py --transport sse
# Listening on http://127.0.0.1:8000/sse
Flag Default Description
--transport stdio stdio or sse
--host 127.0.0.1 Bind address
--port 8000 Bind port

Example Prompts

  • "Read all the metadata from this photo and tell me what camera was used."
  • "Read the metadata from every photo in photos/ and summarize what cameras were used."
  • "Set the Comment field on this MP3 to 'ripped from vinyl'."
  • "Set the Artist and Album on every MP3 in music/ to 'Jim Lehmer' and 'Demo'."
  • "Add an Author and Copyright field to this Markdown file."
  • "Inject a description meta tag into this HTML page."
  • "Set copyright on every JPEG in photos/ to '© 2026 Jim Lehmer'."
  • "Copy all metadata from original.jpg to backup.jpg."
  • "Strip all metadata from this file before uploading."
  • "Strip all metadata from every JPEG in exports/ before I upload them."
  • "Set my GPS coordinates on this photo to geotag my travels."

Testing with the MCP Inspector

mcp dev server.py

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选