Skip to main content
Glama
uzaysozen

imdb-mcp-server

get_imdb_details

Retrieve comprehensive movie and TV series information from IMDb by providing an IMDb ID to access detailed data.

Instructions

Get more in depth details about a movie/series from IMDb. Args: imdbId: The IMDb ID of the movie/series to get details for. Returns: JSON object containing the movie/series details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imdb_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'get_imdb_details' tool. It fetches detailed information for a given IMDb ID from the API and returns it as formatted JSON. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def get_imdb_details(imdb_id: str, ctx: Context) -> str:
        """Get more in depth details about a movie/series from IMDb.
        Args:
            imdbId: The IMDb ID of the movie/series to get details for.
        Returns:
            JSON object containing the movie/series details.
        """
        imdb_details_url = f"{BASE_URL}/{imdb_id}"
        imdb_details_data = await make_imdb_request(imdb_details_url, {}, ctx)
        if not imdb_details_data:
            return "Unable to fetch imdb details data for this movie or movie not found."
        return json.dumps(imdb_details_data, indent=4)
  • Supporting utility function 'make_imdb_request' called by the handler to perform the actual API request to IMDb, including caching, authentication with RapidAPI key, and error handling.
    async def make_imdb_request(url: str, querystring: dict[str, Any], ctx: Optional[Context] = None) -> Optional[Dict[str, Any]]:
        """Make a request to the IMDb API with proper error handling and caching."""
        
        # Check if it's time to clean the cache
        cache_manager.cleanup_if_needed()
        
        # Create a cache key from the URL and querystring
        cache_key = f"{url}_{str(querystring)}"
        
        # Try to get from cache first
        cached_data = cache_manager.cache.get(cache_key)
        if cached_data:
            return cached_data
        
        # Get API key from session config or fallback to environment variable
        api_key = None
        if ctx and hasattr(ctx, 'session_config') and ctx.session_config:
            api_key = ctx.session_config.rapidApiKeyImdb
        
        if not api_key:
            api_key = os.getenv("RAPID_API_KEY_IMDB")
        
        # Not in cache, make the request
        headers = {
            "x-rapidapi-key": api_key,
            "x-rapidapi-host": "imdb236.p.rapidapi.com",
        }
        
        if not api_key:
            raise ValueError("API key not found. Please set the RAPID_API_KEY_IMDB environment variable or provide rapidApiKeyImdb in the request.")
        
        try:
            response = requests.get(url, headers=headers, params=querystring, timeout=30.0)
            response.raise_for_status()
            data = response.json()
            
            # Cache the response
            cache_manager.cache.set(cache_key, data)
                
            return data
        except Exception as e:
            raise ValueError(f"Unable to fetch data from IMDb. Please try again later. Error: {e}")
  • BASE_URL constant used in constructing the API endpoint URL for the tool.
    BASE_URL = "https://imdb236.p.rapidapi.com/api/imdb"
  • Call to register_tools(server) which defines and registers the get_imdb_details tool among others.
    # Register all tools with the server
    register_tools(server)
  • Alternative call to register_tools(server) in stdio mode.
    register_tools(server)
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. It mentions it returns a JSON object, which is basic, but lacks details on behavioral traits such as rate limits, authentication needs, error handling, or what 'in depth details' specifically includes (e.g., runtime, ratings, plot). This is a significant gap for a tool with no annotation coverage.

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 with three sentences: purpose, args, and returns. It's front-loaded with the main action, and each sentence adds value without waste. However, the formatting with 'Args:' and 'Returns:' could be slightly more integrated 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 has an output schema (which covers return values), no annotations, and low complexity with 1 parameter, the description is minimally adequate. It states the purpose and parameter semantics but lacks behavioral context and usage guidelines, leaving gaps in completeness for effective agent use.

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

Parameters4/5

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

The description adds meaning by specifying that 'imdbId' is for a movie/series to get details for, which clarifies the parameter's purpose beyond the schema's generic 'Imdb Id' title. With 0% schema description coverage and only 1 parameter, this compensates adequately, though it doesn't detail format constraints (e.g., 'tt' prefix).

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 verb 'Get' and resource 'more in depth details about a movie/series from IMDb', which is specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'search_imdb' or 'get_most_popular_movies', which might also provide details but through different mechanisms.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an IMDb ID), exclusions, or compare to siblings like 'search_imdb' for when you don't have an ID. The description only states what it does, not when to use it.

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/uzaysozen/imdb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server