Logo van iTunes/Apple Music CLI & MCP Server

iTunes/Apple Music CLI & MCP Server

Community
chew-z

This is MCP server for playing from Apple Music Library

Uitgeverchew-z
Repositoryitunes.vim
TaalGo
Forks
0
Sterren
10
Beschikbare tools
0
Transporttypestdio
Categorieën
Links
  • Koppel tools aan AI-workflows

    iTunes/Apple Music CLI & MCP Server biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    10 sterren en 0 forks in de gekoppelde repository.

iTunes/Apple Music CLI & MCP Server

High-performance command-line tool and MCP server for iTunes/Apple Music integration on macOS

Go Version Platform SQLite MCP

Overview

A Go-based tool that bridges command-line interfaces and AI applications with your Apple Music library. Features ultra-fast search (<7ms via SQLite FTS5), smart playback control, and integration with Large Language Models through the Model Context Protocol (MCP).

Key Features

  • Ultra-Fast Search: SQLite FTS5 database with <7ms query performance
  • Smart Playback: ID-based track lookup with playlist context support
  • Audio Control: EQ presets and output device management (local/AirPlay)
  • MCP Integration: 14 specialized tools for AI/LLM applications
  • Database-First: Normalized SQLite schema keyed by persistent Apple Music IDs
  • Context-Aware: context.Context flows from MCP requests down to SQLite queries and JXA processes, so cancellation propagates end to end
  • Radio Stations: Apple Music stations with database-backed CRUD and search
  • Vim Plugin: fzf-powered library search and playback from inside Vim/Neovim (vim-plugin/)

Project History

This project evolved from a legacy VIM plugin for iTunes integration. The original plugin remains untouched in the master branch as a reference. The current implementation is a complete rewrite focused on modern Apple Music integration, database performance, and AI/LLM compatibility through the MCP protocol — and includes a rewritten Vim plugin (vim-plugin/) that fronts the Go CLI instead of JXA scripts.

Architecture

+-------------------+    +--------------------+    +-------------------+
|   CLI Tool        |    |   MCP Server       |    |  Apple Music      |
|   (itunes)        |    |  (mcp-itunes)      |    |  Desktop App      |
+---------+---------+    +---------+----------+    +---------+---------+
          |                        |                         |
          +----------+-------------+                         |
                     |                                       |
          +----------v------------+              +----------v--------+
          |   itunes.Client       |              |   JXA Scripts     |
          |   (core library)      |<-------------+   (via osascript  |
          +----------+------------+              |    stdin)         |
                     |                           +-------------------+
          +----------v------------+
          |   SQLite Database     |
          |   FTS5 Search         |
          +-----------------------+
  • Search path: queries hit the local SQLite database directly — the Apple Music app is not involved.
  • Playback path: Go pipes embedded JXA scripts to osascript via stdin (no temp files) to drive the Apple Music app.
  • Library refresh: Apple Music → JXA bulk property fetch → SQLite (~15–30 seconds even for 10k+ track libraries).

Installation

Prerequisites

  • macOS (required for Apple Music integration)
  • Go 1.25+
  • Apple Music app (installed and configured)
  • Terminal access with Automation permissions for AppleScript/JXA

Build from Source

bash
git clone <repository-url>
cd itunes

go build -o bin/itunes .                 # CLI tool
go build -o bin/mcp-itunes ./mcp-server  # MCP server
go build -o bin/itunes-migrate ./cmd/migrate  # Migration tool

Quick Start

Database Setup (first)

bash
# First-time setup or library refresh (~15-30 seconds)
./bin/itunes-migrate -from-script

# Validate existing database
./bin/itunes-migrate -validate

When to refresh: first install, library changes, metadata updates, or search issues.

CLI Usage

bash
# Search your music library
./bin/itunes search "jazz"
./bin/itunes search "Miles Davis"
./bin/itunes search --json "Miles Davis"   # JSON output (used by the Vim plugin)

# Play tracks: play <playlist> [album] [track] [trackID]
./bin/itunes play "My Playlist" "" "" "B258396D58E2ECC9"   # ID with playlist context
./bin/itunes play "" "Kind of Blue" "So What"              # album + track name

# Current playback status
./bin/itunes now-playing   # or: status

# Radio stations
./bin/itunes search-stations "jazz"
./bin/itunes list-stations
./bin/itunes add-station --name "Name" --url "itmss://..." [--genre g --description d --homepage url]
./bin/itunes update-station <id> [--name/--url/--genre/--description/--homepage ...]
./bin/itunes delete-station <id>
./bin/itunes import-stations stations.json
./bin/itunes export-stations stations.json

MCP Server

bash
# Start MCP server (stdio transport)
./bin/mcp-itunes

Claude Desktop / Claude Code configuration:

json
{
  "mcpServers": {
    "itunes": {
      "command": "/path/to/bin/mcp-itunes"
    }
  }
}

Vim Plugin

Search and play from inside Vim/Neovim via fzf:

vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'chew-z/itunes.vim', { 'branch': 'main', 'rtp': 'vim-plugin' }
CommandDescription
:Tunes [query]Fuzzy-search the library and play the selected track
:TunesStatusShow the currently playing track
:TunesPlay [playlist]Play an entire playlist

The plugin shells out to bin/itunes (auto-detected, or set g:itunes_bin). See vim-plugin/README.md for configuration and docs/VIM-PLUGIN.md for design details.

MCP Tools (14)

Music Library:

  • search_itunes — search library (<7ms FTS5 performance)
  • search_advanced — filtered search (genre, artist, album, rating, starred, streaming)
  • play_track — play with ID-based lookup and optional playlist context
  • now_playing — current playback status and track info
  • refresh_library — rebuild database from Apple Music (~15–30 s, resource-intensive)

Playlists:

  • list_playlists — all playlists with metadata
  • get_playlist_tracks — tracks in a specific playlist

Radio & Streams:

  • search_stations — find Apple Music radio stations by genre/name
  • play_stream — play streaming URLs (itmss://, https://)

EQ & Audio Output:

  • check_eq — current EQ status and available presets
  • set_eq — apply EQ presets (Rock, Jazz, Classical, …) or enable/disable
  • get_output_device — current audio output (local/AirPlay)
  • list_output_devices — available output devices
  • set_output_device — switch to local output (AirPlay selection must be manual)

MCP Resources: itunes://database/stats, itunes://database/playlists

Usage Pattern

Best practice is ID-based playback with playlist context for continuous play:

json
{"track_id": "B258396D58E2ECC9", "playlist": "My Jazz Collection"}

Track IDs come from search results and are Apple Music persistent IDs, which avoids name-matching and encoding issues.

Performance

  • Search: <7ms queries, <5µs cache hits
  • Database: ~760 bytes per track, ~800 tracks/sec migration
  • Storage: ~1MB per 1,000 tracks including FTS5 indexes
  • Driver: pure Go SQLite (modernc.org/sqlite, no CGO)

Environment Variables

VariableDefaultDescription
ITUNES_DB_PATH~/Music/iTunes/itunes_library.dbPrimary database path
ITUNES_BACKUP_DB_PATH~/Music/iTunes/itunes_library_backup.dbBackup database path
ITUNES_SEARCH_LIMIT15Maximum search results

Documentation

Developer docs live in docs/: architecture, database & FTS5 internals, JXA automation (including the bulk-fetch rule — required reading before touching any JXA script), and the Vim plugin.

Development

Project Structure

├── itunes.go              # CLI application (command dispatch + handlers)
├── mcp-server/            # MCP server (14 tools, grouped registration)
├── itunes/                # Core library: Client type, playback, EQ, JXA scripts
│   └── scripts/           # Embedded JXA automation scripts
├── database/              # SQLite + FTS5: schema, search, migrations
├── vim-plugin/            # Vim/Neovim frontend (fzf + CLI)
├── docs/                  # Developer documentation
├── logging/               # zap logger setup
└── cmd/migrate/           # Database migration/validation tool

The core library exposes itunes.NewClient(logger) owning the database connection and search manager; playback and audio-control functions are package-level and take a context.Context.

Build, Test, Lint

bash
./run_test.sh        # go test -v ./...
./run_lint.sh        # golangci-lint (zero findings expected)
./run_format.sh      # gofmt -w .

# Or directly:
go test ./...
go test ./database -bench=BenchmarkSearch

Troubleshooting

Database issues:

bash
./bin/itunes-migrate -from-script    # Initialize/refresh
./bin/itunes-migrate -validate       # Check status

Playback issues:

  • Use track_id from search results (most reliable)
  • Ensure the Apple Music app is running
  • Grant Automation permissions: System Settings → Privacy & Security → Automation

EQ/Audio issues:

  • EQ status is unavailable while using AirPlay (macOS limitation)
  • Specific AirPlay device selection must be done manually in the Music app

Radio station playback:

  • Stations must use itmss:// protocol URLs for playback; https:// URLs are homepage links only

License & Acknowledgments

MIT License — see LICENSE file for details.

Thanks to Apple Music, SQLite FTS5, the MCP Protocol, and modernc.org/sqlite.

Installatie

TypingMind
{
  "mcpServers": {
    "itunes-vim": {
      "command": "./bin/mcp-itunes",
      "args": []
    }
  }
}

Gebruik iTunes/Apple Music CLI & MCP Server MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra iTunes/Apple Music CLI & MCP Server is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg iTunes/Apple Music CLI & MCP Server toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van iTunes/Apple Music CLI & MCP Server.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "itunes-vim": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van iTunes/Apple Music CLI & MCP Server in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van iTunes/Apple Music CLI & MCP Server in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je iTunes/Apple Music CLI & MCP Server gebruiken om me hiermee te helpen?
iTunes/Apple Music CLI & MCP Server
Zeker. Ik heb het gelezen.
Dit vond ik met iTunes/Apple Music CLI & MCP Server.

Veelgestelde vragen

Waarvoor wordt de MCP-server iTunes/Apple Music CLI & MCP Server gebruikt?

iTunes/Apple Music CLI & MCP Server is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik iTunes/Apple Music CLI & MCP Server MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je iTunes/Apple Music CLI & MCP Server gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom iTunes/Apple Music CLI & MCP Server MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als iTunes/Apple Music CLI & MCP Server verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik iTunes/Apple Music CLI & MCP Server MCP met TypingMind?

iTunes/Apple Music CLI & MCP Server werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt iTunes/Apple Music CLI & MCP Server MCP in TypingMind?

iTunes/Apple Music CLI & MCP Server biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om iTunes/Apple Music CLI & MCP Server MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als iTunes/Apple Music CLI & MCP Server authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇