List Chapters
get_chaptersRetrieve chapter listings from BookStack documentation, with options to filter by specific book ID and manage pagination for organized content navigation.
Instructions
List chapters, optionally filtered by book
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | No | Filter by book ID | |
| offset | No | Pagination offset | |
| count | No | Number of results to return |
Implementation Reference
- src/bookstack-client.ts:386-397 (handler)The implementation of the getChapters method which fetches chapters from the API.
async getChapters(bookId?: number, offset = 0, count = 50): Promise<any> { const params: any = { offset, count }; if (bookId) params.filter = JSON.stringify({ book_id: bookId }); const response = await this.client.get('/chapters', { params }); const data = response.data; return { ...data, data: await Promise.all(data.data.map((chapter: Chapter) => this.enhanceChapterResponse(chapter))) }; } - src/index.ts:196-213 (registration)Registration of the 'get_chapters' tool and the request handler.
server.registerTool( "get_chapters", { title: "List Chapters", description: "List chapters, optionally filtered by book", inputSchema: { book_id: z.coerce.number().optional().describe("Filter by book ID"), offset: z.coerce.number().default(0).describe("Pagination offset"), count: z.coerce.number().default(50).describe("Number of results to return") } }, async (args) => { const chapters = await client.getChapters(args.book_id, args.offset, args.count); return { content: [{ type: "text", text: JSON.stringify(chapters, null, 2) }] }; } );