Skip to main content
Glama
djbriane
by djbriane

delete_playlist

Remove playlists from your Plex Media Server to manage your media library and organize content by deleting unwanted or outdated collections.

Instructions

Delete a playlist from the Plex server.

Parameters: playlist_key: The key of the playlist to delete.

Returns: A success message if deletion is successful, or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_keyYes

Implementation Reference

  • The main handler function for the 'delete_playlist' tool. It connects to the Plex server, finds the playlist by key, deletes it, and returns a success or error message.
    @mcp.tool()
    async def delete_playlist(playlist_key: str) -> str:
        """
        Delete a playlist from the Plex server.
        
        Parameters:
            playlist_key: The key of the playlist to delete.
            
        Returns:
            A success message if deletion is successful, or an error message.
        """
        try:
            plex = await get_plex_server()
        except Exception as e:
            return f"ERROR: Could not connect to Plex server. {str(e)}"
    
        try:
            key = int(playlist_key)
            all_playlists = await asyncio.to_thread(plex.playlists)
            playlist = next((p for p in all_playlists if p.ratingKey == key), None)
            if not playlist:
                return f"No playlist found with key {playlist_key}."
            await asyncio.to_thread(playlist.delete)
            logger.info("Playlist '%s' with key %s successfully deleted.", playlist.title, playlist_key)
            return f"Successfully deleted playlist '{playlist.title}' with key {playlist_key}."
        except NotFound:
            return f"ERROR: Playlist with key {playlist_key} not found."
        except Exception as e:
            logger.exception("Failed to delete playlist with key '%s'", playlist_key)
            return f"ERROR: Failed to delete playlist. {str(e)}"
  • The tool name 'delete_playlist' is included in the __all__ export list, making it available when importing from the package.
    "delete_playlist",
  • Helper function used by delete_playlist to asynchronously obtain the PlexServer instance.
    async def get_plex_server() -> PlexServer:
        """
        Asynchronously get a PlexServer instance via the singleton PlexClient.
        
        Returns:
            A PlexServer instance.
            
        Raises:
            Exception: When the Plex server connection fails.
        """
        try:
            plex_client = get_plex_client()  # Singleton accessor
            plex = await asyncio.to_thread(plex_client.get_server)
            return plex
        except Exception as e:
            logger.exception("Failed to get Plex server instance")
            raise e
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 deletes a playlist and mentions success/error messages, but lacks details on permissions required, whether deletion is irreversible, rate limits, or side effects (e.g., impact on associated items). This is a significant gap for a destructive operation.

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 action. The parameter and return sections are structured but could be more integrated; overall, it avoids unnecessary verbosity while covering essential points efficiently.

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

Completeness2/5

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

Given the tool's complexity (destructive operation with no annotations and no output schema), the description is incomplete. It lacks critical context such as authentication needs, error handling specifics, or behavioral nuances, making it inadequate for safe and effective use by an AI agent.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'playlist_key' identifies the playlist to delete, which clarifies the parameter's purpose beyond the schema's title ('Playlist Key'). However, it does not provide format examples or constraints, leaving some ambiguity.

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 ('Delete') and resource ('a playlist from the Plex server'), distinguishing it from sibling tools like 'create_playlist' or 'list_playlists'. It directly addresses what the tool does without being tautological.

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. It does not mention prerequisites (e.g., needing an existing playlist), exclusions, or compare it to related tools like 'add_to_playlist' or 'get_playlist_items', 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/djbriane/plex-mcp'

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