Skip to main content
Glama

recent_movies

Retrieve recently added movies from your Plex library to stay updated on new content. Specify the number of movies to display for quick access to your latest additions.

Instructions

Get recently added movies from the Plex library.

Parameters: count: The maximum number of recent movies to return.

Returns: A formatted string of recent movies or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNo

Implementation Reference

  • The core handler function for the 'recent_movies' tool, decorated with @mcp.tool(). It fetches the most recently added movies from the Plex library using the Plex API, limits them by count, formats them using format_movie helper, and returns a formatted string or error message.
    @mcp.tool() async def recent_movies(count: int = 5) -> str: """ Get recently added movies from the Plex library. Parameters: count: The maximum number of recent movies to return. Returns: A formatted string of recent movies or an error message. """ if count <= 0: return "ERROR: Count must be a positive integer." try: plex = await get_plex_server() except Exception as e: return f"ERROR: Could not connect to Plex server. {str(e)}" try: # Perform a global search for recently added movies all_recent = await asyncio.to_thread(lambda: plex.library.search(libtype="movie", sort="addedAt:desc")) recent_movies_list = all_recent[:count] if not recent_movies_list: return "No recent movies found in your Plex library." formatted_movies = [] for i, movie in enumerate(recent_movies_list, 1): formatted_movies.append( f"Recent Movie #{i}:\nKey: {movie.ratingKey}\nAdded: {movie.addedAt.strftime('%Y-%m-%d')}\n{format_movie(movie)}" ) return "\n---\n".join(formatted_movies) except Exception as e: logger.exception("Failed to fetch recent movies") return f"ERROR: Failed to fetch recent movies. {str(e)}"
  • Imports the recent_movies function (and others) from plex_mcp.py into the package __init__, making it available for import as part of the plex_mcp module.
    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, )
  • Explicitly lists 'recent_movies' in __all__, ensuring it is exported when using 'from plex_mcp import *'.
    __all__ = [ "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", ]

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