get-similar
Find movies similar to a specific film by entering its movie ID. The tool leverages TMDB API to provide tailored recommendations, enhancing your movie discovery experience.
Instructions
Get similar movies to a given movie
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| movieId | Yes | ID of the movie to find similar movies for |
Implementation Reference
- src/tools.ts:105-115 (handler)The handler function for the 'get-similar' tool. It takes a movieId and calls getSimilarMovies from tmdb-api, handling errors by throwing descriptive errors."get-similar": async ({ movieId }: { movieId: string }) => { try { // Return the raw results directly return await getSimilarMovies(movieId); } catch (error: unknown) { if (error instanceof Error) { throw new Error(`Failed to get similar movies: ${error.message}`); } throw new Error("Failed to get similar movies: Unknown error"); } },
- src/tools.ts:42-55 (registration)Registration of the 'get-similar' tool, including name, description, and input schema definition."get-similar": { name: "get-similar", description: "Get similar movies to a given movie", inputSchema: { type: "object", properties: { movieId: { type: "string", description: "ID of the movie to find similar movies for", }, }, required: ["movieId"], }, },
- src/tools.ts:42-55 (schema)Input schema for the 'get-similar' tool defining the movieId parameter."get-similar": { name: "get-similar", description: "Get similar movies to a given movie", inputSchema: { type: "object", properties: { movieId: { type: "string", description: "ID of the movie to find similar movies for", }, }, required: ["movieId"], }, },
- src/tmdb-api.ts:144-155 (helper)Helper function that fetches similar movies from TMDB API using axios, with retry logic.export async function getSimilarMovies(movieId: number | string): Promise<SearchMoviesResponse> { try { const response = await axiosWithRetry<SearchMoviesResponse>({ url: `/movie/${movieId}/similar` }); return response.data; } catch (error) { const err = error as Error; console.error('Error getting similar movies:', err.message); throw new Error(`Failed to get similar movies: ${err.message}`); } }