Skip to main content
Glama

itunes_all_songs

Retrieve a formatted list of all songs in your Apple Music library, including track names and artists, using commands from the MCP-AppleMusic server.

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 @mcp.tool() decorator registers and defines the handler function for the 'itunes_all_songs' tool. It executes an AppleScript to fetch all tracks from the Music library playlist, formatting them as 'name - artist' and returns the output.
    @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)
  • Helper function used by itunes_all_songs (and other tools) to execute AppleScript commands via 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()

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