Skip to main content
Glama
AmeliaMiddleton

moviefinder-mcp

search_movies

Find movies by title through TMDB. Filter search results by release year if needed.

Instructions

Search TMDB for movies by title. Optionally filter by release year.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
yearNo

Implementation Reference

  • The async handler function for the search_movies tool. It receives { query, year }, calls tmdbFetch to TMDB's /search/movie endpoint, summarizes the results via summarizeList, and returns them as JSON.
    async ({ query, year }) => {
      try {
        const data = await tmdbFetch<{ results: any[] }>("/search/movie", {
          query,
          year,
          include_adult: "false",
        });
        return jsonResult({ results: summarizeList(data.results) });
      } catch (err) {
        return errorResult(err);
      }
    }
  • Zod schema for search_movies input: 'query' (required string, min length 1) and 'year' (optional integer 1800-2100).
    {
      query: z.string().min(1, "query is required"),
      year: z.number().int().min(1800).max(2100).optional(),
    },
  • src/index.ts:37-56 (registration)
    Registration of the 'search_movies' tool via server.tool(), including its description string, input schema, and handler callback.
    server.tool(
      "search_movies",
      "Search TMDB for movies by title. Optionally filter by release year.",
      {
        query: z.string().min(1, "query is required"),
        year: z.number().int().min(1800).max(2100).optional(),
      },
      async ({ query, year }) => {
        try {
          const data = await tmdbFetch<{ results: any[] }>("/search/movie", {
            query,
            year,
            include_adult: "false",
          });
          return jsonResult({ results: summarizeList(data.results) });
        } catch (err) {
          return errorResult(err);
        }
      }
    );
  • summarizeList helper function that takes raw movie results, limits to 20 items, and maps each through summarizeMovie to produce clean output.
    export function summarizeList(items: RawMovie[] | undefined, limit = 20) {
      return (items ?? []).slice(0, limit).map(summarizeMovie);
    }
  • tmdbFetch helper function that makes authenticated HTTP requests to the TMDB API, with error handling for 401, 404, 429, and other HTTP errors.
    export async function tmdbFetch<T = unknown>(
      path: string,
      query: Record<string, string | number | undefined> = {}
    ): Promise<T> {
      const url = new URL(BASE_URL + path);
      for (const [k, v] of Object.entries(query)) {
        if (v !== undefined && v !== null && v !== "") {
          url.searchParams.set(k, String(v));
        }
      }
    
      const res = await fetch(url, {
        headers: {
          Authorization: `Bearer ${getToken()}`,
          Accept: "application/json",
        },
      });
    
      if (!res.ok) {
        const text = await res.text().catch(() => "");
        if (res.status === 401) {
          throw new TmdbError(
            "TMDB rejected the request (401). Check that TMDB_API_KEY is your v4 read access token, not a v3 API key.",
            401
          );
        }
        if (res.status === 404) {
          throw new TmdbError(
            `TMDB resource not found (404) for ${path}. Verify the ID exists.`,
            404
          );
        }
        if (res.status === 429) {
          const retry = res.headers.get("retry-after");
          throw new TmdbError(
            `TMDB rate limit exceeded (429).${retry ? ` Retry after ${retry}s.` : " Slow down requests and retry."}`,
            429
          );
        }
        throw new TmdbError(
          `TMDB request failed (${res.status}) for ${path}: ${text || res.statusText}`,
          res.status
        );
      }
    
      return (await res.json()) as T;
    }
Behavior2/5

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

With no annotations, the description only says 'search' without disclosing behavior like rate limits, pagination, or error handling. Minimal transparency.

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?

Single sentence, no fluff. Every word adds value.

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

Completeness3/5

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

Adequate for a simple search tool, but could mention result format or common constraints. Since no output schema, description could be more complete.

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

Parameters4/5

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

Description explains that query is for title search and year is an optional filter, adding meaning beyond schema constraints. Schema had 0% description coverage.

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 tool searches TMDB movies by title, with optional year filter. It distinguishes from siblings like discover_movies and get_movie_details.

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 guidance on when to use this over sibling tools like discover_movies or search_tv. No exclusions or alternatives mentioned.

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