Blago’s blog

Just another personal blog about system administration and stuff

~/post/2026-11-29-mcp-id3

mcp-id3: letting an AI assistant tag my music collection

6 min readProgramming

mcp-id3 is an MCP server that lets an AI assistant identify, tag, organise and repair MP3 and FLAC files. It recognises songs by their sound, looks them up on MusicBrainz, Discogs and Bulgarian Rock Archives, writes clean tags and covers, and can undo every change.

Every music collection that has grown over the years ends up the same way. Files called track04.mp3, albums where every song has a different year, folders with no tags at all, and old Bulgarian rips whose Cyrillic tags show up as Ùóðöèòå instead of Щурците. Taggers like MusicBrainz Picard can fix all of that, but it is slow, clicky work, one folder at a time.

So I wrote mcp-id3, an MCP server that gives an AI assistant the tools to do this work. I say what I want in plain language, and the model decides which tools to call:

Identify the album in /music/incoming/Lordz of Brooklyn and tag it.

It works with any model that can call tools through an MCP client: hosted assistants such as Claude, or a model running on my own machine with Ollama or LM Studio. The server itself is a single Go binary that speaks MCP over stdio.

What it can do

The main job is tagging whole albums. Point it at a folder and it matches all the files against one release, so the album name, the year and the track numbers agree with each other. If a file doesn’t belong to the album, it says so, and if tracks are missing, it lists them. Single files work too. They are recognised by their sound first, and if that fails, by whatever is left in the old tags, the file name or the folder name.

What gets written is the usual set: title, artist, album, album artist, year, track and disc numbers, genre, comment, and the MusicBrainz IDs, so Picard and other players know the files later. The server can also put a cover into the files, from an image lying in the folder or downloaded from the Cover Art Archive, and rename files from their tags, up to sorting a messy inbox into Artist/Album/01 - Title.mp3.

For a large collection there is a scan that walks the whole tree and reports only the folders that need attention: untagged files, missing fields, mixed albums, missing covers. And there are two things I wanted for Bulgarian music in particular, repairing old Cyrillic tags and searching Bulgarian Rock Archives. More about those below.

Anything that changes files can be previewed first and undone afterwards.

How a song is recognised

For a single file the server tries several things in order and stops at the first one that works:

  1. Fingerprint. fpcalc from Chromaprint computes an acoustic fingerprint, and AcoustID maps it to MusicBrainz recordings. This recognises the song by how it sounds, whatever the file is called.
  2. Existing tags, searched on MusicBrainz.
  3. The file name, Artist - Title.mp3, with track numbers and site adverts cut off. If the name has no artist, the folder name supplies one.
  4. Discogs.
  5. Bulgarian Rock Archives, for Cyrillic artist names only.

A match by name is weaker than a match by sound, so the server also checks whether the recording it found is as long as the file. That is what tells the album version of a song from the live and extended ones.

A whole folder is handled differently. A few files spread over the folder are looked up, and every release they appear on gets a vote. The most promising releases are fetched with their full tracklists, and every file is matched against them, first by fingerprint, then by title. Title matching tolerates small spelling differences and understands romanised Cyrillic, so “Dve sledi” matches “Две следи”. The release that explains the most files wins, and one write_tags call then tags the whole album from it.

The answer the model gets back looks like this:

{"album":{"title":"All in the Family","artist":"Lordz of Brooklyn","year":"1995","tracks":12,
          "release_mbid":"1474d046-7980-4868-85dc-b2373a7de1b0"},
 "files":[{"file":"Lordz of Brooklyn - Saturday Night Fever.mp3","track":"1","title":"Saturday Nite Fever","by":"title"},
          {"file":"Lordz of Brooklyn - Papers.mp3","track":"2","title":"Papers","by":"title"}],
 "unmatched":["Lordz of Brooklyn - Mafia.mp3"],
 "missing_tracks":["8 Out Ta Bomb","11 Unda the Boardwalk"]}

Keeping the output small

A language model pays for every byte of a tool result, and small local models get confused by long ones. So the results are deliberately compact. Values that all files of a folder share are sent only once, lists are capped, and big things like fingerprints and cover images never pass through the model at all. The server fingerprints the file and downloads the cover itself, and the model only sees the outcome.

For small models there is one more knob: MCP_ID3_TOOLS=core offers only the seven tools needed for everyday work instead of all of them. A shorter tool list leaves more room in the context and makes it easier for the model to pick the right one. The repository has a guide for running it with Ollama and explains why the default context length there is too small for tool use.

Nothing is lost

Letting a model write to my music files sounded risky, so safety came first:

  • Every tool that changes files accepts dry_run, which shows the old and new values and changes nothing.
  • Before a file is changed, its previous state is saved: the old tags, the old name or the old cover. If that cannot be saved, the change is not made.
  • undo reverts the last operation as a whole, however many files it touched. Calling it again goes one step further back, up to 20 operations.
  • Writes skip files that would not change, and renames never overwrite an existing file.

In practice that means I can say “show me first”, look at the diff, and say “that was wrong, put it back” if the model got it wrong.

Bulgarian music

This part is the reason I couldn’t just use an existing tagger. A lot of Bulgarian rock from the 70s, 80s and 90s simply isn’t on MusicBrainz or Discogs. Bulgarian Rock Archives has most of it, with tracklists, years, labels and catalogue numbers. When MusicBrainz finds nothing and the names are in Cyrillic, the server looks the artist up there on its own. Romanised names like “Shturcite” work too.

The other Bulgarian problem is old tags written in CP1251, the Windows Cyrillic code page, but marked as Latin-1. Most players show them as garbage. scan_library reports such files, and write_tags with fix_encoding saves them again as proper Unicode.

Setting it up

The server needs fpcalc (the chromaprint package on Arch and Manjaro, libchromaprint-tools on Debian and Ubuntu) and a free AcoustID application key. A Discogs token is optional. Releases carry static Linux binaries for amd64 and arm64, so it runs on a Raspberry Pi too, or it can be built with go build.

With Claude Code, adding it is one command:

claude mcp add mcp-id3 \
  -e ACOUSTID_API_KEY=your_application_key \
  -- /absolute/path/to/mcp-id3

Other clients take the same command and environment variables in their own config file. The README has the details for Claude Desktop, Ollama, Open WebUI and others.

Source code

The project is open source under the GPLv3 or later: code.blago.cloud/blago/mcp_id3. The README documents every tool, the tags that are written and how identification works.

Credits