Skip to main content
Glama
uzaysozen

imdb-mcp-server

get_directors

Retrieve director information for any movie using its IMDb ID. This tool provides structured data about film directors from the IMDb database.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imdb_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the core logic of the 'get_directors' tool. It constructs the API URL, calls make_imdb_request to fetch directors data for the specified IMDb ID, handles errors, and returns formatted JSON.
    @mcp.tool()
    async def get_directors(imdb_id: str, ctx: Context) -> str:
        """Get the directors of a movie from IMDb.
        Args:
            imdbId: The IMDb ID of the movie to get directors for.
        Returns:
            JSON object containing the directors of the movie.
        """
        directors_url = f"{BASE_URL}/{imdb_id}/directors"
        directors_data = await make_imdb_request(directors_url, {}, ctx)
        if not directors_data:
            return "Unable to fetch directors data for this movie or movie not found."
        return json.dumps(directors_data, indent=4)
  • Registers all tools, including 'get_directors', by calling register_tools(server) in the FastMCP server setup.
    # Register all tools with the server
    register_tools(server)
  • Supporting helper function 'make_imdb_request' called by the get_directors handler to perform the HTTP request to the IMDb API endpoint, including caching, authentication, 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}")
  • Alternative registration call for 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 retrieves data ('Get') and returns a JSON object, implying a read-only operation, but does not cover critical aspects like error handling (e.g., invalid IMDb IDs), rate limits, authentication needs, or data freshness. For a tool with no annotations, this is a significant gap in transparency.

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 well-structured and concise, with a clear purpose statement followed by bullet points for args and returns. Each sentence earns its place by delivering necessary information without redundancy. However, the use of 'Args:' and 'Returns:' is slightly verbose for such a simple tool, and it could be more front-loaded by integrating parameter details into the main sentence.

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 (1 parameter, no annotations, but has an output schema), the description is minimally adequate. It covers the basic purpose and parameter semantics, and the output schema likely handles return values, reducing the need for detailed output explanation. However, it lacks usage guidelines and behavioral details, making it incomplete for optimal agent operation without additional context.

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 meaningful context for the single parameter: 'imdbId: The IMDb ID of the movie to get directors for.' This clarifies the parameter's purpose and format beyond the schema's basic title ('Imdb Id') and type. With schema description coverage at 0%, the description effectively compensates by providing essential semantic information, though it could specify format details (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 tool's purpose: 'Get the directors of a movie from IMDb.' It specifies the verb ('Get'), resource ('directors'), and source ('IMDb'), making the function unambiguous. However, it does not explicitly differentiate from sibling tools like 'get_writers' or 'get_imdb_details', which might provide overlapping or related information, 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 mentions IMDb as the source but does not specify prerequisites, limitations (e.g., availability of data), or when to choose siblings like 'get_imdb_details' for broader movie information. This lack of contextual advice leaves the agent without clear usage direction.

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