Skip to main content
Glama

itunes_play_song

Play a specific song in Apple Music by matching the exact song name. Returns a confirmation message upon successful playback. Part of the MCP-AppleMusic server for macOS control.

Instructions

Play the first track whose name exactly matches the given song name. Returns a confirmation message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
songYes

Implementation Reference

  • The handler function for the 'itunes_play_song' tool. It uses AppleScript via run_applescript to find and play a song by exact name match in the Music library, returning a confirmation message.
    @mcp.tool() def itunes_play_song(song: str) -> str: """ Play the first track whose name exactly matches the given song name. Returns a confirmation message. """ script = f""" tell application "Music" set theTrack to first track of playlist "Library" whose name is "{song}" play theTrack return "Now playing: " & (name of theTrack) & " by " & (artist of theTrack) end tell """ return run_applescript(script)
  • Helper function used by itunes_play_song (and other tools) to execute AppleScript commands.
    def run_applescript(script: str) -> str: """Execute an AppleScript command via osascript and return its output.""" result = subprocess.run(["osascript", "-e", script], capture_output=True, text=True) if result.returncode != 0: return f"Error: {result.stderr.strip()}" return result.stdout.strip()
  • The @mcp.tool() decorator registers the itunes_play_song function as an MCP tool.
    @mcp.tool()

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kennethreitz/mcp-applemusic'

If you have feedback or need assistance with the MCP directory API, please join our Discord server