Skip to main content
Glama

recent_movies

Retrieve a list of recently added movies from your Plex library by specifying the number of entries. Integrates with Plex Media Server API for streamlined library updates.

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 main asynchronous handler function for the 'recent_movies' tool. It is decorated with @mcp.tool() for automatic registration in FastMCP. Fetches recently added movies from the Plex library sorted by 'addedAt:desc', limits to the specified count, formats each using format_movie helper, and returns a delimited 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)}"

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