delete_playlist
Remove a playlist from your Plex Media Server by specifying its unique playlist key. Ensures efficient playlist management through direct integration with Plex API.
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
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_key | Yes |
Implementation Reference
- src/plex_mcp/plex_mcp.py:448-476 (handler)The core handler function for the 'delete_playlist' tool, decorated with @mcp.tool() for registration in the MCP framework. It handles connecting to the Plex server, locating the playlist by key, deleting it, and returning appropriate success or error messages.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)}"
- src/plex_mcp/__init__.py:7-21 (registration)The delete_playlist function is imported and exposed via __all__ in the package __init__.py, making it available for use and potentially for tool registration in the broader application.delete_playlist, add_to_playlist, recent_movies, get_movie_genres, get_plex_server, MovieSearchParams, ) __all__ = [ "search_movies", "get_movie_details", "list_playlists", "get_playlist_items", "create_playlist", "delete_playlist",
- src/plex_mcp/__init__.py:21-27 (registration)Explicit listing in __all__ confirms public exposure of the delete_playlist tool."delete_playlist", "add_to_playlist", "recent_movies", "get_movie_genres", "get_plex_server", "MovieSearchParams", ]