get_pages
Retrieve and filter BookStack documentation pages with content previews, word counts, and contextual information to locate specific content efficiently.
Instructions
List pages with content previews, word counts, and contextual information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| book_id | No | Filter by book ID | |
| chapter_id | No | Filter by chapter ID | |
| offset | No | Pagination offset | |
| count | No | Number of results to return | |
| sort | No | Sort field | |
| filter | No | Additional filter criteria |
Implementation Reference
- src/bookstack-client.ts:348-379 (handler)The implementation of getPages, which makes the API call to BookStack to fetch page lists.
async getPages(options?: { bookId?: number; chapterId?: number; offset?: number; count?: number; sort?: string; filter?: Record<string, any>; }): Promise<ListResponse<Page>> { const params: any = { offset: options?.offset || 0, count: Math.min(options?.count || 50, 500) }; // Build filter object const filter: any = { ...options?.filter }; if (options?.bookId) filter.book_id = options.bookId; if (options?.chapterId) filter.chapter_id = options.chapterId; if (Object.keys(filter).length > 0) { params.filter = JSON.stringify(filter); } if (options?.sort) params.sort = options.sort; const response = await this.client.get('/pages', { params }); const data = response.data; return { ...data, data: await Promise.all(data.data.map((page: Page) => this.enhancePageResponse(page))) }; } - src/index.ts:150-177 (registration)Tool registration for 'get_pages', defining its input schema and invoking the handler.
server.registerTool( "get_pages", { title: "List Pages", description: "List pages with content previews, word counts, and contextual information", inputSchema: { book_id: z.coerce.number().optional().describe("Filter by book ID"), chapter_id: z.coerce.number().optional().describe("Filter by chapter ID"), offset: z.coerce.number().default(0).describe("Pagination offset"), count: z.coerce.number().max(500).default(50).describe("Number of results to return"), sort: z.string().optional().describe("Sort field"), filter: z.record(z.any()).optional().describe("Additional filter criteria") } }, async (args) => { const pages = await client.getPages({ bookId: args.book_id, chapterId: args.chapter_id, offset: args.offset, count: args.count, sort: args.sort, filter: args.filter }); return { content: [{ type: "text", text: JSON.stringify(pages, null, 2) }] }; } );