list-book-reviews
Retrieve user reviews for a specific book by providing its Douban ID to analyze reader feedback and opinions.
Instructions
list book reviews
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | douban book id, e.g. "1234567890" |
Implementation Reference
- src/index.ts:58-86 (registration)MCP tool registration for 'list-book-reviews', including description, Zod input schema, and execution handler that fetches reviews and formats them as a markdown table.server.tool( TOOL.LIST_BOOK_REVIEWS, "list book reviews", { id: z.string().describe('douban book id, e.g. "1234567890"') }, async (args) => { if (!args.id) { throw new McpError(ErrorCode.InvalidParams, "douban book id must be provided") } const reviews = await getBookReviews({ id: args.id }) const text = json2md({ table: { headers: ['title', 'rating', 'summary', 'id'], rows: reviews.reviews.map(_ => ({ id: _.id, title: _.title, rating: `${_.rating?.value || 0} (${_.rating?.count || 0}人)`, summary: _.abstract })) } }) return { content: [{ type: 'text', text }] } } )
- src/api.ts:48-58 (handler)Core implementation of fetching book reviews from Douban's Frodo API (`/book/{id}/reviews`), returning structured response with reviews list.export async function getBookReviews(params: { id: string }) { const res: { count: number start: number total: number reviews: Douban.BookReview[] } = await requestFrodoApi(`/book/${params.id}/reviews`) return res }
- src/index.ts:61-63 (schema)Input validation schema using Zod, requires 'id' string parameter.{ id: z.string().describe('douban book id, e.g. "1234567890"') },
- src/types.ts:1-9 (schema)TOOL enum defining the constant name 'list-book-reviews' used for registration.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' }
- src/types.ts:56-96 (schema)Type definition for Douban.BookReview, used in the response typing for getBookReviews.interface BookReview { rating: { count: number; max: number; star_count: number; value: number; } | null; useful_count: number; sharing_url: string; title: string; url: string; abstract: string; uri: string; ad_info: null; topic: null; photos: any[]; reactions_count: number; comments_count: number; user: { kind: string; name: string; url: string; uri: string; avatar: string; is_club: boolean; type: string; id: string; uid: string; }; create_time: string; reshares_count: number; type: string; id: string; subject: { press: string[]; type: string; pubdate: string[]; title: string; }; }