Skip to main content
Glama

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
NameRequiredDescriptionDefault
movieIdYesID of the movie to find similar movies for

Implementation Reference

  • 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"], }, },
  • 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"], }, },
  • 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}`); } }

Other Tools

Related 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