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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_applemusic.py:141-157 (handler)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)
- mcp_applemusic.py:5-10 (helper)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()