Skip to main content
Glama
ShubhanshuSondhiya

TMDB MCP Server

get-similar

Find movies similar to a specific film using its TMDB ID. This tool helps users discover related content based on movie preferences.

Instructions

Get similar movies to a given movie

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
movieIdYesID of the movie to find similar movies for

Implementation Reference

  • MCP tool handler for 'get-similar' that invokes getSimilarMovies with error handling.
    "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");
      }
    },
  • JSON Schema definition for the input parameters of the 'get-similar' tool.
    "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.
    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}`);
      }
    }
  • src/handlers.ts:13-72 (registration)
    Import of toolHandlers and tools (schemas) in the MCP server handlers setup.
    import { toolHandlers, tools } from "./tools.js";
    import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
    
    export const setupHandlers = (server: Server): void => {
      // Resource handlers
      server.setRequestHandler(
        ListResourcesRequestSchema,
        async () => ({ resources }),
      );
      
      server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => ({
        resourceTemplates,
      }));
      
      server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
        const { uri } = request.params;
        // Using type assertion to tell TypeScript this is a valid key
        const resourceHandler = resourceHandlers[uri as keyof typeof resourceHandlers];
        if (resourceHandler) return await resourceHandler();
        
        const resourceTemplateHandler = await getResourceTemplate(uri);
        if (resourceTemplateHandler) return await resourceTemplateHandler();
        
        throw new Error(`Resource not found: ${uri}`);
      });
    
      // Prompt handlers
      server.setRequestHandler(ListPromptsRequestSchema, async () => ({
        prompts: Object.values(prompts),
      }));
      
      server.setRequestHandler(GetPromptRequestSchema, async (request) => {
        const { name, arguments: args } = request.params;
        // Using type assertion to tell TypeScript this is a valid key
        const promptHandler = promptHandlers[name as keyof typeof promptHandlers];
        
        if (promptHandler) {
          return promptHandler(args as any);
        }
        
        throw new Error(`Prompt not found: ${name}`);
      });
    
      // Tool handlers
      server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: Object.values(tools),
      }));
    
      // This is the key fix - we need to format the response properly
      server.setRequestHandler(CallToolRequestSchema, async (request) => {
        try {
          const { name, arguments: args } = request.params;
          // Using type assertion to tell TypeScript this is a valid key
          const handler = toolHandlers[name as keyof typeof toolHandlers];
    
          if (!handler) throw new Error(`Tool not found: ${name}`);
    
          // Execute the handler but wrap the response in the expected format
          const result = await handler(args as any);
  • src/handlers.ts:62-98 (registration)
    MCP CallTool request handler that dispatches to specific toolHandlers including 'get-similar'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        const { name, arguments: args } = request.params;
        // Using type assertion to tell TypeScript this is a valid key
        const handler = toolHandlers[name as keyof typeof toolHandlers];
    
        if (!handler) throw new Error(`Tool not found: ${name}`);
    
        // Execute the handler but wrap the response in the expected format
        const result = await handler(args as any);
        
        // Return in the format expected by the SDK
        return {
          tools: [{
            name,
            inputSchema: {
              type: "object",
              properties: {} // This would ideally be populated with actual schema
            },
            description: `Tool: ${name}`,
            result
          }]
        };
      } catch (error) {
        // Properly handle errors
        if (error instanceof Error) {
          return {
            tools: [],
            error: error.message
          };
        }
        return {
          tools: [],
          error: "An unknown error occurred"
        };
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It doesn't describe response format, error handling, rate limits, or other behavioral traits beyond the basic operation, which is insufficient for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste, making it appropriately sized and front-loaded. Every word contributes directly to the tool's purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that likely returns a list of movies. It doesn't explain what 'similar' means (e.g., genre, director, ratings), the return format, or any limitations, leaving significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents the 'movieId' parameter fully. The description adds no additional meaning beyond what the schema provides, such as examples or constraints, resulting in the baseline score for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('similar movies'), making it immediately understandable. However, it doesn't differentiate from sibling tools like 'search-movies' or 'get-trending' beyond the basic concept of similarity, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search-movies' or 'get-trending'. It lacks explicit context, exclusions, or prerequisites, leaving the agent to infer usage based on the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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