Search Pages
search_pagesFind pages in BookStack by search query, optionally filtering results to specific books for targeted documentation discovery.
Instructions
Search specifically for pages with optional book filtering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for pages | |
| book_id | No | Filter results to pages within a specific book | |
| count | No | Number of results to return | |
| offset | No | Pagination offset |
Implementation Reference
- src/bookstack-client.ts:298-318 (handler)The actual implementation of the search_pages tool logic.
async searchPages(query: string, options?: { bookId?: number; count?: number; offset?: number; }): Promise<any> { let searchQuery = `{type:page} ${query}`.trim(); // Add book filtering if specified if (options?.bookId) { searchQuery = `{book_id:${options.bookId}} ${searchQuery}`; } const params: any = { query: searchQuery }; if (options?.count) params.count = Math.min(options.count, 500); if (options?.offset) params.offset = options.offset; const response = await this.client.get('/search', { params }); const results = response.data.data || response.data; return await this.enhanceSearchResults(results, query); } - src/index.ts:84-106 (registration)The registration of the search_pages tool in the MCP server.
server.registerTool( "search_pages", { title: "Search Pages", description: "Search specifically for pages with optional book filtering", inputSchema: { query: z.string().describe("Search query for pages"), book_id: z.coerce.number().optional().describe("Filter results to pages within a specific book"), count: z.coerce.number().max(500).optional().describe("Number of results to return"), offset: z.coerce.number().optional().describe("Pagination offset") } }, async (args) => { const results = await client.searchPages(args.query, { bookId: args.book_id, count: args.count, offset: args.offset }); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] }; } );