Apple音乐控制服务

一个通过AppleScript命令控制macOS上Apple Music(原iTunes)的FastMCP服务器实现。

  • by kennethreitz
  • Python
  • 本地部署
  • 91 星标
  • 更新于
在 GitHub 查看 kennethreitz/mcp-applemusic

使用说明

MCP苹果音乐

FastMCP服务器实现,用于通过AppleScript命令在macOS上控制Apple Music(以前的iTunes)。

需求

  • Python 3.13+
  • 安装了Apple Music应用程序的macOS
  • MCP库≥1.2.1

安装

首先,确保您安装了紫外线:

$ brew install uv

然后,随着 克劳德桌面,添加以下内容 claude_desktop_config.json:

{
  "mcpServers": {
    "iTunesControlServer": {
      "command": "uvx",
      "args": ["-p", "3.13", "-n", "mcp-applemusic"]
    }
  }
}

可用命令

以下命令可通过MCP服务器使用:

itunes_play()         # Start playback
itunes_pause()        # Pause playback
itunes_next()         # Skip to next track
itunes_previous()     # Go to previous track
itunes_search(query)  # Search library for tracks
itunes_play_song(song)  # Play specific song
itunes_create_playlist(name, songs)  # Create new playlist
itunes_library()      # Get library statistics

用法

启动服务器:

python server.py

交互示例:

# Search for a song
results = itunes_search("Hey Jude")

# Create a new playlist
itunes_create_playlist("Beatles Favorites", ["Yesterday", "Hey Jude", "Let It Be"])

# Play a specific song
itunes_play_song("Hey Jude")

发展

  1. 克隆存储库:
git clone https://github.com/yourusername/mcp-applemusic.git
cd mcp-applemusic
  1. 安装开发依赖项:
pip install -e ".[dev]"

贡献

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

备注

  • 由于其AppleScript依赖性,此工具仅适用于macOS系统
  • 需要安装Apple Music(以前的iTunes)