Skip to main content
Glama
uzaysozen

imdb-mcp-server

get_top_box_office_us

Retrieve current US box office rankings for movies from IMDb. Specify a starting index to get paginated results showing top-performing films.

Instructions

Get the top box office data for the US from IMDb with pagination. Args: start: The starting index (0-based) to retrieve movies from. Returns: JSON object containing 5 top box office movies starting from the specified index.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the get_top_box_office_us MCP tool. Decorated with @mcp.tool(), it fetches top box office US movies from IMDb API, paginates the results, and returns formatted JSON.
    @mcp.tool()
    async def get_top_box_office_us(start: int, ctx: Context) -> str:
        """Get the top box office data for the US from IMDb with pagination.
        Args:
            start: The starting index (0-based) to retrieve movies from.
        Returns:
            JSON object containing 5 top box office movies starting from the specified index.
        """
        box_office_us_url = f"{BASE_URL}/top-box-office"
        box_office_us_data = await make_imdb_request(box_office_us_url, {}, ctx)
        if not box_office_us_data:
            return "Unable to fetch box office data for the US."
        return json.dumps(paginated_response(box_office_us_data, start, len(box_office_us_data)), indent=4)
  • Primary registration of all tools (including get_top_box_office_us) via register_tools call in the smithery server creator function.
    server = FastMCP("IMDb MCP Server")
    
    # Register all tools with the server
    register_tools(server)
    
    return server
  • Registration of all tools (including get_top_box_office_us) via register_tools call in stdio transport mode.
    server = FastMCP("IMDb MCP Server")
    register_tools(server)
  • Helper function called by the tool to make HTTP requests to the IMDb API endpoint, with caching and API key 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}")
  • Helper function used by the tool to paginate the API response data into chunks of 5 items.
    def paginated_response(items, start, total_count=None):
        """Format a paginated response with a fixed page size of 5."""
        if total_count is None:
            total_count = len(items)
        
        # Validate starting index
        start = max(0, min(total_count - 1 if total_count > 0 else 0, start))
        
        # Fixed page size of 5
        page_size = 5
        end = min(start + page_size, total_count)
        
        return {
            "items": items[start:end],
            "start": start,
            "count": end - start,
            "totalCount": total_count,
            "hasMore": end < total_count,
            "nextStart": end if end < total_count else None
        }
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 pagination and that it returns 5 movies per call, which is useful behavioral context. However, it doesn't disclose important traits like rate limits, authentication needs, error handling, or whether the data is real-time/cached. For a data-fetching tool with zero annotation coverage, this leaves significant gaps.

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

Conciseness5/5

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

The description is perfectly structured and concise: a clear purpose statement followed by a well-organized Args/Returns section. Every sentence earns its place by providing essential information without redundancy. The front-loaded purpose statement immediately conveys the tool's function.

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 tool has an output schema (so return values are documented elsewhere) and the description fully explains the single parameter, it's reasonably complete. However, with no annotations and a data-fetching operation, the description could better address behavioral aspects like data freshness or limitations. The presence of an output schema reduces the burden, but some contextual gaps remain.

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 has 0% description coverage, but the description fully compensates by explaining the single parameter: 'start: The starting index (0-based) to retrieve movies from.' It adds crucial semantics beyond the schema's type information, clarifying it's a 0-based index for pagination. This is excellent compensation for the schema gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get'), resource ('top box office data for the US from IMDb'), and scope ('with pagination'), distinguishing it from sibling tools like get_most_popular_movies or get_top_250_movies. It explicitly mentions the US focus and pagination feature, which differentiates it from other movie listing tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

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

The description implies usage context through 'with pagination' and the parameter explanation, suggesting it's for retrieving paginated US box office data. However, it doesn't explicitly state when to use this tool versus alternatives like get_most_popular_movies or get_top_250_movies, nor does it mention any exclusions or prerequisites.

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