"""IMDB MCP Server using FastMCP."""
from fastmcp import FastMCP
from imdb_backend import IMDBBackend
mcp = FastMCP("IMDB Server")
backend = IMDBBackend()
@mcp.tool
def search_movies(query: str, limit: int = 10) -> list[dict]:
"""Search for movies by title.
Args:
query: Movie title to search for
limit: Maximum number of results to return (default: 10)
Returns:
List of movies with id, title, and year
"""
return backend.search_movies(query, limit)
@mcp.tool
def get_movie_details(movie_id: str) -> dict:
"""Get full details for a movie by its IMDB ID.
Args:
movie_id: IMDB movie ID (e.g., "0133093" for The Matrix)
Returns:
Movie details including title, year, rating, plot, genres, directors, etc.
"""
return backend.get_movie_details(movie_id)
@mcp.tool
def search_people(query: str, limit: int = 10) -> list[dict]:
"""Search for actors, directors, or other film industry people by name.
Args:
query: Person name to search for
limit: Maximum number of results to return (default: 10)
Returns:
List of people with id and name
"""
return backend.search_people(query, limit)
@mcp.tool
def get_person_details(person_id: str) -> dict:
"""Get full details for a person including their filmography.
Args:
person_id: IMDB person ID (e.g., "0000206" for Keanu Reeves)
Returns:
Person details including name, birth date, bio, and filmography
"""
return backend.get_person_details(person_id)
@mcp.tool
def get_top_250_movies(limit: int = 25) -> list[dict]:
"""Get the IMDB Top 250 movies list.
Args:
limit: Maximum number of movies to return (default: 25)
Returns:
List of top-rated movies with rank, id, title, year, and rating
"""
return backend.get_top_250_movies(limit)
@mcp.tool
def get_movie_cast(movie_id: str, limit: int = 20) -> list[dict]:
"""Get the cast of a movie.
Args:
movie_id: IMDB movie ID
limit: Maximum number of cast members to return (default: 20)
Returns:
List of cast members with id, name, and role
"""
return backend.get_movie_cast(movie_id, limit)
if __name__ == "__main__":
mcp.run()