Skip to main content
Glama

itunes_current_song

Retrieve details of the currently playing track on Apple Music, including track name, artist, and album, through the MCP-AppleMusic server.

Instructions

Get information about the currently playing track. Returns the track name, artist, and album.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'itunes_current_song' tool. It uses AppleScript to query the Music app for the currently playing track and returns its name, artist, and album if playing, or a message if not.
    @mcp.tool() def itunes_current_song() -> str: """ Get information about the currently playing track. Returns the track name, artist, and album. """ script = """ tell application "Music" if player state is playing then set currentTrack to current track return "Now playing: " & (name of currentTrack) & " by " & (artist of currentTrack) & " from " & (album of currentTrack) else return "No track is currently playing" end if end tell """ return run_applescript(script)
  • Helper function used by the tool to execute AppleScript commands and handle subprocess output or errors.
    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_current_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