list_chapters
Retrieve a paginated listing of chapters accessible to the user from a BookStack wiki, with options to sort results and control page size.
Instructions
Get a listing of chapters visible to the user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of items per page | |
| page | No | Page number for pagination | |
| sort | No | Sort parameter |
Implementation Reference
- src/tools/content-tools.ts:609-613 (handler)Handler function for the 'list_chapters' tool. Parses input arguments using PaginationSchema, fetches chapters via BookStackClient.getChapters, and formats the paginated response.case "list_chapters": { const params = PaginationSchema.parse(args); const result = await client.getChapters(params); return formatApiResponse(result.data, result.total); }
- src/lib/validation.ts:5-11 (schema)Zod schema used for validating the input parameters (page, count, sort) of the list_chapters tool.export const PaginationSchema = z .object({ page: z.number().optional(), count: z.number().optional(), sort: z.string().optional(), }) .optional();
- src/tools/content-tools.ts:164-175 (registration)Tool registration in createContentTools function, defining name, description, and inputSchema for MCP tool listing.{ name: "list_chapters", description: "Get a listing of chapters visible to the user", inputSchema: { type: "object", properties: { page: { type: "number", description: "Page number for pagination" }, count: { type: "number", description: "Number of items per page" }, sort: { type: "string", description: "Sort parameter" }, }, }, },
- src/index.ts:56-59 (registration)Registration of all tools including content tools (containing list_chapters) for the MCP server.const allTools: Tool[] = [ ...createContentTools(bookStackClient), ...createSearchAndUserTools(bookStackClient), ];
- src/lib/bookstack-client.ts:142-146 (helper)BookStackClient method that implements the API call to fetch list of chapters using the private get helper.async getChapters( params?: PaginationParams ): Promise<ApiResponse<Chapter[]>> { return this.get<Chapter>("/chapters", params); }