Skip to main content
Glama
jamiew

Spotify MCP Server

create_playlist

Create a new Spotify playlist by specifying name, description, and privacy settings to organize your music collection.

Instructions

Create a new Spotify playlist.

Args:
    name: Playlist name
    description: Playlist description (default: empty)
    public: Whether playlist is public (default: True)

Returns:
    Dict with created playlist information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionNo
publicNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary handler function for the 'create_playlist' MCP tool. Decorated with @mcp.tool() which handles registration and automatic schema generation from type hints. Directly calls Spotify API to create and return structured playlist info.
    @mcp.tool()
    @log_tool_execution
    def create_playlist(
        name: str, description: str = "", public: bool = True
    ) -> dict[str, Any]:
        """Create a new Spotify playlist.
    
        Args:
            name: Playlist name
            description: Playlist description (default: empty)
            public: Whether playlist is public (default: True)
    
        Returns:
            Dict with created playlist information
        """
        try:
            logger.info(f"🎧 Creating playlist: '{name}' (public={public})")
            user = spotify_client.current_user()
            result = spotify_client.user_playlist_create(
                user["id"], name, public=public, description=description
            )
    
            playlist = Playlist(
                name=result["name"],
                id=result["id"],
                owner=result.get("owner", {}).get("display_name"),
                description=result.get("description"),
                tracks=[],
                total_tracks=0,
                public=result.get("public"),
            )
    
            return playlist.model_dump()
    
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • Pydantic model defining the structured output schema for the create_playlist tool and other playlist-related tools.
    class Playlist(BaseModel):
        """A Spotify playlist."""
    
        name: str
        id: str
        owner: str | None = None
        description: str | None = None
        tracks: list[Track] | None = None
        total_tracks: int | None = None
        public: bool | None = None
  • FastMCP decorator @mcp.tool() that registers the create_playlist function as an MCP tool, inferring input schema from annotations.
    @mcp.tool()
  • Supporting helper method in SpotifyClient class for creating playlists, wrapping spotipy API call (not directly used by MCP handler).
    def create_playlist(
        self, user_id: str, name: str, description: str = "", public: bool = False
    ) -> dict[str, Any]:
        """Create a new playlist"""
        try:
            self.logger.info(f"Creating playlist '{name}' for user {user_id}")
            self.logger.info(f"Description: {description}, Public: {public}")
    
            playlist = self.sp.user_playlist_create(
                user_id, name, public=public, description=description
            )
            playlist_info = utils.parse_playlist(playlist, detailed=True)
    
            if playlist_info:
                self.logger.info(
                    f"Successfully created playlist. ID: {playlist_info.get('id', 'Unknown')}"
                )
            else:
                self.logger.warning("Created playlist but received empty playlist info")
    
            return playlist_info if playlist_info else {}
        except Exception as e:
            self.logger.error(f"Error creating playlist: {str(e)}", exc_info=True)
            raise
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 states the tool creates a playlist but doesn't mention critical behaviors like authentication requirements, rate limits, error conditions, or what happens on success (beyond the vague 'created playlist information'). This leaves significant gaps for a mutation tool.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose. The Args and Returns sections are structured for clarity, though the 'Returns' statement is somewhat vague ('Dict with created playlist information'). Every sentence adds value, with minimal waste.

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 the tool's complexity (a mutation with 3 parameters), lack of annotations, and presence of an output schema (which should cover return values), the description is moderately complete. It explains parameters well but misses behavioral details like authentication, making it adequate but with clear gaps for safe use.

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 description adds meaningful context beyond the input schema, which has 0% description coverage. It explains that 'name' is the playlist name, 'description' is the playlist description with a default of empty, and 'public' controls visibility with a default of True. This compensates well for the schema's lack of descriptions, though it doesn't detail constraints (e.g., name length limits).

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 Spotify playlist') and identifies the resource ('Spotify playlist'), making the purpose immediately evident. It distinguishes this tool from sibling tools like 'modify_playlist_details' or 'get_user_playlists' by focusing on creation rather than modification or retrieval.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., user authentication), when not to use it (e.g., for existing playlists), or refer to sibling tools like 'modify_playlist_details' for updates, leaving usage context unclear.

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/jamiew/spotify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server