export_page
Export BookStack wiki pages in HTML, PDF, plaintext, or markdown format using the page ID to convert and download content for offline use or sharing.
Instructions
Export a page in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | Yes | Export format | |
| id | Yes | Page ID |
Implementation Reference
- src/tools/content-tools.ts:711-730 (handler)The handler function for the 'export_page' tool. It extracts the page ID and format from arguments, then calls the corresponding BookStackClient export method (html, plaintext, markdown) or returns a message for PDF.case "export_page": { const id = parseInteger(args.id); const format = args.format; switch (format) { case "html": const html = await client.exportPageHtml(id); return html; case "pdf": return "PDF export is binary data - use API directly for file download"; case "plaintext": const text = await client.exportPagePlainText(id); return text; case "markdown": const markdown = await client.exportPageMarkdown(id); return markdown; default: throw new Error(`Unsupported export format: ${format}`); } }
- src/tools/content-tools.ts:406-421 (schema)The input schema and definition for the 'export_page' tool, specifying required parameters: page ID (number) and format (enum: html, pdf, plaintext, markdown). This is part of the Tool object returned by createContentTools.{ name: "export_page", description: "Export a page in various formats", inputSchema: { type: "object", properties: { id: { type: "number", description: "Page ID" }, format: { type: "string", enum: ["html", "pdf", "plaintext", "markdown"], description: "Export format", }, }, required: ["id", "format"], }, },
- src/index.ts:55-66 (registration)Registers the 'export_page' tool (included via createContentTools) in the MCP server's list of available tools, making it discoverable via listTools request.// Combine all tools const allTools: Tool[] = [ ...createContentTools(bookStackClient), ...createSearchAndUserTools(bookStackClient), ]; // List tools handler server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools, }; });
- src/index.ts:76-100 (registration)Explicitly lists 'export_page' in the contentToolNames array, enabling dispatch to handleContentTool during tool execution.const contentToolNames = [ "list_books", "get_book", "create_book", "update_book", "delete_book", "export_book", "list_chapters", "get_chapter", "create_chapter", "update_chapter", "delete_chapter", "export_chapter", "list_pages", "get_page", "create_page", "update_page", "delete_page", "export_page", "list_shelves", "get_shelf", "create_shelf", "update_shelf", "delete_shelf", ];
- src/lib/bookstack-client.ts:226-255 (helper)Helper methods in BookStackClient class that implement the actual BookStack API calls for exporting a page in HTML, PDF (binary), plaintext, and Markdown formats. Called by the tool handler.async exportPageHtml(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/pages/${id}/export/html` ); return response.data; } async exportPagePdf(id: number): Promise<Buffer> { const response: AxiosResponse<Buffer> = await this.api.get( `/pages/${id}/export/pdf`, { responseType: "arraybuffer", } ); return response.data; } async exportPagePlainText(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/pages/${id}/export/plaintext` ); return response.data; } async exportPageMarkdown(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/pages/${id}/export/markdown` ); return response.data; }