list-movie-reviews
Retrieve movie reviews from Douban by providing the movie ID to analyze audience feedback and critical perspectives.
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)MCP tool handler for 'list-movie-reviews': validates input ID, fetches movie reviews via getMovieReviews, formats results as a markdown table, 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 schema for input parameters of the 'list-movie-reviews' tool, requiring a douban movie ID.{ id: z.string().describe('douban movie id, e.g. "1234567890"') },
- src/index.ts:122-149 (registration)Registration of the 'list-movie-reviews' tool in the MCP server using server.tool, specifying name from TOOL enum, description, input schema, and handler function.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:69-74 (helper)Helper function that performs the actual API request to fetch movie reviews from Douban's Frodo API endpoint.export async function getMovieReviews(params: { id: string }) { const res = await requestFrodoApi(`/movie/${params.id}/reviews`); return res?.reviews ? res.reviews : [] }
- src/types.ts:132-152 (schema)TypeScript interface defining the expected structure of individual movie reviews returned by the API.interface MovieReview { id: string title: string alt: string subject_id: string author: { id: string name: string uid: string signature: string alt: string avatar: string }[] rating: { max: number numRaters: number average: string min: number } summary: string }