Skip to main content
Glama
terryso

tv-recommender-mcp-server

get_recommendations_by_actor

Discover TV show recommendations based on a specific actor. Input the actor's name to receive a curated list of shows, with an option to limit the number of results. Ideal for finding new series featuring your favorite actors.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actor_nameYes演员名称,如"布莱恩·科兰斯顿"、"安东尼·斯塔尔"等
limitNo返回结果数量限制,默认为10

Implementation Reference

  • The core handler function implementing the logic for get_recommendations_by_actor: finds actor ID, retrieves TV credits via TMDB API, sorts results by vote_average descending, applies limit, and formats the DiscoverShowsResponse.
    export async function getRecommendationsByActor(actorName: string, limit = 10): Promise<DiscoverShowsResponse> {
      try {
        // 获取演员ID
        const actorId = await findPersonId(actorName);
        if (!actorId) {
          throw new ApiError(`未找到演员: ${actorName}`, 404);
        }
        
        // 获取演员的电视剧作品
        const response = await getPersonTvCredits(actorId);
        
        // 按流行度排序并限制结果数量
        let sortedResults = [...response.results];
        sortedResults.sort((a, b) => (b.vote_average || 0) - (a.vote_average || 0));
        sortedResults = sortedResults.slice(0, limit);
        
        return {
          page: 1,
          results: sortedResults,
          total_pages: 1,
          total_results: sortedResults.length
        };
      } catch (error) {
        throw new ApiError(`获取演员推荐电视剧失败: ${formatErrorMessage(error)}`, 500);
      }
    } 
  • src/server.ts:126-139 (registration)
    Registers the get_recommendations_by_actor tool with the MCP server, defines Zod input schema (actor_name required string, limit optional number default 10), and provides async handler that requires and invokes the implementation function.
    server.tool("get_recommendations_by_actor",
      { 
        actor_name: z.string().describe('演员名称,如"布莱恩·科兰斯顿"、"安东尼·斯塔尔"等'),
        limit: z.number().optional().default(10).describe('返回结果数量限制,默认为10')
      },
      async (params) => {
        console.log(`收到获取演员推荐请求,演员名称: ${params.actor_name},限制: ${params.limit || 10}`);
        const { getRecommendationsByActor } = require('./tools/discoverShowsTool');
        const results = await getRecommendationsByActor(params.actor_name, params.limit);
        return {
          content: [{ type: "text", text: JSON.stringify(results) }]
        };
      }
    );
  • Key helper function called by the handler to fetch TV credits for a given person ID from TMDB API and format them into DiscoverShowsResponse.
    export async function getPersonTvCredits(personId: number): Promise<DiscoverShowsResponse> {
      try {
        // 调用person/{person_id}/tv_credits API获取此人参与的所有电视剧
        const response = await tmdbClient.getPersonTvCredits(personId);
        
        // 格式化结果以匹配DiscoverShowsResponse格式
        const results = response.cast || [];
        const formattedResults = formatDiscoverResults(results);
        
        return {
          page: 1,
          results: formattedResults,
          total_pages: 1,
          total_results: formattedResults.length
        };
      } catch (error) {
        throw new ApiError(`获取人物电视作品失败: ${formatErrorMessage(error)}`, 500);
      }
    }
  • Helper function to search for a person by name in TMDB and return the first matching ID, used to resolve actorName to actorId in the handler.
    export async function findPersonId(personName: string): Promise<number | null> {
      try {
        const response = await tmdbClient.searchPerson(personName);
        if (response.results && response.results.length > 0) {
          return response.results[0].id;
        }
        return null;
      } catch (error) {
        return null;
      }
    }
  • TypeScript interface defining the output structure returned by getRecommendationsByActor and related functions.
    export interface DiscoverShowsResponse {
      page: number;
      results: DiscoverShowsResult[];
      total_pages: number;
      total_results: number;
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

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/terryso/tv-recommender-mcp-server'

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