Skip to main content
Glama
djbriane
by djbriane

get_movie_details

Retrieve comprehensive details for a specific movie in your Plex library using its unique identifier.

Instructions

Get detailed information about a specific movie.

Parameters: movie_key: The key identifying the movie.

Returns: A formatted string with movie details or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
movie_keyYes

Implementation Reference

  • The core handler function for the get_movie_details tool. It connects to the Plex server, searches for the movie by its ratingKey, and returns formatted details using the format_movie helper or appropriate error messages.
    @mcp.tool()
    async def get_movie_details(movie_key: str) -> str:
        """
        Get detailed information about a specific movie.
        
        Parameters:
            movie_key: The key identifying the movie.
            
        Returns:
            A formatted string with movie details 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(movie_key)
    
            all_movies = await asyncio.to_thread(lambda: plex.library.search(libtype="movie"))
            movie = next((m for m in all_movies if m.ratingKey == key), None)
    
            if not movie:
                return f"No movie found with key {movie_key}."
            return format_movie(movie)
        except NotFound:
            return f"ERROR: Movie with key {movie_key} not found."
        except Exception as e:
            logger.exception("Failed to fetch movie details for key '%s'", movie_key)
            return f"ERROR: Failed to fetch movie details. {str(e)}"
  • Utility function that formats a Plex movie object into a detailed human-readable string, called by get_movie_details to present the movie information.
    def format_movie(movie) -> str:
        """
        Format a movie object into a human-readable string.
        
        Parameters:
            movie: A Plex movie object.
            
        Returns:
            A formatted string containing movie details.
        """
        title = getattr(movie, 'title', 'Unknown Title')
        year = getattr(movie, 'year', 'Unknown Year')
        summary = getattr(movie, 'summary', 'No summary available')
        duration = getattr(movie, 'duration', 0) // 60000 if hasattr(movie, 'duration') else 0
        rating = getattr(movie, 'rating', 'Unrated')
        studio = getattr(movie, 'studio', 'Unknown Studio')
        directors = [director.tag for director in getattr(movie, 'directors', [])[:3]]
        actors = [role.tag for role in getattr(movie, 'roles', [])[:5]]
        
        return (
            f"Title: {title} ({year})\n"
            f"Rating: {rating}\n"
            f"Duration: {duration} minutes\n"
            f"Studio: {studio}\n"
            f"Directors: {', '.join(directors) if directors else 'Unknown'}\n"
            f"Starring: {', '.join(actors) if actors else 'Unknown'}\n"
            f"Summary: {summary}\n"
        )
  • Helper function to asynchronously obtain a PlexServer instance using a singleton PlexClient, used by get_movie_details for server connection.
    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
  • The @mcp.tool() decorator registers the get_movie_details function as an MCP tool, with input schema inferred from type hints (movie_key: str) and output str.
    @mcp.tool()
    async def get_movie_details(movie_key: str) -> str:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool returns a 'formatted string with movie details or an error message', which adds some context about output format and error handling. However, it lacks details on permissions, rate limits, or whether it's a read-only operation, which are important for a tool with no annotations.

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 appropriately sized and front-loaded, starting with the core purpose followed by parameter and return details. It uses clear sections ('Parameters:', 'Returns:') for structure, with no wasted sentences, making it efficient and easy to scan.

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 has no annotations, no output schema, and low schema coverage, the description is minimally adequate. It covers the basic purpose, parameter, and return format, but lacks depth in usage guidelines, behavioral traits, and parameter details, which are needed for a tool with such sparse structured data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists the parameter 'movie_key' and explains it as 'The key identifying the movie', adding basic meaning beyond the schema's title 'Movie Key'. However, it doesn't provide examples, format details, or constraints, leaving gaps in understanding how to use the parameter effectively.

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 tool's purpose with a specific verb ('Get') and resource ('detailed information about a specific movie'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'get_movie_genres' or 'search_movies', which might provide overlapping or related functionality.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing a valid movie_key, or compare it to siblings like 'search_movies' for finding movies or 'get_movie_genres' for genre-specific details, leaving the agent to infer usage context.

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