Skip to main content
Glama

get_playlist_items

Retrieve items from a Plex playlist using the playlist key. This tool outputs a formatted list of playlist items or an error message, simplifying media library management.

Instructions

Get the items in a specific playlist.

Parameters: playlist_key: The key of the playlist to retrieve items from.

Returns: A formatted string of playlist items or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_keyYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the logic to retrieve and format items from a specific Plex playlist by its key.
    @mcp.tool() async def get_playlist_items(playlist_key: str) -> str: """ Get the items in a specific playlist. Parameters: playlist_key: The key of the playlist to retrieve items from. Returns: A formatted string of playlist items 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}." items = playlist.items() if not items: return "No items found in this playlist." formatted_items = [] for i, item in enumerate(items, 1): title = item.title year = getattr(item, 'year', '') type_str = item.type.capitalize() formatted_items.append(f"{i}. {title} ({year}) - {type_str}") return "\n".join(formatted_items) except NotFound: return f"ERROR: Playlist with key {playlist_key} not found." except Exception as e: logger.exception("Failed to fetch items for playlist key '%s'", playlist_key) return f"ERROR: Failed to fetch playlist items. {str(e)}"

Other Tools

Related 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