Skip to main content
Glama
moria97
by moria97

search-movie

Search for movies and TV shows on Douban using keywords to find titles, details, and related content.

Instructions

search movies or tvs from douban by query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesquery string, e.g. "python"

Implementation Reference

  • The MCP tool handler function for 'search-movie'. It validates the query parameter, fetches movies using the searchMovies helper, formats the results into a markdown table using json2md, and returns the content as text.
    async (args) => {
      if (!args.q) {
        throw new McpError(ErrorCode.InvalidParams, "q must be provided")
      }
    
      const movies = await searchMovies(args)
      const text = json2md({
        table: {
          headers: ['title', 'subtitle', 'publish_date', 'rating', 'id'],
          rows: movies.map(_ => ({
            id: _.id,
            title: _.title,
            subtitle: _.card_subtitle,
            publish_date: _.year,
            rating: `${_.rating?.value || '0'} (${_.rating?.count || 0}人)`,
          }))
        }
      })
    
      return {
        content: [{ type: 'text', text }]
      }
    }
  • Zod schema defining the input parameters for the 'search-movie' tool: a required query string 'q'.
    {
      q: z.string().describe('query string, e.g. "python"')
    },
  • src/index.ts:89-118 (registration)
    Registration of the 'search-movie' tool on the MCP server using server.tool(), specifying the tool name via TOOL.SEARCH_MOVIE, description, input schema, and handler.
    server.tool(
      TOOL.SEARCH_MOVIE,
      'search movies or tvs from douban by query',
      {
        q: z.string().describe('query string, e.g. "python"')
      },
      async (args) => {
        if (!args.q) {
          throw new McpError(ErrorCode.InvalidParams, "q must be provided")
        }
    
        const movies = await searchMovies(args)
        const text = json2md({
          table: {
            headers: ['title', 'subtitle', 'publish_date', 'rating', 'id'],
            rows: movies.map(_ => ({
              id: _.id,
              title: _.title,
              subtitle: _.card_subtitle,
              publish_date: _.year,
              rating: `${_.rating?.value || '0'} (${_.rating?.count || 0}人)`,
            }))
          }
        })
    
        return {
          content: [{ type: 'text', text }]
        }
      }
    );
  • Core API helper function searchMovies that performs the actual API request to Frodo Douban API endpoint for searching movies by query and maps the response items to their target objects.
    export async function searchMovies(params: {
      q: string
    }) {
      const res = await requestFrodoApi(`/search/movie?q=${params.q}`)
      return res?.items ? res.items.map(_ => _.target) : [];
    }
  • TypeScript type definition for Douban.Movie, describing the structure of movie data used in the tool's output.
    interface Movie {
      /** 条目 id */
      id: string;
      /** 中文名 */
      title: string;
      /** 原名 */
      original_title: string;
      /** 条目 URL */
      alt: string;
      /** 
       * 电影海报图,分别提供 288px x 465px(大),96px x 155px(中) 64px x 103px(小)尺寸 
       */
      images: {
        small: string;
        medium: string;
        large: string;
      };
      /** 评分信息 */
      rating: {
        /** 平均评分 */
        average: number;
        /** 评分人数 */
        numRaters?: number;
        /** 评分人数(别名) */
        ratings_count?: number;
      };
      /** 如果条目类型是电影则为上映日期,如果是电视剧则为首播日期 */
      pubdates: string[];
      /** 年代 */
      year: string;
      /** 条目分类, movie 或者 tv */
      subtype: 'movie' | 'tv';
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.0
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observed

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are present, and the description only states the basic action. It does not disclose behavioral traits such as output format, pagination, or safety considerations (e.g., read-only nature).

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, direct sentence with no filler. It is front-loaded with the verb and resource, capturing the essence efficiently.

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

Completeness3/5

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

Given the simple nature of the tool (one parameter, no output schema), the description is adequate but lacks details on return values or behavior, making it minimally viable.

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 fully describes the 'q' parameter with an example, and the description's 'by query' adds no additional semantic value. With 100% schema coverage, a baseline of 3 is appropriate.

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

Purpose5/5

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

The description clearly identifies the action (search), resource (movies or TVs), and source (Douban), distinguishing it from sibling tools like search-book and get-movie-detail.

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?

No guidance is provided on when to use this tool versus alternatives. The description merely states the function without mentioning exclusions or context such as 'use for finding movies by query, not for details'.

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