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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'Returns a confirmation message including the number of tracks added,' which adds some context about output behavior. However, it lacks critical details such as whether this operation requires specific permissions, if it's idempotent, what happens on errors (e.g., duplicate playlist names), or any rate limits. For a mutation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by specific parameter guidance and return behavior in subsequent sentences. Every sentence adds value without redundancy, making it efficient and easy to parse. No words are wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there is an output schema (which should document the return values), the description doesn't need to explain return details extensively. However, for a mutation tool with no annotations and 0% schema description coverage, the description provides basic purpose and parameter guidance but lacks behavioral context like error handling or prerequisites. It's minimally adequate but has clear gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It adds meaningful semantics beyond the schema: it explains that 'songs' should be a 'comma-separated list of exact track names,' which clarifies the format and requirement for exact names. However, it doesn't provide similar context for the 'name' parameter (e.g., length limits, allowed characters), leaving some gaps. Given the low schema coverage, this is above baseline but not fully comprehensive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Create a new playlist') and resources involved ('with the given name and add tracks to it'), distinguishing it from sibling tools like itunes_play_song (plays existing songs) or itunes_search (finds songs). It provides a complete picture of the tool's function beyond just the name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention whether this should be used instead of modifying existing playlists (if such a tool exists) or clarify that it's for creating new playlists specifically, not updating existing ones. The description assumes the context without providing explicit usage boundaries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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