Skip to main content
Glama
uzaysozen

imdb-mcp-server

get_cast

Retrieve the cast of a movie using its IMDb ID. This tool provides a JSON object with all cast members for the specified film.

Instructions

Get the cast of a movie from IMDb. Args: imdbId: The IMDb ID of the movie to get cast for. Returns: JSON object containing the cast of the movie.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imdb_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler implementation for the 'get_cast' MCP tool. It fetches the cast list from the IMDb API using the provided imdb_id and returns JSON-formatted data. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def get_cast(imdb_id: str, ctx: Context) -> str:
        """Get the cast of a movie from IMDb.
        Args:
            imdbId: The IMDb ID of the movie to get cast for.
        Returns:
            JSON object containing the cast of the movie.
        """
        cast_url = f"{BASE_URL}/{imdb_id}/cast"
        cast_data = await make_imdb_request(cast_url, {}, ctx)
        if not cast_data:
            return "Unable to fetch cast data for this movie or movie not found."
        return json.dumps(cast_data, indent=4)
  • The call to register_tools(server) in the MCP server initialization, which registers all tools including 'get_cast'.
    # Register all tools with the server
    register_tools(server)
  • Key helper function called by get_cast to perform the actual HTTP request to the IMDb RapidAPI, handling authentication, caching, and error management.
    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}")
  • The base URL constant used to construct the cast API endpoint in get_cast: f'{BASE_URL}/{imdb_id}/cast'.
    BASE_URL = "https://imdb236.p.rapidapi.com/api/imdb"
  • Alternative registration call in stdio transport 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 of behavioral disclosure. It states the tool fetches data from IMDb, implying it's a read-only operation, but doesn't mention potential rate limits, authentication needs, error handling, or what the JSON structure looks like. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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: the first sentence states the purpose clearly, followed by structured Args and Returns sections. There's no wasted text, and it efficiently communicates the core functionality. However, the use of 'imdbId' in the description doesn't exactly match the schema's 'imdb_id', which is a minor inconsistency, preventing a perfect score.

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 should document the return structure), the description doesn't need to explain return values in detail. However, with no annotations and minimal behavioral context, it's somewhat incomplete for a data-fetching tool—it lacks information on error cases, data freshness, or IMDb-specific constraints. The presence of an output schema raises the baseline, but gaps remain.

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 explains that 'imdbId' is 'The IMDb ID of the movie to get cast for,' which clarifies the purpose of the single parameter. However, with 0% schema description coverage and only one parameter, this is adequate but not exceptional. It doesn't provide format details (e.g., IMDb ID pattern like 'tt1234567') or examples, so it meets the baseline for low parameter count.

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 the cast of a movie from IMDb.' It specifies the verb ('Get') and resource ('cast of a movie'), and distinguishes it from siblings like get_directors or get_writers by focusing on cast members. However, it doesn't explicitly differentiate from get_imdb_details, which might also return cast information, so it's not a perfect 5.

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 siblings like get_imdb_details (which might provide broader movie details including cast) or search_imdb (for finding movies). There are no explicit when/when-not instructions or prerequisites, leaving the agent to infer usage from the tool name alone.

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