Skip to main content
Glama
tonderflash

Movie Search MCP Server

by tonderflash

get_movie_details

Fetch detailed information about a movie using its IMDB or TMDb ID, sourced from OMDb or TMDb APIs, to access key data for analysis or integration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesMovie ID (IMDB ID or TMDb ID)
sourceNoData source (omdb or tmdb)omdb

Implementation Reference

  • MCP tool handler for 'get_movie_details': fetches movie details via API wrapper, handles errors, and formats a rich text response with movie info.
    async ({ id, source }) => {
      try {
        const details = await getMovieDetails(id, source);
    
        if (!details) {
          return {
            content: [
              {
                type: "text",
                text: `āŒ No details found for movie with ID "${id}" in ${source.toUpperCase()}.`,
              },
            ],
          };
        }
    
        let response = `šŸŽ¬ **${details.title}** (${details.year})\n\n`;
        response += `šŸ“ **Plot:** ${details.plot}\n\n`;
        response += `šŸŽ­ **Genre:** ${details.genre}\n`;
        response += `⭐ **Rating:** ${details.rating}\n`;
        response += `ā±ļø **Runtime:** ${details.runtime || "N/A"}\n`;
    
        if (details.director) {
          response += `šŸŽ¬ **Director:** ${details.director}\n`;
        }
    
        if (details.actors) {
          response += `šŸ‘„ **Main Cast:** ${details.actors}\n`;
        }
    
        if (details.language) {
          response += `šŸŒ **Language:** ${details.language}\n`;
        }
    
        if (details.country) {
          response += `šŸ“ **Country:** ${details.country}\n`;
        }
    
        if (details.awards && details.awards !== "N/A") {
          response += `šŸ† **Awards:** ${details.awards}\n`;
        }
    
        if (details.boxOffice && details.boxOffice !== "N/A") {
          response += `šŸ’° **Box Office:** ${details.boxOffice}\n`;
        }
    
        if (details.imdbId) {
          response += `šŸ”— **IMDB ID:** ${details.imdbId}\n`;
        }
    
        response += `\nšŸ“Š **Source:** ${details.source.toUpperCase()}`;
    
        if (details.poster !== "N/A") {
          response += `\n\nšŸ–¼ļø **Poster:** ${details.poster}`;
        }
    
        return {
          content: [
            {
              type: "text",
              text: response,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `āŒ Error getting details: ${
                error instanceof Error ? error.message : "Unknown error"
              }`,
            },
          ],
        };
      }
    }
  • Zod schema for input validation of 'get_movie_details' tool parameters: id (string) and source (enum omdb|tmdb, default omdb).
    {
      id: z.string().describe("Movie ID (IMDB ID or TMDb ID)"),
      source: z
        .enum(["omdb", "tmdb"])
        .default("omdb")
        .describe("Data source (omdb or tmdb)"),
    },
  • src/index.ts:87-172 (registration)
    Registration of the 'get_movie_details' MCP tool on the server using server.tool(name, inputSchema, handlerFn).
    server.tool(
      "get_movie_details",
      {
        id: z.string().describe("Movie ID (IMDB ID or TMDb ID)"),
        source: z
          .enum(["omdb", "tmdb"])
          .default("omdb")
          .describe("Data source (omdb or tmdb)"),
      },
      async ({ id, source }) => {
        try {
          const details = await getMovieDetails(id, source);
    
          if (!details) {
            return {
              content: [
                {
                  type: "text",
                  text: `āŒ No details found for movie with ID "${id}" in ${source.toUpperCase()}.`,
                },
              ],
            };
          }
    
          let response = `šŸŽ¬ **${details.title}** (${details.year})\n\n`;
          response += `šŸ“ **Plot:** ${details.plot}\n\n`;
          response += `šŸŽ­ **Genre:** ${details.genre}\n`;
          response += `⭐ **Rating:** ${details.rating}\n`;
          response += `ā±ļø **Runtime:** ${details.runtime || "N/A"}\n`;
    
          if (details.director) {
            response += `šŸŽ¬ **Director:** ${details.director}\n`;
          }
    
          if (details.actors) {
            response += `šŸ‘„ **Main Cast:** ${details.actors}\n`;
          }
    
          if (details.language) {
            response += `šŸŒ **Language:** ${details.language}\n`;
          }
    
          if (details.country) {
            response += `šŸ“ **Country:** ${details.country}\n`;
          }
    
          if (details.awards && details.awards !== "N/A") {
            response += `šŸ† **Awards:** ${details.awards}\n`;
          }
    
          if (details.boxOffice && details.boxOffice !== "N/A") {
            response += `šŸ’° **Box Office:** ${details.boxOffice}\n`;
          }
    
          if (details.imdbId) {
            response += `šŸ”— **IMDB ID:** ${details.imdbId}\n`;
          }
    
          response += `\nšŸ“Š **Source:** ${details.source.toUpperCase()}`;
    
          if (details.poster !== "N/A") {
            response += `\n\nšŸ–¼ļø **Poster:** ${details.poster}`;
          }
    
          return {
            content: [
              {
                type: "text",
                text: response,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `āŒ Error getting details: ${
                  error instanceof Error ? error.message : "Unknown error"
                }`,
              },
            ],
          };
        }
      }
    );
  • Helper function getMovieDetails: dispatches to specific OMDb or TMDb detail fetchers based on source.
    export async function getMovieDetails(
      id: string,
      source: "omdb" | "tmdb" = "omdb"
    ): Promise<MovieInfo | null> {
      if (source === "omdb") {
        return await getMovieDetailsOMDb(id);
      } else {
        return await getMovieDetailsTMDb(id);
      }
    }
  • OMDb-specific implementation: fetches and maps movie details from OMDb API using IMDB ID.
    export async function getMovieDetailsOMDb(
      imdbId: string
    ): Promise<MovieInfo | null> {
      try {
        const params = new URLSearchParams({
          apikey: OMDB_API_KEY,
          i: imdbId,
          plot: "full",
        });
    
        const response = await fetch(`${OMDB_BASE_URL}?${params}`);
        const data = (await response.json()) as OMDbMovie;
    
        if (data.Response === "False") {
          return null;
        }
    
        return {
          title: data.Title,
          year: data.Year,
          director: data.Director,
          actors: data.Actors,
          plot: data.Plot,
          genre: data.Genre,
          rating: data.imdbRating,
          poster: data.Poster,
          imdbId: data.imdbID,
          runtime: data.Runtime,
          language: data.Language,
          country: data.Country,
          awards: data.Awards,
          boxOffice: data.BoxOffice,
          source: "omdb",
        };
      } catch (error) {
        console.error("Error getting movie details from OMDb:", error);
        return null;
      }
    }
  • TMDb-specific implementation: fetches movie details from TMDb API using TMDb ID, appends credits for cast/director.
    export async function getMovieDetailsTMDb(
      tmdbId: string
    ): Promise<MovieInfo | null> {
      if (!TMDB_API_KEY) {
        return null;
      }
    
      try {
        const params = new URLSearchParams({
          api_key: TMDB_API_KEY,
          language: "en-US",
          append_to_response: "credits",
        });
    
        const response = await fetch(`${TMDB_BASE_URL}/movie/${tmdbId}?${params}`);
        const data = (await response.json()) as TMDbMovieDetails & {
          credits?: any;
        };
    
        const director =
          data.credits?.crew?.find((person: any) => person.job === "Director")
            ?.name || "N/A";
        const actors =
          data.credits?.cast
            ?.slice(0, 5)
            .map((actor: any) => actor.name)
            .join(", ") || "N/A";
    
        return {
          title: data.title,
          year: data.release_date ? data.release_date.split("-")[0] : "",
          director: director,
          actors: actors,
          plot: data.overview,
          genre: data.genres.map((g) => g.name).join(", "),
          rating: data.vote_average.toString(),
          poster: data.poster_path
            ? `https://image.tmdb.org/t/p/w500${data.poster_path}`
            : "N/A",
          imdbId: data.imdb_id,
          runtime: data.runtime ? `${data.runtime} min` : "N/A",
          language: data.original_language,
          country: data.production_countries.map((c) => c.name).join(", "),
          awards: "N/A", // TMDb no proporciona premios directamente
          boxOffice: data.revenue ? `$${data.revenue.toLocaleString()}` : "N/A",
          source: "tmdb",
        };
      } catch (error) {
        console.error("Error getting movie details from TMDb:", error);
        return null;
      }
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

Related 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/tonderflash/movie-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server