Skip to main content
Glama
ShubhanshuSondhiya

TMDB MCP Server

get-trending

Retrieve trending movies from The Movie Database (TMDB) API for day or week time windows to identify popular content.

Instructions

Get trending movies

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeWindowNoTime window for trending movies

Implementation Reference

  • MCP tool handler for 'get-trending'. Validates input, calls getTrendingMovies from TMDB API wrapper, and handles errors.
    "get-trending": async ({
      timeWindow = "week",
    }: {
      timeWindow?: "day" | "week";
    }) => {
      try {
        // Return the raw results directly
        return await getTrendingMovies(timeWindow);
      } catch (error: unknown) {
        if (error instanceof Error) {
          throw new Error(`Failed to get trending movies: ${error.message}`);
        }
        throw new Error("Failed to get trending movies: Unknown error");
      }
    },
  • Schema definition and metadata for the 'get-trending' tool, used in tool listing.
    "get-trending": {
      name: "get-trending",
      description: "Get trending movies",
      inputSchema: {
        type: "object",
        properties: {
          timeWindow: {
            type: "string",
            enum: ["day", "week"],
            description: "Time window for trending movies",
          },
        },
        required: [],
      },
    },
  • src/handlers.ts:57-59 (registration)
    MCP server registration for listing tools, which exposes the 'get-trending' schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: Object.values(tools),
    }));
  • src/handlers.ts:62-98 (registration)
    MCP server request handler for calling tools, which dispatches to 'get-trending' handler based on name.
    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"
        };
      }
    });
  • Helper function implementing the core API logic for fetching trending movies from TMDB.
    export async function getTrendingMovies(timeWindow: 'day' | 'week' = 'week'): Promise<SearchMoviesResponse> {
      try {
        const response = await axiosWithRetry<SearchMoviesResponse>({
          url: `/trending/movie/${timeWindow}`
        });
        return response.data;
      } catch (error) {
        const err = error as Error;
        console.error('Error getting trending movies:', err.message);
        throw new Error(`Failed to get trending movies: ${err.message}`);
      }
    }
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 only states the action ('Get trending movies') without revealing any behavioral traits such as rate limits, authentication needs, data freshness, or response format (e.g., list of movies with scores). This leaves critical operational aspects unspecified, making it inadequate for a tool with no annotation support.

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 extremely concise ('Get trending movies'), consisting of a single, front-loaded sentence that directly conveys the core functionality without any wasted words. It is appropriately sized for a simple tool with one optional parameter, making it easy to parse and understand quickly.

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 lack of annotations and output schema, the description is incomplete for a tool that likely returns a list of trending movies. It does not address what 'trending' means, how results are ordered, or what data is included in the response. While the schema covers the parameter well, the overall context for using the tool effectively is insufficient, especially for an agent needing to interpret results.

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?

The input schema has 100% description coverage, with the single parameter 'timeWindow' fully documented in the schema (enum: 'day', 'week'). The description adds no additional meaning beyond the schema, such as explaining the impact of timeWindow on results or default behavior. Given the high schema coverage, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

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 'Get trending movies' clearly states the verb ('Get') and resource ('trending movies'), making the purpose immediately understandable. It distinguishes from siblings like 'get-movie-details' (specific movie info), 'get-similar' (related movies), and 'search-movies' (query-based search) by focusing on trending content. However, it lacks specificity about what 'trending' entails (e.g., popularity metrics, ranking criteria), preventing a perfect score.

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. It does not mention use cases (e.g., discovering popular movies, time-sensitive trends) or exclusions (e.g., not for detailed movie info or search queries). Without such context, an agent must infer usage from the tool name alone, which is insufficient for optimal selection.

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