Skip to main content
Glama

itunes_create_playlist

Create a new Apple Music playlist by specifying a name and adding tracks from your library. Provide exact song titles in a comma-separated list to build custom collections.

Instructions

Create a new playlist with the given name and add tracks to it. 'songs' should be a comma-separated list of exact track names. Returns a confirmation message including the number of tracks added.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
songsYes

Implementation Reference

  • The handler function for the 'itunes_create_playlist' tool. It creates a new playlist in the Music app using AppleScript, adds tracks matching the provided song names from the library, and returns a confirmation message.
    @mcp.tool() def itunes_create_playlist(name: str, songs: str) -> str: """ Create a new playlist with the given name and add tracks to it. 'songs' should be a comma-separated list of exact track names. Returns a confirmation message including the number of tracks added. """ # Split the songs string into a list. song_list = [s.strip() for s in songs.split(",") if s.strip()] if not song_list: return "No songs provided." # Build a condition string that matches any one of the song names. # Example: 'name is "Song1" or name is "Song2"' conditions = " or ".join([f'name is "{s}"' for s in song_list]) script = f""" tell application "Music" set newPlaylist to make new user playlist with properties {{name:"{name}"}} set matchingTracks to every track of playlist "Library" whose ({conditions}) repeat with t in matchingTracks duplicate t to newPlaylist end repeat return "Playlist \\"{name}\\" created with " & (count of tracks of newPlaylist) & " tracks." end tell """ return run_applescript(script)

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