Apple Music MCP Server

Apple Music MCP Server

Integrates Apple Music with MCP clients to search the global catalog, manage personal playlists, and access library data. It enables users to perform actions like creating playlists, adding tracks, and viewing recommendations through natural language commands.

Category
访问服务器

README

Apple Music MCP Server

An MCP (Model Context Protocol) server that integrates with Apple Music, allowing Claude and other MCP clients to search the catalog, manage playlists, and access your library.

Claude creating a Deep Focus Coding playlist on Apple Music

Features

  • Search the Apple Music catalog (songs, albums, artists, playlists)
  • List your playlists and browse their tracks
  • Create new playlists with optional initial tracks
  • Add tracks to existing playlists
  • Browse your library songs
  • View recently played tracks
  • Get personalized recommendations

Prerequisites

Apple Developer Setup

1. Create a MusicKit Identifier

  1. Go to Apple Developer > Certificates, Identifiers & Profiles
  2. Click + to register a new identifier
  3. Select MusicKit IDs (or Media IDs)
  4. Enter a description (e.g., "MCP Server") and an identifier (e.g., com.yourname.musicmcp)
  5. Click Continue and Register

2. Create a MusicKit Private Key

  1. Go to Apple Developer > Keys
  2. Click + to create a new key
  3. Name it (e.g., "MusicKit MCP Key")
  4. Check MusicKit and configure it with your MusicKit identifier
  5. Click Continue and Register
  6. Download the .p8 file (you can only download it once!)
  7. Note the Key ID shown on the page

3. Find Your Team ID

Your Team ID is visible at the top right of the Apple Developer portal, or under Membership Details.

Installation

git clone <this-repo>
cd AppleMusicMCP
npm install
npm run build

Configuration

The server is configured via environment variables:

Variable Required Description
APPLE_MUSIC_TEAM_ID Yes Your Apple Developer Team ID
APPLE_MUSIC_KEY_ID Yes Your MusicKit Key ID (from the key you created)
APPLE_MUSIC_PRIVATE_KEY_PATH Yes Absolute path to your .p8 private key file
APPLE_MUSIC_STOREFRONT No ISO 3166 alpha-2 country code (default: us)
APPLE_MUSIC_CONFIG_DIR No Config directory path (default: ~/.apple-music-mcp/)
APPLE_MUSIC_AUTH_PORT No Port for auth server (default: 7829)

Authorization

Before using library features (playlists, library songs, recommendations), you need to authorize with your Apple Music account:

APPLE_MUSIC_TEAM_ID=YOUR_TEAM_ID \
APPLE_MUSIC_KEY_ID=YOUR_KEY_ID \
APPLE_MUSIC_PRIVATE_KEY_PATH=/path/to/AuthKey.p8 \
node dist/index.js auth

This will:

  1. Open your browser to a local authorization page
  2. You click "Authorize with Apple Music" and sign in with your Apple ID
  3. The Music User Token is captured and stored in ~/.apple-music-mcp/tokens.json
  4. The token is valid for approximately 6 months

Note: Catalog search works without authorization. Only library/personal features require it.

Adding to Claude Desktop

Add this to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "apple-music": {
      "command": "node",
      "args": ["/absolute/path/to/AppleMusicMCP/dist/index.js"],
      "env": {
        "APPLE_MUSIC_TEAM_ID": "YOUR_TEAM_ID",
        "APPLE_MUSIC_KEY_ID": "YOUR_KEY_ID",
        "APPLE_MUSIC_PRIVATE_KEY_PATH": "/absolute/path/to/AuthKey_XXXXXXXX.p8",
        "APPLE_MUSIC_STOREFRONT": "us"
      }
    }
  }
}

Adding to Claude Code

Add to your Claude Code settings (.claude/settings.json or global settings):

{
  "mcpServers": {
    "apple-music": {
      "command": "node",
      "args": ["/absolute/path/to/AppleMusicMCP/dist/index.js"],
      "env": {
        "APPLE_MUSIC_TEAM_ID": "YOUR_TEAM_ID",
        "APPLE_MUSIC_KEY_ID": "YOUR_KEY_ID",
        "APPLE_MUSIC_PRIVATE_KEY_PATH": "/absolute/path/to/AuthKey_XXXXXXXX.p8"
      }
    }
  }
}

Available Tools

search_music

Search the Apple Music catalog.

  • query (string, required): Search term
  • types (array, optional): ["songs", "albums", "artists", "playlists"] (default: songs, albums, artists)
  • limit (number, optional): 1-25 results per type (default: 10)
  • storefront (string, optional): Country code

get_user_playlists

List your playlists.

  • limit (number, optional): 1-100 (default: 25)
  • offset (number, optional): Pagination offset

get_playlist_tracks

Get tracks from a playlist.

  • playlist_id (string, required): Playlist ID
  • limit (number, optional): 1-100 (default: 100)
  • offset (number, optional): Pagination offset

create_playlist

Create a new playlist.

  • name (string, required): Playlist name
  • description (string, optional): Playlist description
  • track_ids (string[], optional): Song IDs to add initially

add_tracks_to_playlist

Add tracks to an existing playlist.

  • playlist_id (string, required): Playlist ID
  • track_ids (string[], required): Song IDs to add (max 100)

remove_tracks_from_playlist

Remove tracks from a playlist (limited Apple API support).

  • playlist_id (string, required): Playlist ID
  • track_ids (string[], required): Song IDs to remove

get_library_songs

Get songs from your library.

  • limit (number, optional): 1-100 (default: 25)
  • offset (number, optional): Pagination offset

get_recently_played

Get recently played tracks.

  • limit (number, optional): 1-10 (default: 10)

get_recommendations

Get personalized music recommendations.

  • limit (number, optional): 1-30 recommendation groups (default: 10)

Example Usage

Once configured, you can ask Claude things like:

  • "Search for Taylor Swift songs on Apple Music"
  • "Show me my Apple Music playlists"
  • "Create a new playlist called 'Road Trip' with some rock songs"
  • "What have I been listening to recently?"
  • "Get my music recommendations"
  • "Add the song 'Bohemian Rhapsody' to my Road Trip playlist"

Troubleshooting

"Music User Token required"

Run the auth flow: node dist/index.js auth

"Authentication failed (401)"

Your developer token may be invalid. Check your Team ID, Key ID, and private key path.

"Access forbidden (403)"

Your Music User Token may have expired (they last ~6 months). Re-run: node dist/index.js auth

Auth page doesn't load in browser

Ensure port 7829 isn't in use. Set a different port with APPLE_MUSIC_AUTH_PORT.

"remove_tracks_from_playlist" doesn't work

This is a known Apple Music API limitation. The API has limited DELETE support for playlist tracks. Use the workaround: create a new playlist with the tracks you want to keep.

Development

npm run dev    # Run with tsx (no build needed)
npm run build  # Compile TypeScript
npm start      # Run compiled version

Architecture

  • Transport: stdio (JSON-RPC over stdin/stdout)
  • API: Direct REST calls to api.music.apple.com/v1/
  • Auth: ES256 JWT developer tokens + browser-based MusicKit JS for user tokens
  • Caching: In-memory with per-endpoint TTLs
  • Error handling: Typed errors with helpful messages and retry logic for rate limits

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选