Apple Music integration via AppleScript (macOS) or MusicKit API
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install mcp-applemusic或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install mcp-applemusic⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/mcp-applemusic/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: apple-music version: 0.6.0 description: Apple Music integration via AppleScript (macOS) or MusicKit API ---
Guide for integrating with Apple Music. Covers AppleScript (macOS), MusicKit API (cross-platform), and the critical library-first requirement.
Invoke when users ask to:
You CANNOT add catalog songs directly to playlists.
Songs must be in the user's library first:
Why: Playlists use library IDs (i.abc123), not catalog IDs (1234567890).
This applies to both AppleScript and API approaches.
| Feature | AppleScript (macOS) | MusicKit API | |---------|:-------------------:|:------------:| | Setup required | None | Dev account + tokens | | Playlist management | Full | API-created only | | Playback control | Full | None | | Catalog search | No | Yes | | Library access | Instant | With tokens | | Cross-platform | No | Yes |
---
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
| Category | Operations | |----------|------------| | Playback | play, pause, stop, resume, next track, previous track, fast forward, rewind | | Player State | player position, player state, sound volume, mute, shuffle enabled/mode, song repeat | | Current Track | name, artist, album, duration, time, rating, loved, disliked, genre, year, track number | | Library | search, list tracks, get track properties, set ratings | | Playlists | list, create, delete, rename, add tracks, remove tracks, get tracks | | AirPlay | list devices, select device, current device |
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
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
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
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
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
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
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
...
安装 Apple Music 后,可以对 AI 说这些话来触发它
Help me get started with Apple Music
Explains what Apple Music does, walks through the setup, and runs a quick demo based on your current project
Use Apple Music to apple Music integration via AppleScript (macOS) or MusicKit API
Invokes Apple Music with the right parameters and returns the result directly in the conversation
What can I do with Apple Music in my design & creative workflow?
Lists the top use cases for Apple Music, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/mcp-applemusic/ 目录(个人级,所有项目可用),或 .claude/skills/mcp-applemusic/(项目级)。重启 AI 客户端后,用 /mcp-applemusic 主动调用,或让 AI 根据上下文自动发现并使用。
Apple Music 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Apple Music 可免费安装使用。请查阅仓库了解许可证信息。
Apple Music integration via AppleScript (macOS) or MusicKit API
Apple Music 属于「Design & Creative」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my design & creative tasks using Apple Music
Identifies repetitive steps in your workflow and sets up Apple Music to handle them automatically