Token导航 LogoToken导航TokenDH.com
音频生成敏感数据github未标认证来源可访问许可证需确认审计提醒

apple-musicApple music 音频

Agent Skill

用于辅助音频、音乐、语音转写、语音合成或声音素材处理。它适合让 Agent 生成配乐说明、整理音频流程、调用语音工具或处理播客和视频配音素材。使用时需要确认输入音频来源、输出格式、时长和模型限制;涉及人声克隆、版权音乐或公开发布时,应先核对授权和合规边界。

总安装

522

周安装

33

GitHub Stars

36

下载量

261
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:apple-music(Apple music 音频)
来源仓库:https://github.com/epheterson/mcp-applemusic
仓库路径:skills/apple-music
安装命令:
npx skills add https://github.com/epheterson/mcp-applemusic --skill apple-music
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/epheterson/mcp-applemusic --skill apple-music

简介

Apple Music 集成技能提供播放列表管理、播放控制和音乐库操作能力,支持 AppleScript、UI 自动化和 MusicKit API 三种接入方式。

  • 适合在播客制作、视频配音或音频素材处理中调用音乐服务,需先确保歌曲已加入本地音乐库才能添加至播放列表。
  • 使用时需区分测试环境与生产环境,涉及版权音乐时应提前核查授权条款和公开发布限制。
  • 安装命令为 npx skills add https://github.com/epheterson/mcp-applemusic --skill apple-music。
  • 调用播放控制或修改音乐库前,建议确认当前系统是否已登录有效 Apple ID 并开启相应权限。

SKILL.md

Apple Music Integration

Guide for integrating with Apple Music. Three approaches: AppleScript (direct control), UI automation (catalog without API), and MusicKit API (cross-platform).

When to Use

Invoke when users ask to:

  • Manage playlists (create, add/remove tracks, list)
  • Control playback (play, pause, skip, volume)
  • Play an Apple Music URL (album, playlist, or song)
  • Search catalog or library
  • Add songs to library
  • Access listening history or recommendations

Critical Rule: Library-First Workflow

You CANNOT add catalog songs directly to playlists.

Songs must be in the user's library first:

  • ❌ Catalog ID → Playlist (fails)
  • ✅ Catalog ID → Library → Playlist (works)

Why: Playlists use library IDs (i.abc123), not catalog IDs (1234567890).

This applies to both AppleScript and API approaches.


AppleScript (macOS)

Zero setup. Works immediately with the Music app.

Run via Bash:

osascript -e 'tell application "Music" to playpause'
osascript -e 'tell application "Music" to return name of current track'

Multi-line scripts:

osascript <<'EOF'
tell application "Music"
    set t to current track
    return {name of t, artist of t}
end tell
EOF

Available Operations

CategoryOperations
Playbackplay, pause, stop, resume, next track, previous track, fast forward, rewind, play URL
Player Stateplayer position, player state, sound volume, mute, shuffle enabled/mode, song repeat
Current Trackname, artist, album, duration, time, rating, loved, disliked, genre, year, track number
Librarysearch, list tracks, get track properties, set ratings
Playlistslist, create, delete, rename, add tracks, remove tracks, get tracks
AirPlaylist devices, select device, current device

Track Properties (Read)

tell application "Music"
    set t to current track
    -- Basic info
    name of t           -- "Hey Jude"
    artist of t         -- "The Beatles"
    album of t          -- "1 (Remastered)"
    album artist of t   -- "The Beatles"
    composer of t       -- "Lennon-McCartney"
    genre of t          -- "Rock"
    year of t           -- 1968

    -- Timing
    duration of t       -- 431.0 (seconds)
    time of t           -- "7:11" (formatted)
    start of t          -- start time in seconds
    finish of t         -- end time in seconds

    -- Track info
    track number of t   -- 21
    track count of t    -- 27
    disc number of t    -- 1
    disc count of t     -- 1

    -- Ratings
    rating of t         -- 0-100 (20 per star)
    loved of t          -- true/false
    disliked of t       -- true/false

    -- Playback
    played count of t   -- 42
    played date of t    -- date last played
    skipped count of t  -- 3
    skipped date of t   -- date last skipped

    -- IDs
    persistent ID of t  -- "ABC123DEF456"
    database ID of t    -- 12345
end tell

Track Properties (Writable)

tell application "Music"
    set t to current track
    set rating of t to 80          -- 4 stars
    set loved of t to true
    set disliked of t to false
    set name of t to "New Name"    -- rename track
    set genre of t to "Alternative"
    set year of t to 1995
end tell

Player State Properties

tell application "Music"
    player state          -- stopped, playing, paused, fast forwarding, rewinding
    player position       -- current position in seconds (read/write)
    sound volume          -- 0-100 (read/write)
    mute                  -- true/false (read/write)
    shuffle enabled       -- true/false (read/write)
    shuffle mode          -- songs, albums, groupings
    song repeat           -- off, one, all (read/write)
    current track         -- track object
    current playlist      -- playlist object
    current stream URL    -- URL if streaming
end tell

Playback Commands

tell application "Music"
    -- Play controls
    play                          -- play current selection
    pause
    stop
    resume
    playpause                     -- toggle play/pause
    next track
    previous track
    fast forward
    rewind

    -- Play specific content
    play (first track of library playlist 1 whose name contains "Hey Jude")
    play user playlist "Road Trip"

    -- Settings
    set player position to 60     -- seek to 1:00
    set sound volume to 50        -- 0-100
    set mute to true
    set shuffle enabled to true
    set song repeat to all        -- off, one, all
end tell

Library Queries

tell application "Music"
    -- All library tracks
    every track of library playlist 1

    -- Search by name
    tracks of library playlist 1 whose name contains "Beatles"

    -- Search by artist
    tracks of library playlist 1 whose artist contains "Beatles"

    -- Search by album
    tracks of library playlist 1 whose album contains "Abbey Road"

    -- Combined search
    tracks of library playlist 1 whose name contains "Hey" and artist contains "Beatles"

    -- By genre
    tracks of library playlist 1 whose genre is "Rock"

    -- By year
    tracks of library playlist 1 whose year is 1969

    -- By rating
    tracks of library playlist 1 whose rating > 60  -- 3+ stars

    -- Loved tracks
    tracks of library playlist 1 whose loved is true

    -- Recently played (sort by played date)
    tracks of library playlist 1 whose played date > (current date) - 7 * days
end tell

Playlist Operations

tell application "Music"
    -- List all playlists
    name of every user playlist

    -- Get playlist
    user playlist "Road Trip"
    first user playlist whose name contains "Road"

    -- Create playlist
    make new user playlist with properties {name:"New Playlist", description:"My playlist"}

    -- Delete playlist
    delete user playlist "Old Playlist"

    -- Rename playlist
    set name of user playlist "Old Name" to "New Name"

    -- Get playlist tracks
    every track of user playlist "Road Trip"
    name of every track of user playlist "Road Trip"

    -- Add track to playlist (must be library track)
    set targetPlaylist to user playlist "Road Trip"
    set targetTrack to first track of library playlist 1 whose name contains "Hey Jude"
    duplicate targetTrack to targetPlaylist

    -- Remove track from playlist
    delete (first track of user playlist "Road Trip" whose name contains "Hey Jude")

    -- Playlist properties
    duration of user playlist "Road Trip"   -- total duration
    time of user playlist "Road Trip"       -- formatted duration
    count of tracks of user playlist "Road Trip"
end tell

AirPlay

tell application "Music"
    -- List AirPlay devices
    name of every AirPlay device

    -- Get current device
    current AirPlay devices

    -- Set output device
    set current AirPlay devices to {AirPlay device "Living Room"}

    -- Multiple devices
    set current AirPlay devices to {AirPlay device "Living Room", AirPlay device "Kitchen"}

    -- Device properties
    set d to AirPlay device "Living Room"
    name of d
    kind of d           -- computer, AirPort Express, Apple TV, AirPlay device, Bluetooth device
    active of d         -- true if playing
    available of d      -- true if reachable
    selected of d       -- true if in current devices
    sound volume of d   -- 0-100
end tell

String Escaping

Always escape user input:

def escape_applescript(s):
    return s.replace('\\', '\\\\').replace('"', '\\"')

safe_name = escape_applescript(user_input)
script = f'tell application "Music" to play user playlist "{safe_name}"'

Limitations

  • macOS only — no Windows/Linux
  • UI features require display — UI automation won't work headless or with Music.app minimized

UI Automation (macOS)

For catalog features without an API token. Controls Music.app through System Events (Accessibility API) and CoreGraphics (mouse events).

Requirements: Display attached, Music.app visible, Accessibility permissions for System Events (System Settings → Privacy & Security → Accessibility).

Key Concepts

System Events reads and clicks UI elements by their accessibility hierarchy:

tell application "System Events" to tell process "Music"
    -- Main content area
    scroll area 2 of splitter group 1 of window "Music"
    -- Search field
    text field 1 of UI element 1 of row 1 of outline 1 of scroll area 1 of splitter group 1 of window "Music"
end tell

CoreGraphics mouse events (via JXA) trigger hover effects that reveal hidden UI controls:

// osascript -l JavaScript
ObjC.import("CoreGraphics");
var point = $.CGPointMake(x, y);
var event = $.CGEventCreateMouseEvent($(), $.kCGEventMouseMoved, point, 0);
$.CGEventPost($.kCGHIDEventTap, event);

The Hover Trick

Music.app hides per-track Play and "Add to Library" buttons until the mouse hovers over a track row. To interact with them programmatically:

  1. Find the track's UI element position via System Events
  2. Move the mouse there via CoreGraphics (generates real hover events)
  3. The hidden checkbox (play) and button (Add to Library) appear in the accessibility tree
  4. Click them via System Events

Search via UI

  1. Set the search field value: set value of searchField to "query"
  2. Press Return: key code 36
  3. Wait for results to load (~4 seconds)
  4. Parse the "Top Results" list from scroll area 2
  5. Each result is a UI element with description = name, static texts for type/artist

Note: The type separator in results uses Unicode three-per-em space (U+2004) + middle dot (U+00B7): Song꘎·꘎Radiohead

Window Recovery

Music.app can run without a window. To ensure a window exists:

tell application "Music" to activate
tell application "System Events" to tell process "Music"
    if (count of windows) is 0 then
        click menu item "Music" of menu "Window" of menu bar 1
    end if
end tell

Fragility

UI paths break when Apple updates Music.app's layout. Centralize paths as constants and test after macOS updates. Use Accessibility Inspector.app to explore the current hierarchy.

Compound flows (no API)

Recipes for replicating mcp-applemusic's catalog features without an API token. Gate each user request on "does this need catalog access?" — pure library and playback ops stay in AppleScript; only catalog lookups go through UI automation.

Add a catalog song to the user's library

If the user gave a single combined string like "Silvera - GOJIRA", split on - before searching so the catalog query gets a clean name.

  1. UI search for the target (§ Search via UI)
  2. Pick the first Song result whose name + artist match — do not fall back to a non-Song result; fail cleanly if no Song matched. Stale search state can lead to wrong-result clicks otherwise.
  3. Get the result's element position via System Events
  4. Move the mouse there via CoreGraphics to trigger hover — the hidden "Add to Library" button becomes reachable in the accessibility tree
  5. Click it via System Events
  6. Clear the search field so the next call starts from fresh state
  7. Poll search_library via AppleScript until the track is visible locally (typical 0.5–8 s; iCloud can stall longer — cap at ~18 s, then give up cleanly)

Add a catalog song to a specific playlist

Compose "add to library" (above) → then AppleScript duplicate the new library track into the target playlist:

tell application "Music"
    set targetTrack to first track of library playlist 1 ¬
        whose name contains "Silvera" and artist contains "GOJIRA"
    duplicate targetTrack to user playlist "Road Trip"
end tell

Don't click "Add to Playlist" menu items via UI — the AppleScript duplicate path is more reliable. Even if you have a dev token, don't hit POST /v1/me/library/playlists/{id}/tracks — it returns HTTP 500 for any playlist not originally created via API (the default for playlists made in Music.app). duplicate works for any playlist.

Post-add verification

The UI path can silently click the wrong result under stale search state, and AppleScript state lags briefly after a fresh add. Always verify the expected track actually landed:

tell application "Music"
    set matches to (every track of user playlist "Road Trip" ¬
        whose name contains "Silvera" and artist contains "GOJIRA")
    return (count of matches) > 0
end tell

Retry once after a ~1 s sleep before failing. If the second verify still fails, trust it — the add did not land, surface the error instead of claiming false success.


MusicKit API

Cross-platform but requires Apple Developer account ($99/year) and token setup.

Authentication

Requirements:

  1. Apple Developer account
  2. MusicKit key (.p8 file) from developer portal
  3. Developer token (JWT, 180 day max)
  4. User music token (browser OAuth)

Generate developer token:

import jwt, datetime

with open('AuthKey_XXXXXXXXXX.p8') as f:
    private_key = f.read()

token = jwt.encode(
    {
        'iss': 'TEAM_ID',
        'iat': int(datetime.datetime.now().timestamp()),
        'exp': int((datetime.datetime.now() + datetime.timedelta(days=180)).timestamp())
    },
    private_key,
    algorithm='ES256',
    headers={'alg': 'ES256', 'kid': 'KEY_ID'}
)

Get user token: Browser OAuth to https://authorize.music.apple.com/woa

Headers for all requests:

Authorization: Bearer {developer_token}
Music-User-Token: {user_music_token}

Base URL: https://api.music.apple.com/v1

Available Endpoints

Catalog (Public - dev token only)

EndpointMethodDescription
/catalog/{storefront}/searchGETSearch songs, albums, artists, playlists
/catalog/{storefront}/songs/{id}GETSong details
/catalog/{storefront}/albums/{id}GETAlbum details
/catalog/{storefront}/albums/{id}/tracksGETAlbum tracks
/catalog/{storefront}/artists/{id}GETArtist details
/catalog/{storefront}/artists/{id}/albumsGETArtist's albums
/catalog/{storefront}/artists/{id}/songsGETArtist's top songs
/catalog/{storefront}/artists/{id}/related-artistsGETSimilar artists
/catalog/{storefront}/playlists/{id}GETPlaylist details
/catalog/{storefront}/chartsGETTop charts
/catalog/{storefront}/genresGETAll genres
/catalog/{storefront}/search/suggestionsGETSearch autocomplete
/catalog/{storefront}/stations/{id}GETRadio station

Library (Requires user token)

EndpointMethodDescription
/me/library/songsGETAll library songs
/me/library/albumsGETAll library albums
/me/library/artistsGETAll library artists
/me/library/playlistsGETAll library playlists
/me/library/playlists/{id}GETPlaylist details
/me/library/playlists/{id}/tracksGETPlaylist tracks
/me/library/searchGETSearch library
/me/libraryPOSTAdd to library
/catalog/{sf}/songs/{id}/libraryGETGet library ID from catalog ID

Playlist Management

EndpointMethodDescription
/me/library/playlistsPOSTCreate playlist
/me/library/playlists/{id}/tracksPOSTAdd tracks to playlist

Personalization

EndpointMethodDescription
/me/recommendationsGETPersonalized recommendations
/me/history/heavy-rotationGETFrequently played
/me/recent/playedGETRecently played
/me/recent/addedGETRecently added

Ratings

EndpointMethodDescription
/me/ratings/songs/{id}GETGet song rating
/me/ratings/songs/{id}PUTSet song rating
/me/ratings/songs/{id}DELETERemove rating
/me/ratings/albums/{id}GET/PUT/DELETEAlbum ratings
/me/ratings/playlists/{id}GET/PUT/DELETEPlaylist ratings

Storefronts

EndpointMethodDescription
/storefrontsGETAll storefronts
/storefronts/{id}GETStorefront details
/me/storefrontGETUser's storefront

Common Query Parameters

ParameterDescriptionExample
termSearch queryterm=beatles
typesResource typestypes=songs,albums
limitResults per page (max 25)limit=10
offsetPagination offsetoffset=25
includeRelated resourcesinclude=artists,albums
extendAdditional attributesextend=editorialNotes
lLanguage codel=en-US

Search Example

GET /v1/catalog/us/search?term=wonderwall&types=songs&limit=10

Response:
{
  "results": {
    "songs": {
      "data": [{
        "id": "1234567890",
        "type": "songs",
        "attributes": {
          "name": "Wonderwall",
          "artistName": "Oasis",
          "albumName": "(What's the Story) Morning Glory?",
          "durationInMillis": 258773,
          "releaseDate": "1995-10-02",
          "genreNames": ["Alternative", "Music"]
        }
      }]
    }
  }
}

Library-First Workflow (Complete)

Adding a catalog song to a playlist requires 4 API calls:

import requests

headers = {
    "Authorization": f"Bearer {dev_token}",
    "Music-User-Token": user_token
}

# 1. Search catalog
r = requests.get(
    "https://api.music.apple.com/v1/catalog/us/search",
    headers=headers,
    params={"term": "Wonderwall Oasis", "types": "songs", "limit": 1}
)
catalog_id = r.json()['results']['songs']['data'][0]['id']

# 2. Add to library
requests.post(
    "https://api.music.apple.com/v1/me/library",
    headers=headers,
    params={"ids[songs]": catalog_id}
)

# 3. Get library ID (catalog ID → library ID)
r = requests.get(
    f"https://api.music.apple.com/v1/catalog/us/songs/{catalog_id}/library",
    headers=headers
)
library_id = r.json()['data'][0]['id']

# 4. Add to playlist (library IDs only!)
requests.post(
    f"https://api.music.apple.com/v1/me/library/playlists/{playlist_id}/tracks",
    headers={**headers, "Content-Type": "application/json"},
    json={"data": [{"id": library_id, "type": "library-songs"}]}
)

Create Playlist

POST /v1/me/library/playlists
Content-Type: application/json

{
  "attributes": {
    "name": "Road Trip",
    "description": "Summer vibes"
  },
  "relationships": {
    "tracks": {
      "data": []
    }
  }
}

Ratings

# Love a song (value: 1 = love, -1 = dislike)
PUT /v1/me/ratings/songs/{id}
Content-Type: application/json

{"attributes": {"value": 1}}

Limitations

  • No playback control - API cannot play/pause/skip
  • Playlist editing - can only modify API-created playlists
  • Token management - dev tokens expire every 180 days
  • Rate limits - Apple enforces request limits

Common Mistakes

❌ Using catalog IDs in playlists:

# WRONG
json={"data": [{"id": "1234567890", "type": "songs"}]}

Fix: Add to library first, get library ID, then add.

❌ Playing catalog songs via AppleScript:

# WRONG
play track id "1234567890"

Fix: Song must be in library.

❌ Unescaped AppleScript strings:

# WRONG
name = "Rock 'n Roll"
script = f'tell application "Music" to play playlist "{name}"'

Fix: Escape quotes.

❌ Expired tokens: Dev tokens last 180 days max. Fix: Check expiration, handle 401 errors.


The Easy Way: mcp-applemusic

The mcp-applemusic MCP server handles all this complexity automatically: AppleScript escaping, token management, library-first workflow, ID conversions.

Install:

git clone https://github.com/epheterson/mcp-applemusic.git
cd mcp-applemusic && python3 -m venv venv && source venv/bin/activate
pip install -e .

Configure Claude Desktop:

{
  "mcpServers": {
    "Apple Music": {
      "command": "/path/to/mcp-applemusic/venv/bin/python",
      "args": ["-m", "applemusic_mcp"]
    }
  }
}

On macOS, most features work immediately. For catalog features or Windows/Linux, see the repo README.

Manualmcp-applemusic
4 API calls to add songplaylist(action="add", auto_search=True)
Copy URL + open in Musicplayback(action="play", url="...")
UI hover + click to add to librarylibrary(action="add") with UI fallback
Track library changes manuallylibrary(action="snapshot")
AppleScript escapingAutomatic
Token managementAutomatic with warnings

适合场景

01

生成背景音乐

02

生成歌曲或旋律

03

视频和播客配乐

04

社媒内容音频素材

能力概览

能力 1

调用音乐生成模型

能力 2

支持文本到音乐或歌曲生成

能力 3

提供 CLI 示例和使用场景

能力 4

适合音频内容工作流

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

40.41%
按下载量换算105

Claude

30.17%
按下载量换算79

Cursor

17.69%
按下载量换算46

Gemini CLI

9.62%
按下载量换算25

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills