list-tv-reviews
Retrieve TV show reviews from Douban by providing the show's ID to analyze audience feedback and ratings.
Instructions
list tv reviews
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | douban tv id, e.g. "1234567890" |
Implementation Reference
- src/index.ts:158-179 (handler)The handler function for the "list-tv-reviews" tool. It validates the input 'id', fetches TV reviews via getTVReviews, formats them into a markdown table using json2md, and returns the content as text.async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban tv id must be provided") } const reviews = await getTVReviews({ 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:155-157 (schema)Zod input schema defining the required 'id' parameter (Douban TV ID).{ id: z.string().describe('douban tv id, e.g. "1234567890"') },
- src/index.ts:152-180 (registration)MCP server.tool registration for 'list-tv-reviews', including name, description, schema, and handler function.server.tool( 'list-tv-reviews', "list tv reviews", { id: z.string().describe('douban tv id, e.g. "1234567890"') }, async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban tv id must be provided") } const reviews = await getTVReviews({ 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:76-82 (helper)Helper function getTVReviews that queries the Douban Frodo API for TV reviews given the TV ID and returns the reviews array.// 获取电视剧长评列表 export async function getTVReviews(params: { id: string }) { const res = await requestFrodoApi(`/tv/${params.id}/reviews`); return res?.reviews ? res.reviews : [] }