Skip to main content
Glama
tonderflash

Movie Search MCP Server

by tonderflash

recommend_movies

Discover personalized movie recommendations based on your preferred genre. Input a genre like action, comedy, or drama to receive curated film suggestions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
genreNoMovie genre (optional). Examples: action, comedy, drama, horror, sci-fi, romance

Implementation Reference

  • Full tool definition including registration, input schema (zod), and handler logic for 'recommend_movies'. The handler fetches recommendations via helper and formats markdown response.
    server.tool( "recommend_movies", { genre: z .string() .optional() .describe( "Movie genre (optional). Examples: action, comedy, drama, horror, sci-fi, romance" ), }, async ({ genre }) => { try { const recommendations = await getMovieRecommendations(genre); if (recommendations.length === 0) { return { content: [ { type: "text", text: `❌ No recommendations found${ genre ? ` for genre "${genre}"` : "" }.`, }, ], }; } let response = `🎯 **Movie recommendations${ genre ? ` for ${genre}` : " (popular)" }:**\n\n`; recommendations.forEach((movie, index) => { response += `${index + 1}. **${movie.title}** (${movie.year})\n`; response += ` - TMDb ID: ${movie.id}\n`; if (movie.poster !== "N/A") { response += ` - Poster: ${movie.poster}\n`; } response += "\n"; }); response += '\n💡 *Use "get_movie_details" with the ID and source "tmdb" for more information.*'; return { content: [ { type: "text", text: response, }, ], }; } catch (error) { return { content: [ { type: "text", text: `❌ Error getting recommendations: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } } );
  • Core helper function implementing the movie recommendation logic using TMDb API. Supports genre filtering via discover endpoint or falls back to popular movies. Maps results to standardized SearchResult format.
    export async function getMovieRecommendations( genre?: string ): Promise<SearchResult[]> { if (!TMDB_API_KEY) { return []; } try { let endpoint = `${TMDB_BASE_URL}/movie/popular`; const params = new URLSearchParams({ api_key: TMDB_API_KEY, language: "en-US", page: "1", }); if (genre) { // Basic genre mapping const genreMap: { [key: string]: string } = { action: "28", adventure: "12", animation: "16", comedy: "35", crime: "80", documentary: "99", drama: "18", family: "10751", fantasy: "14", history: "36", horror: "27", music: "10402", mystery: "9648", romance: "10749", "science fiction": "878", "sci-fi": "878", thriller: "53", war: "10752", western: "37", }; const genreId = genreMap[genre.toLowerCase()]; if (genreId) { endpoint = `${TMDB_BASE_URL}/discover/movie`; params.append("with_genres", genreId); } } const response = await fetch(`${endpoint}?${params}`); const data = (await response.json()) as TMDbSearchResult; return data.results.slice(0, 10).map((movie) => ({ title: movie.title, year: movie.release_date ? movie.release_date.split("-")[0] : "", id: movie.id.toString(), type: "movie", poster: movie.poster_path ? `https://image.tmdb.org/t/p/w500${movie.poster_path}` : "N/A", source: "tmdb" as const, })); } catch (error) { console.error("Error getting movie recommendations:", error); return []; } }

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/tonderflash/movie-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server