list-movie-reviews
Retrieve reviews for a specific movie from Douban using its unique ID to analyze audience opinions and critical feedback.
Instructions
list movie reviews
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | douban movie id, e.g. "1234567890" |
Implementation Reference
- src/index.ts:127-148 (handler)The MCP tool handler function. Validates input args.id, calls getMovieReviews helper, formats reviews into a Markdown table using json2md, and returns structured text content.async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban movie id must be provided") } const reviews = await getMovieReviews({ id: args.id }) const text = json2md({ table: { headers: ['title', 'rating', 'summary', 'id'], rows: reviews.map(_ => ({ id: _.id, title: _.title, rating: `${_.rating?.value || 0} (有用:${_.useful_count || 0}人)`, summary: _.abstract })) } }) return { content: [{ type: "text", text }] } }
- src/index.ts:124-126 (schema)Zod input schema for the tool: requires a douban movie ID.{ id: z.string().describe('douban movie id, e.g. "1234567890"') },
- src/index.ts:121-149 (registration)Registration of the 'list-movie-reviews' tool on the MCP server, including name from TOOL.LIST_MOVIE_REVIEWS constant, description, schema, and inline handler.server.tool( TOOL.LIST_MOVIE_REVIEWS, "list movie reviews", { id: z.string().describe('douban movie id, e.g. "1234567890"') }, async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban movie id must be provided") } const reviews = await getMovieReviews({ id: args.id }) const text = json2md({ table: { headers: ['title', 'rating', 'summary', 'id'], rows: reviews.map(_ => ({ id: _.id, title: _.title, rating: `${_.rating?.value || 0} (有用:${_.useful_count || 0}人)`, summary: _.abstract })) } }) return { content: [{ type: "text", text }] } } )
- src/api.ts:68-74 (helper)Helper function to fetch movie reviews data from the Douban Frodo API endpoint `/movie/{id}/reviews`.// 获取电影长评列表 export async function getMovieReviews(params: { id: string }) { const res = await requestFrodoApi(`/movie/${params.id}/reviews`); return res?.reviews ? res.reviews : [] }
- src/types.ts:1-9 (schema)Type definitions including the TOOL enum constant LIST_MOVIE_REVIEWS = 'list-movie-reviews' used for tool name.export enum TOOL { SEARCH_BOOK = 'search-book', LIST_BOOK_REVIEWS = 'list-book-reviews', SEARCH_MOVIE = 'search-movie', LIST_MOVIE_REVIEWS = 'list-movie-reviews', BROWSE = 'browse', LIST_GROUP_TOPICS = 'list-group-topics', GET_GROUP_TOPIC_DETAIL = 'get-group-topic-detail' }