Skip to main content
Glama
djbriane
by djbriane

list_playlists

Retrieve all available playlists from your Plex media server to browse and manage your curated media collections.

Instructions

List all playlists in the Plex server.

Returns: A formatted string of playlists or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'list_playlists' tool. It fetches all playlists from the Plex server using the singleton PlexClient, formats each using the format_playlist helper, and returns a formatted string response.
    @mcp.tool()
    async def list_playlists() -> str:
        """
        List all playlists in the Plex server.
        
        Returns:
            A formatted string of playlists 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:
            playlists = await asyncio.to_thread(plex.playlists)
            if not playlists:
                return "No playlists found in your Plex server."
            formatted_playlists = []
            for i, playlist in enumerate(playlists, 1):
                formatted_playlists.append(
                    f"Playlist #{i}:\nKey: {playlist.ratingKey}\n{format_playlist(playlist)}"
                )
            return "\n---\n".join(formatted_playlists)
        except Exception as e:
            logger.exception("Failed to fetch playlists")
            return f"ERROR: Failed to fetch playlists. {str(e)}"
  • Supporting utility function used by list_playlists to format individual playlist information including title, item count, total duration, and last updated timestamp.
    def format_playlist(playlist) -> str:
        """
        Format a playlist into a human-readable string.
        
        Parameters:
            playlist: A Plex playlist object.
            
        Returns:
            A formatted string containing playlist details.
        """
        duration_mins = sum(item.duration for item in playlist.items()) // 60000 if playlist.items() else 0
        updated = (
            playlist.updatedAt.strftime('%Y-%m-%d %H:%M:%S')
            if hasattr(playlist, 'updatedAt') else 'Unknown'
        )
        return (
            f"Playlist: {playlist.title}\n"
            f"Items: {len(playlist.items())}\n"
            f"Duration: {duration_mins} minutes\n"
            f"Last Updated: {updated}\n"
        )
  • Package __init__.py imports and exposes list_playlists from plex_mcp.py, making it available for use as an MCP tool.
    from .plex_mcp import (
        search_movies,
        get_movie_details,
        list_playlists,
        get_playlist_items,
        create_playlist,
        delete_playlist,
        add_to_playlist,
        recent_movies,
        get_movie_genres,
        get_plex_server,
        MovieSearchParams,
    )
  • Helper function used by list_playlists to asynchronously obtain the PlexServer instance via the PlexClient singleton.
    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 full burden for behavioral disclosure. It mentions the return format ('formatted string of playlists or an error message'), which is helpful, but lacks critical details like whether this requires authentication, how many playlists might be returned (pagination?), or if there are rate limits. For a read operation with zero annotation coverage, this leaves significant gaps.

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 brief and front-loaded with the core action ('List all playlists in the Plex server'), followed by a concise note on returns. Both sentences are necessary—the first defines the purpose, and the second clarifies output format—with no wasted words.

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 simplicity (0 parameters, no output schema, no annotations), the description is adequate but minimal. It covers the basic purpose and output format, which might suffice for a straightforward list operation, but lacks context about authentication, performance, or sibling tool differentiation that could help an agent use it effectively.

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 tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to explain any parameters, so it appropriately focuses on the action and output. A baseline of 4 is justified since there are no parameters to document.

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

Purpose4/5

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

The description clearly states the verb ('List') and resource ('all playlists in the Plex server'), making the purpose immediately understandable. However, it doesn't differentiate this from sibling tools like 'get_playlist_items' or 'create_playlist', which would require more specific scope definition.

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 like 'get_playlist_items' (which presumably retrieves items within a specific playlist) or 'search_movies' (which might find content across playlists). The description only states what it does, not when it's appropriate.

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