Skip to main content
Glama
AmeliaMiddleton

moviefinder-mcp

discover_movies

Find movies by genre, minimum rating, year, and sort order. Genre names are resolved automatically.

Instructions

Discover movies by genre name, minimum rating, year, and sort order. Genre is resolved by name (e.g. 'Action').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
genreNo
min_ratingNo
yearNo
sort_byNo

Implementation Reference

  • The async handler function for the discover_movies tool. It resolves genre name to ID, fetches /discover/movie from TMDB with optional filters (genre, min_rating, year, sort_by), and returns a summarized list of results.
    async ({ genre, min_rating, year, sort_by }) => {
      try {
        let with_genres: number | undefined;
        if (genre) {
          const id = await resolveGenreId(genre);
          if (id === null) {
            return errorResult(
              new TmdbError(
                `Unknown genre '${genre}'. Try one of: Action, Adventure, Animation, Comedy, Crime, Documentary, Drama, Family, Fantasy, History, Horror, Music, Mystery, Romance, Science Fiction, TV Movie, Thriller, War, Western.`
              )
            );
          }
          with_genres = id;
        }
        const data = await tmdbFetch<{ results: any[] }>("/discover/movie", {
          with_genres,
          "vote_average.gte": min_rating,
          primary_release_year: year,
          sort_by: sort_by ?? "popularity.desc",
          include_adult: "false",
        });
        return jsonResult({ results: summarizeList(data.results) });
      } catch (err) {
        return errorResult(err);
      }
    }
  • Input schema for discover_movies: optional genre (string), min_rating (0-10 number), year (1800-2100 integer), and sort_by (enum of TMDB sort values like popularity.desc).
    {
      genre: z.string().optional(),
      min_rating: z.number().min(0).max(10).optional(),
      year: z.number().int().min(1800).max(2100).optional(),
      sort_by: z
        .enum([
          "popularity.desc",
          "popularity.asc",
          "vote_average.desc",
          "vote_average.asc",
          "primary_release_date.desc",
          "primary_release_date.asc",
          "revenue.desc",
          "revenue.asc",
        ])
        .optional(),
    },
  • src/index.ts:163-209 (registration)
    Registration of the discover_movies tool on the MCP server via server.tool(), including name, description, schema, and handler.
    server.tool(
      "discover_movies",
      "Discover movies by genre name, minimum rating, year, and sort order. Genre is resolved by name (e.g. 'Action').",
      {
        genre: z.string().optional(),
        min_rating: z.number().min(0).max(10).optional(),
        year: z.number().int().min(1800).max(2100).optional(),
        sort_by: z
          .enum([
            "popularity.desc",
            "popularity.asc",
            "vote_average.desc",
            "vote_average.asc",
            "primary_release_date.desc",
            "primary_release_date.asc",
            "revenue.desc",
            "revenue.asc",
          ])
          .optional(),
      },
      async ({ genre, min_rating, year, sort_by }) => {
        try {
          let with_genres: number | undefined;
          if (genre) {
            const id = await resolveGenreId(genre);
            if (id === null) {
              return errorResult(
                new TmdbError(
                  `Unknown genre '${genre}'. Try one of: Action, Adventure, Animation, Comedy, Crime, Documentary, Drama, Family, Fantasy, History, Horror, Music, Mystery, Romance, Science Fiction, TV Movie, Thriller, War, Western.`
                )
              );
            }
            with_genres = id;
          }
          const data = await tmdbFetch<{ results: any[] }>("/discover/movie", {
            with_genres,
            "vote_average.gte": min_rating,
            primary_release_year: year,
            sort_by: sort_by ?? "popularity.desc",
            include_adult: "false",
          });
          return jsonResult({ results: summarizeList(data.results) });
        } catch (err) {
          return errorResult(err);
        }
      }
    );
  • Helper function resolveGenreId() used by the handler to convert a genre name string to a TMDB genre ID, with caching.
    export async function resolveGenreId(name: string): Promise<number | null> {
      if (!genreCache) {
        const data = await tmdbFetch<{ genres: { id: number; name: string }[] }>(
          "/genre/movie/list"
        );
        genreCache = new Map(data.genres.map((g) => [g.name.toLowerCase(), g.id]));
      }
      return genreCache.get(name.toLowerCase()) ?? null;
    }
  • Helper function summarizeList() used by the handler to format and limit the list of results returned from TMDB.
    export function summarizeList(items: RawMovie[] | undefined, limit = 20) {
      return (items ?? []).slice(0, limit).map(summarizeMovie);
    }
Behavior2/5

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

No annotations are provided, so the description must convey behavior. It only states that genre is resolved by name, but lacks details on return type, pagination, error handling, or what happens if no movies match.

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?

Two sentences, front-loaded with verb and parameters, no extra words. Highly efficient for the information it provides.

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

Completeness2/5

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

Given no output schema and 4 parameters, the description is too sparse. It omits any mention of output format, pagination, or common behavior for filter tools, leaving the agent underinformed.

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

Parameters3/5

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

Schema coverage is 0%, but description names all four parameters and clarifies that genre is a resolved name. However, it does not explain valid values for min_rating (0-10), year range, or sort_by options, which are already in schema but not repeated.

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?

Description clearly states the tool discovers movies by genre, rating, year, and sort order. However, it does not differentiate from sibling tools like search_movies or get_trending, which could be confused.

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?

No explicit guidance on when to use this tool versus alternatives. The description implies filtering but lacks context like 'for exploring movies by criteria' and does not mention when not to use.

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/AmeliaMiddleton/Php1mcp'

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