Skip to main content
Glama
ShubhanshuSondhiya

TMDB MCP Server

search-movies

Find movies by title or keywords using The Movie Database API. Enter a search query to retrieve relevant film results with pagination support.

Instructions

Search for movies by title or keywords

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
pageNoPage number for results

Implementation Reference

  • The handler function for the 'search-movies' tool that invokes the searchMovies helper from tmdb-api.ts.
    "search-movies": async ({
      query,
      page = 1,
    }: {
      query: string;
      page?: number;
    }) => {
      try {
        // Return the raw results directly
        return await searchMovies(query, page);
      } catch (error: unknown) {
        if (error instanceof Error) {
          throw new Error(`Failed to search movies: ${error.message}`);
        }
        throw new Error("Failed to search movies: Unknown error");
      }
    },
  • The input schema and metadata definition for the 'search-movies' tool.
    "search-movies": {
      name: "search-movies",
      description: "Search for movies by title or keywords",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query",
          },
          page: {
            type: "number",
            description: "Page number for results",
          },
        },
        required: ["query"],
      },
    },
  • The core implementation of movie search using TMDB API, called by the tool handler.
    export async function searchMovies(query: string, page: number = 1): Promise<SearchMoviesResponse> {
      try {
        const response = await axiosWithRetry<SearchMoviesResponse>({
          url: '/search/movie',
          params: {
            query: query,
            page: page
          }
        });
        return response.data;
      } catch (error) {
        const err = error as Error;
        console.error('Error searching movies:', err.message);
        throw new Error(`Failed to search movies: ${err.message}`);
      }
    }
  • src/handlers.ts:62-98 (registration)
    Generic registration of tool handlers, dispatching calls to toolHandlers[name] including 'search-movies'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        const { name, arguments: args } = request.params;
        // Using type assertion to tell TypeScript this is a valid key
        const handler = toolHandlers[name as keyof typeof toolHandlers];
    
        if (!handler) throw new Error(`Tool not found: ${name}`);
    
        // Execute the handler but wrap the response in the expected format
        const result = await handler(args as any);
        
        // Return in the format expected by the SDK
        return {
          tools: [{
            name,
            inputSchema: {
              type: "object",
              properties: {} // This would ideally be populated with actual schema
            },
            description: `Tool: ${name}`,
            result
          }]
        };
      } catch (error) {
        // Properly handle errors
        if (error instanceof Error) {
          return {
            tools: [],
            error: error.message
          };
        }
        return {
          tools: [],
          error: "An unknown error occurred"
        };
      }
    });
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 of behavioral disclosure. It states the tool searches for movies but doesn't mention key behaviors like whether it's read-only (likely, but not confirmed), how results are returned (e.g., format, pagination details beyond the 'page' parameter), or any limitations (e.g., rate limits, authentication needs). This leaves significant gaps for a tool with no annotation coverage.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core purpose and avoids redundancy, making it highly concise and well-structured for quick understanding.

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 the tool's moderate complexity (search functionality with pagination), no annotations, and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., read-only status, result format), usage context relative to siblings, and output expectations, leaving the agent with incomplete guidance for proper invocation.

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 description coverage is 100%, with both parameters ('query' and 'page') documented in the schema. The description adds minimal value beyond the schema by implying the 'query' parameter is for title/keyword searches, but it doesn't provide additional context like search syntax, result ordering, or default behaviors. This meets the baseline for high schema coverage.

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?

The description clearly states the tool's purpose with a specific verb ('Search') and resource ('movies'), and specifies the search criteria ('by title or keywords'). However, it doesn't explicitly differentiate from sibling tools like 'get-trending' or 'get-similar', which might also involve movie discovery but through different mechanisms.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get-trending' (for popular movies) or 'get-similar' (for recommendations based on a known movie). It mentions the search criteria but doesn't clarify scenarios where this is preferred over sibling tools, leaving usage context implied rather than explicit.

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/ShubhanshuSondhiya/MCP-TMDB'

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