export_page
Export BookStack wiki pages to HTML, PDF, plain text, or markdown formats for offline use, sharing, or backup purposes.
Instructions
Export a page in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Page ID | |
| format | Yes | Export format |
Implementation Reference
- src/tools/content-tools.ts:406-421 (schema)Defines the input schema for the 'export_page' tool, requiring a page ID and specifying supported export formats (html, pdf, plaintext, markdown).{ 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/tools/content-tools.ts:711-730 (handler)The handler logic within handleContentTool for 'export_page', which parses the page ID and format, then delegates to the appropriate BookStackClient export method 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/lib/bookstack-client.ts:226-255 (helper)BookStackClient helper methods that perform the actual HTTP requests to BookStack API for exporting a page in HTML, PDF, plaintext, or Markdown formats.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; }
- src/index.ts:56-59 (registration)Registers the 'export_page' tool (via createContentTools) in the allTools array provided to the MCP server's ListToolsRequest handler.const allTools: Tool[] = [ ...createContentTools(bookStackClient), ...createSearchAndUserTools(bookStackClient), ];