Skip to main content
Glama

itunes_all_songs

Retrieve all songs from your Apple Music library to view a formatted list of tracks with artist names.

Instructions

Get a list of all songs in the Music library. Returns a formatted list of all tracks with their names and artists.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'itunes_all_songs' tool. It uses AppleScript to fetch all tracks from the Music app's Library playlist and returns a list formatted as 'Track Name - Artist' for each track. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool() def itunes_all_songs() -> str: """ Get a list of all songs in the Music library. Returns a formatted list of all tracks with their names and artists. """ script = """ tell application "Music" set trackList to every track of playlist "Library" set output to "" repeat with t in trackList set output to output & (name of t) & " - " & (artist of t) & linefeed end repeat return output end tell """ return run_applescript(script)
  • Shared helper function used by itunes_all_songs (and other tools) to execute AppleScript commands via the osascript subprocess.
    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()

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