iTunes/Apple Music CLI & MCP Server logo

iTunes/Apple Music CLI & MCP Server

Community
chew-z

This is MCP server for playing from Apple Music Library

Publisherchew-z
Repositoryitunes.vim
LanguageGo
Forks
0
Stars
10
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    iTunes/Apple Music CLI & MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    10 stars and 0 forks from the linked 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.

Installation

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

Use iTunes/Apple Music CLI & MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once iTunes/Apple Music CLI & MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add iTunes/Apple Music CLI & MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the iTunes/Apple Music CLI & MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "itunes-vim": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the iTunes/Apple Music CLI & MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the iTunes/Apple Music CLI & MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use iTunes/Apple Music CLI & MCP Server to help me with this task?
iTunes/Apple Music CLI & MCP Server
Sure. I read it.
Here is what I found using iTunes/Apple Music CLI & MCP Server.

Frequently asked questions

What is the iTunes/Apple Music CLI & MCP Server MCP server used for?

iTunes/Apple Music CLI & MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use iTunes/Apple Music CLI & MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use iTunes/Apple Music CLI & MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use iTunes/Apple Music CLI & MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With iTunes/Apple Music CLI & MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect iTunes/Apple Music CLI & MCP Server MCP to TypingMind?

iTunes/Apple Music CLI & MCP Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does iTunes/Apple Music CLI & MCP Server MCP provide in TypingMind?

iTunes/Apple Music CLI & MCP Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use iTunes/Apple Music CLI & MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If iTunes/Apple Music CLI & MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇