list-tv-reviews
Retrieve reviews for TV shows from Douban using the show's unique ID to analyze audience feedback and critical reception.
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 that implements the core logic of the 'list-tv-reviews' tool: validates input, fetches reviews using getTVReviews, formats them into a markdown table using json2md, and returns as text content.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:152-180 (registration)The registration of the 'list-tv-reviews' tool on the MCP server, including name, description, input schema, and inline 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/index.ts:155-157 (schema)Zod input schema for the tool, defining a required 'id' parameter as string with description.{ id: z.string().describe('douban tv id, e.g. "1234567890"') },
- src/api.ts:77-82 (helper)Supporting function that fetches the list of TV reviews from the Douban Frodo API endpoint.export async function getTVReviews(params: { id: string }) { const res = await requestFrodoApi(`/tv/${params.id}/reviews`); return res?.reviews ? res.reviews : [] }