Skip to main content
Glama
djbriane
by djbriane

get_movie_genres

Retrieve genre information for a specific movie in your Plex library using its unique identifier.

Instructions

Get genres for a specific movie.

Parameters: movie_key: The key of the movie.

Returns: A formatted string of movie genres or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
movie_keyYes

Implementation Reference

  • The core handler function for the 'get_movie_genres' tool, decorated with @mcp.tool(). It connects to Plex, searches for the movie by key, extracts its genres, and returns a formatted string or error message.
    @mcp.tool()
    async def get_movie_genres(movie_key: str) -> str:
        """
        Get genres for a specific movie.
        
        Parameters:
            movie_key: The key of the movie.
            
        Returns:
            A formatted string of movie genres 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)
    
            # Perform a global search for the movie
            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}."
    
            # Extract genres
            genres = [genre.tag for genre in movie.genres] if hasattr(movie, 'genres') else []
            if not genres:
                return f"No genres found for movie '{movie.title}'."
            return f"Genres for '{movie.title}':\n{', '.join(genres)}"
        except ValueError:
            return f"ERROR: Invalid movie key '{movie_key}'. Please provide a valid number."
        except Exception as e:
            logger.exception("Failed to fetch genres for movie with key '%s'", movie_key)
            return f"ERROR: Failed to fetch movie genres. {str(e)}"
  • The __init__.py file re-exports the get_movie_genres tool (along with others) via import and __all__, making it available when importing from the plex_mcp package.
    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,
    )
    
    __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",
    ]
  • Helper function used by get_movie_genres to asynchronously obtain the PlexServer instance via a singleton PlexClient.
    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
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 states the tool returns 'A formatted string of movie genres or an error message,' which hints at output behavior but lacks details on error conditions, rate limits, authentication needs, or side effects. For a tool with zero annotation coverage, this is insufficient to fully inform the agent.

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 concise and well-structured, with a clear purpose statement followed by parameter and return sections. It uses minimal words without redundancy, making it easy to parse. However, it could be more front-loaded by integrating the return info into the main sentence for better flow.

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's low complexity (one parameter, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the basic purpose and output format but lacks usage guidelines, detailed behavioral context, and full parameter semantics. It is adequate as a minimum viable description but not fully comprehensive for optimal agent use.

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?

The description adds minimal parameter semantics: it mentions 'movie_key' as 'The key of the movie,' which provides basic meaning. However, with 0% schema description coverage and only one parameter, the baseline is 4 for zero parameters, but here it compensates slightly. It does not explain what a 'movie_key' is (e.g., an ID, title, or other identifier), so it adds limited value beyond the schema.

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: 'Get genres for a specific movie.' It specifies the verb ('Get') and resource ('genres for a specific movie'), making the intent unambiguous. However, it does not explicitly differentiate from sibling tools like 'get_movie_details' or 'search_movies', which might also involve movie data retrieval, so it falls short of a perfect score.

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 does not mention sibling tools like 'get_movie_details' (which might include genres) or 'search_movies', nor does it specify prerequisites or exclusions. This lack of contextual usage information limits its effectiveness for an AI agent.

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