Skip to main content
Glama
uzaysozen

imdb-mcp-server

search_imdb

Search for movies on IMDb using filters like title, genre, rating, year, and language to find specific films from the database.

Instructions

Search for movies on IMDb. First 5 results are returned. Args: original_title: The original title of the movie to search for. Searches the whole word. original_title_autocomplete: The autocomplete title of the movie to search for. Searches the partial word. primary_title: The primary title of the movie to search for. Searches the whole word. primary_title_autocomplete: The autocomplete primary title of the movie to search for. Searches the partial word. type: The type of the movie to search for. Get all possible types with get_types(). genre: The genre of the movie to search for. Get all possible genres with get_genres(). genres: The genres of the movie to search for. List of Genres. Get all possible genres with get_genres(). is_adult: Whether to include adult movies in the search results. average_rating_from: The minimum average rating of the movie to search for. average_rating_to: The maximum average rating of the movie to search for. num_votes_from: The minimum number of votes of the movie to search for. num_votes_to: The maximum number of votes of the movie to search for. start_year_from: The minimum start year of the movie to search for. start_year_to: The maximum start year of the movie to search for. countries_of_origin: The countries of origin of the movie to search for. In ISO 3166-1 alpha-2 format list of strings. Get all possible countries with get_countries(). spoken_languages: The spoken languages of the movie to search for. In ISO 639-1 format list of strings. Get all possible languages with get_languages(). sort_order: The order of the search results. Possible values: "ASC", "DESC". sort_field: The field to sort the search results by. Possible values: "id", "averageRating", "numVotes", "startYear". Returns: JSON object containing the first 5 search results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
original_titleNo
original_title_autocompleteNo
primary_titleNo
primary_title_autocompleteNo
typeNo
genreNo
genresNo
is_adultNo
average_rating_fromNo
average_rating_toNo
num_votes_fromNo
num_votes_toNo
start_year_fromNo
start_year_toNo
countries_of_originNo
spoken_languagesNo
sort_orderNo
sort_fieldNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the search_imdb tool logic. It constructs a search query for the IMDb API, calls the make_imdb_request helper, limits results to the first 5, and returns JSON.
    @mcp.tool()     
    async def search_imdb(
        ctx: Context,
        original_title: Optional[str] = None,
        original_title_autocomplete: Optional[str] = None,
        primary_title: Optional[str] = None,
        primary_title_autocomplete: Optional[str] = None,
        type: Optional[str] = None,
        genre: Optional[str] = None,
        genres: Optional[List[str]] = None,
        is_adult: Optional[bool] = None,
        average_rating_from: Optional[float] = None,
        average_rating_to: Optional[float] = None,
        num_votes_from: Optional[int] = None,
        num_votes_to: Optional[int] = None,
        start_year_from: Optional[int] = None,
        start_year_to: Optional[int] = None,
        countries_of_origin: Optional[List[str]] = None,
        spoken_languages: Optional[List[str]] = None,
        sort_order: Optional[Literal["ASC", "DESC"]] = None,
        sort_field: Optional[Literal["id", "averageRating", "numVotes", "startYear"]] = None,
        ) -> str:
        """Search for movies on IMDb. First 5 results are returned.
        Args:
            original_title: The original title of the movie to search for. Searches the whole word.
            original_title_autocomplete: The autocomplete title of the movie to search for. Searches the partial word.
            primary_title: The primary title of the movie to search for. Searches the whole word.
            primary_title_autocomplete: The autocomplete primary title of the movie to search for. Searches the partial word.
            type: The type of the movie to search for. Get all possible types with get_types().
            genre: The genre of the movie to search for. Get all possible genres with get_genres().
            genres: The genres of the movie to search for. List of Genres. Get all possible genres with get_genres().
            is_adult: Whether to include adult movies in the search results.
            average_rating_from: The minimum average rating of the movie to search for.
            average_rating_to: The maximum average rating of the movie to search for.
            num_votes_from: The minimum number of votes of the movie to search for.
            num_votes_to: The maximum number of votes of the movie to search for.
            start_year_from: The minimum start year of the movie to search for.
            start_year_to: The maximum start year of the movie to search for.
            countries_of_origin: The countries of origin of the movie to search for. In ISO 3166-1 alpha-2 format list of strings. Get all possible countries with get_countries().
            spoken_languages: The spoken languages of the movie to search for. In ISO 639-1 format list of strings. Get all possible languages with get_languages().
            sort_order: The order of the search results. Possible values: "ASC", "DESC".
            sort_field: The field to sort the search results by. Possible values: "id", "averageRating", "numVotes", "startYear".
        Returns:
            JSON object containing the first 5 search results.
        """
        search_url = f"{BASE_URL}/search"
        search_data = await make_imdb_request(search_url, {"originalTitle": original_title,
                                                           "originalTitleAutocomplete": original_title_autocomplete,
                                                           "primaryTitle": primary_title,
                                                           "primaryTitleAutocomplete": primary_title_autocomplete,
                                                           "type": type,
                                                           "genre": genre,
                                                           "genres": genres,
                                                           "isAdult": is_adult,
                                                           "averageRatingFrom": average_rating_from, 
                                                           "averageRatingTo": average_rating_to,
                                                           "numVotesFrom": num_votes_from,
                                                           "numVotesTo": num_votes_to,
                                                           "startYearFrom": start_year_from,
                                                           "startYearTo": start_year_to,
                                                           "countriesOfOrigin": countries_of_origin,
                                                           "spokenLanguages": spoken_languages,
                                                           "sortOrder": sort_order,
                                                           "sortField": sort_field}, ctx)
        if not search_data or not search_data.get("results", []):
            return "Unable to fetch search data for this movie or movie not found."
        
        search_results = search_data.get("results", [])[:5]
        return json.dumps(search_results, indent=4)
  • Key helper function used by search_imdb to perform the HTTP GET request to the IMDb API endpoint, handling caching, API key retrieval from context or environment, 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}")
  • Location where register_tools is called on the MCP server instance, which in turn defines and registers the search_imdb tool via its @mcp.tool() decorator.
    server = FastMCP("IMDb MCP Server")
    
    # Register all tools with the server
    register_tools(server)
  • Session configuration schema providing the required rapidApiKeyImdb for the tool to function.
    class ConfigSchema(BaseModel):
        rapidApiKeyImdb: str = Field(..., description="RapidAPI API key for accessing the IMDb API")
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that 'First 5 results are returned' and returns a 'JSON object', which adds some context on output format and result limits. However, it fails to disclose critical behaviors like whether this is a read-only operation (implied but not stated), potential rate limits, authentication needs, or error handling, leaving significant gaps for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is structured with clear sections (Args, Returns) but is overly verbose, listing all parameters in detail within the description itself rather than relying on the schema. While informative, this duplicates information that could be in the schema descriptions, making it less concise. The front-loaded purpose statement is good, but the bulkiness reduces efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (18 parameters, no annotations, schema coverage 0%, but has output schema), the description is mostly complete. It explains all parameters thoroughly and notes the output is a JSON object with the first 5 results, which aligns with the output schema. However, it lacks context on behavioral aspects like rate limits or error cases, slightly reducing completeness for a search tool.

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

Parameters5/5

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

The schema description coverage is 0%, so the description must fully compensate. It provides detailed explanations for all 18 parameters, including search logic (e.g., 'Searches the whole word' vs. 'Searches the partial word'), format requirements (e.g., ISO codes), value sources (e.g., 'Get all possible types with get_types()'), and sorting options. This adds substantial meaning beyond the basic schema, effectively documenting parameter usage.

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 searches for movies on IMDb and returns the first 5 results, providing a specific verb ('Search') and resource ('movies on IMDb'). However, it doesn't explicitly distinguish itself from sibling tools like 'get_most_popular_movies' or 'get_top_250_movies', which also retrieve movie information 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 Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through its parameter explanations (e.g., 'Get all possible types with get_types()'), suggesting when to use certain parameters. However, it lacks explicit guidance on when to choose this tool over sibling alternatives like 'get_imdb_details' for detailed info or other get_* tools for specific movie lists, leaving usage context partially inferred.

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