get_trending
Find trending movies, TV shows, or both for a selected time window (day or week). Retrieves popular titles based on current trends.
Instructions
Get trending movies, TV, or both, for the day or the week.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| media_type | Yes | Type of media to fetch trends for. | |
| time_window | Yes | Trend time window. |
Implementation Reference
- src/index.ts:95-100 (registration)Registration of the 'get_trending' tool with the MCP server, binding the schema and handler.
server.tool( "get_trending", "Get trending movies, TV, or both, for the day or the week.", getTrendingSchema, wrap(getTrending), ); - src/tools.ts:211-214 (schema)Zod schema defining the input parameters for get_trending: media_type (movie/tv/all) and time_window (day/week).
export const getTrendingSchema = { media_type: z.enum(["movie", "tv", "all"]).describe("Type of media to fetch trends for."), time_window: z.enum(["day", "week"]).describe("Trend time window."), }; - src/tools.ts:216-228 (handler)The main handler function for get_trending. Calls TMDB API /trending/{media_type}/{time_window} and maps results using summarizeTrending.
export async function getTrending(args: { media_type: "movie" | "tv" | "all"; time_window: "day" | "week"; }) { const data = await tmdbGet<PaginatedResponse<TrendingItem>>( `/trending/${args.media_type}/${args.time_window}`, { language: "en-US" }, ); return { total_results: data.total_results, results: data.results.map(summarizeTrending), }; } - src/tools.ts:63-73 (helper)Helper function summarizeTrending used to format each trending result item (id, media_type, title, year, overview, rating, poster).
function summarizeTrending(item: TrendingItem) { return { id: item.id, media_type: item.media_type, title: item.title ?? item.name ?? "", year: yearOf(item.release_date ?? item.first_air_date), overview: item.overview ?? null, rating: item.vote_average ?? null, poster: posterUrl(item.poster_path), }; } - src/tools.ts:29-39 (helper)TrendingItem interface definition used by getTrending, with optional title/name fields since trending can be movie or TV.
interface TrendingItem { id: number; media_type: "movie" | "tv"; title?: string; name?: string; release_date?: string | null; first_air_date?: string | null; overview?: string | null; vote_average?: number | null; poster_path?: string | null; }