Music MCP

Music MCP

Enables AI assistants to control Apple Music on macOS using AppleScript for playback, library management, and playlist operations. It supports features like searching tracks, managing the play queue, and retrieving detailed metadata through a structured interface.

Category
访问服务器

README

Music MCP

npm version License: MIT

A Model Context Protocol (MCP) server for controlling Apple Music on macOS using AppleScript. This connector provides a structured interface for AI assistants like Claude to interact with the Music app, enabling playback control, library management, and music information retrieval.

Features

  • Playback Control: Play, pause, skip tracks, and control volume
  • Current Track Information: Get detailed track metadata and playback status
  • Library Management: Search tracks, albums, artists, and browse your library
  • Playlist Management: Create, manage, modify, and play playlists
  • Enhanced Queue Management: Add tracks to play next, view queue status, and control playback order
  • Smart "Play Next" Feature: Queue tracks to play after the current song using temporary playlists
  • Diagnostic Tools: Built-in info command for troubleshooting

Requirements

  • macOS (required for Apple Music and AppleScript)
  • Node.js 18.0.0 or higher
  • Apple Music app installed and accessible
  • Automation permissions granted to your terminal/app

Installation

Via npm (Recommended)

npx @pedrocid/music-mcp@latest

For Development

git clone https://github.com/pedrocid/music-mcp.git
cd music-mcp
npm install
npm run build

Building as Desktop Extension

If you want to create a Desktop Extension (.dxt) for distribution:

# Install the DXT CLI tool
npm install -g @anthropic-ai/dxt

# Initialize Desktop Extension (if not already done)
dxt init

# Build the project
npm run build

# Package the extension
dxt pack

This creates a music-mcp.dxt file that can be installed directly in Claude Desktop or submitted to the Anthropic extension directory.

Note: The .dxt file is not included in the repository as it's a build artifact. Users who want the Desktop Extension should build it themselves using the instructions above.

Configuration

Claude Desktop Configuration

Add this to your Claude Desktop MCP configuration:

{
  "mcpServers": {
    "music": {
      "command": "npx",
      "args": ["@pedrocid/music-mcp@latest"]
    }
  }
}

Environment Variables (Optional)

All environment variables are optional. The server uses stderr logging by default and works without any configuration.

Variable Default Description
MUSIC_MCP_LOG_LEVEL info Log level (debug, info, warn, error)
MUSIC_MCP_FILE_LOGGING false Enable file logging (disabled by default)
MUSIC_MCP_LOG_FILE ~/Library/Logs/music-mcp.log Log file location (only used if file logging enabled)
MUSIC_MCP_CACHE_TTL 300 Cache timeout in seconds
MUSIC_MCP_MAX_SEARCH_RESULTS 50 Maximum search results
MUSIC_MCP_TIMEOUT_SECONDS 30 Default timeout for operations
MUSIC_MCP_ARTWORK_EXPORT true Enable album artwork export
MUSIC_MCP_LENIENT_PARSING true Accept variations in parameter names

Available Tools

info

Get diagnostic information about the MCP server status.

{
  "command": "info"
}

Returns version information, Music app availability, and configuration status.

execute_music_command

Execute music playback control commands.

{
  "command": "play|pause|next|previous|toggle_playback",
  "volume": 75,
  "position": 30,
  "shuffleMode": true,
  "repeatMode": "all",
  "rating": 4
}

get_music_info

Retrieve information about current playback or library.

{
  "infoType": "current_track|playback_status|queue|library_stats",
  "format": "simple|detailed"
}

search_music

Search the music library.

{
  "query": "artist name or song title",
  "searchType": "all|track|album|artist|playlist",
  "limit": 25
}

manage_playlist

Create and manage playlists.

{
  "action": "create|add_track|remove_track|rename|delete|list|get_tracks",
  "playlistName": "My Playlist",
  "trackId": "search term for track",
  "newName": "New Playlist Name"
}

queue_musicNEW

Enhanced queue management and playlist control.

{
  "action": "view_queue|add_to_queue|play_queue|clear_queue|play_playlist",
  "trackSearchTerm": "song or artist name",
  "playlistName": "My Playlist",
  "shuffle": true
}

Queue Actions:

  • view_queue: See current track, playlist context, and playback status
  • add_to_queue: Add tracks to a temporary "Up Next" queue for sequential playback
  • play_queue: Play the tracks you've added to the queue
  • clear_queue: Clear all tracks from the up next queue
  • play_playlist: Play a specific playlist (with optional shuffle)

Permissions

When first using the MCP server, macOS will prompt you to grant automation permissions. You need to:

  1. Allow your terminal app (Terminal.app, iTerm2, etc.) to control "Music"
  2. Go to System Preferences > Security & Privacy > Privacy > Automation
  3. Ensure your terminal app has permission to control "Music"

Troubleshooting

Check Server Status

npx @pedrocid/music-mcp@latest
# Then use the info tool to check status

Common Issues

"Music app is not running"

  • The server automatically launches the Music app when needed
  • If issues persist, manually open the Music app first

"AppleScript execution failed"

  • Grant automation permissions in System Preferences
  • Ensure Music app is accessible and not restricted

"No tracks found"

  • Check that you have music in your library
  • Verify your Apple Music subscription is active

Debugging

The server logs to stderr by default, which Claude Desktop captures. For additional debugging, you can:

  1. Check Claude Desktop's MCP logs
  2. Enable file logging by setting MUSIC_MCP_FILE_LOGGING=true environment variable
  3. Use the info tool to check server diagnostics

Example Usage

Here are some example interactions you can have with Claude using this MCP server:

Basic Playback:

  • "Play my music and set the volume to 50%"
  • "What song is currently playing?"
  • "Skip to the next track"

Library & Search:

  • "Search for songs by Taylor Swift"
  • "Show me my library statistics"

Playlist Management:

  • "Create a playlist called 'Road Trip' and add some upbeat songs"
  • "Play my 'Chill' playlist with shuffle enabled"
  • "Remove all tracks by [artist] from my 'Favorites' playlist"

Queue Management (NEW):

  • "Add 'Bohemian Rhapsody' to play next"
  • "Show me what's in my up next queue"
  • "Clear my queue and add these 3 songs to play after the current track"
  • "Play my 'Party Mix' playlist next"

Development

Building

npm run build

Testing

npm test              # Unit tests
npm run test:e2e      # Integration tests

Linting

npm run lint

Release Preparation

npm run prepare-release

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests
  4. Run the test suite: npm test
  5. Run the release preparation: npm run prepare-release
  6. Commit your changes: git commit -am 'Add feature'
  7. Push to the branch: git push origin feature-name
  8. Submit a pull request

License

MIT License - see the LICENSE file for details.

Support

Related Projects

推荐服务器

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

官方
精选