get_recommendations
Retrieve movie recommendations based on a given TMDB movie ID. Find similar titles users enjoyed.
Instructions
Get TMDB's recommendations for users who liked the given movie.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| movie_id | Yes | TMDB movie ID to base recommendations on. |
Implementation Reference
- src/tools.ts:185-194 (handler)The handler function that calls TMDB /movie/{id}/recommendations API and returns recommendations mapped through summarizeMovie.
export async function getRecommendations(args: { movie_id: number }) { const data = await tmdbGet<PaginatedResponse<MovieListItem>>( `/movie/${args.movie_id}/recommendations`, { language: "en-US" }, ); return { total_results: data.total_results, results: data.results.map(summarizeMovie), }; } - src/tools.ts:181-183 (schema)Zod schema defining input validation: requires a positive integer movie_id.
export const getRecommendationsSchema = { movie_id: z.number().int().positive().describe("TMDB movie ID to base recommendations on."), }; - src/index.ts:81-86 (registration)Registers the tool 'get_recommendations' with the MCP server, wiring the schema and handler (wrapped for error handling).
server.tool( "get_recommendations", "Get TMDB's recommendations for users who liked the given movie.", getRecommendationsSchema, wrap(getRecommendations), ); - src/tools.ts:41-50 (helper)Helper used by getRecommendations to map raw movie list items into a summarized response shape.
function summarizeMovie(m: MovieListItem) { return { id: m.id, title: m.title, year: yearOf(m.release_date), overview: m.overview ?? null, rating: m.vote_average ?? null, poster: posterUrl(m.poster_path), }; }