Skip to main content
Glama
tonderflash

Movie Search MCP Server

by tonderflash

popular_movies

Discover popular and trending movies using the Movie Search MCP Server. Access curated lists based on audience preferences and stay updated with the most-watched films.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:246-295 (registration)
    Registration of the 'popular_movies' tool. Includes empty input schema {} and the inline handler function that calls getTrendingMovies() to fetch data and formats a markdown response.
    server.tool("popular_movies", {}, async () => {
      try {
        const popular = await getTrendingMovies();
    
        if (popular.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "❌ Could not get popular movies at this time.",
              },
            ],
          };
        }
    
        let response = "🔥 **Most popular movies this week:**\n\n";
    
        popular.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 popular movies: ${
                error instanceof Error ? error.message : "Unknown error"
              }`,
            },
          ],
        };
      }
    });
  • Helper function getTrendingMovies() that implements the core logic: fetches weekly trending movies from TMDb /trending/movie/week endpoint, maps to SearchResult objects (title, year, id, poster, source).
    export async function getTrendingMovies(): Promise<SearchResult[]> {
      if (!TMDB_API_KEY) {
        return [];
      }
    
      try {
        const params = new URLSearchParams({
          api_key: TMDB_API_KEY,
          language: "en-US",
        });
    
        const response = await fetch(
          `${TMDB_BASE_URL}/trending/movie/week?${params}`
        );
        const data = (await response.json()) as TMDbSearchResult;
    
        return data.results.slice(0, 15).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 trending movies:", error);
        return [];
      }
    }
  • TypeScript interface SearchResult used by getTrendingMovies to type the output array of movie search results.
    export interface SearchResult {
      title: string;
      year: string;
      id: string;
      type: string;
      poster: string;
      source: "omdb" | "tmdb";
    }
Install Server

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