Skip to main content
Glama

export_book

Export BookStack books to HTML, PDF, plaintext, or markdown formats for offline use or content migration.

Instructions

Export a book in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesBook ID
formatYesExport format

Implementation Reference

  • Handler logic in handleContentTool that parses input arguments and dispatches to the appropriate BookStackClient exportBook* method based on the specified format (html, pdf, plaintext, markdown). Handles PDF specially as it notes binary limitation.
    case "export_book": { const id = parseInteger(args.id); const format = args.format; switch (format) { case "html": const html = await client.exportBookHtml(id); return html; case "pdf": return "PDF export is binary data - use API directly for file download"; case "plaintext": const text = await client.exportBookPlainText(id); return text; case "markdown": const markdown = await client.exportBookMarkdown(id); return markdown; default: throw new Error(`Unsupported export format: ${format}`); } }
  • Tool declaration including name, description, and inputSchema defining required 'id' (number) and 'format' (enum: ["html", "pdf", "plaintext", "markdown"]).
    { name: "export_book", description: "Export a book in various formats", inputSchema: { type: "object", properties: { id: { type: "number", description: "Book ID" }, format: { type: "string", enum: ["html", "pdf", "plaintext", "markdown"], description: "Export format", }, }, required: ["id", "format"], }, },
  • Supporting methods in BookStackClient class for exporting a book: exportBookHtml, exportBookPdf, exportBookPlainText, exportBookMarkdown. These perform API calls to BookStack endpoints and are invoked by the handler.
    async exportBookHtml(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/books/${id}/export/html` ); return response.data; } async exportBookPdf(id: number): Promise<Buffer> { const response: AxiosResponse<Buffer> = await this.api.get( `/books/${id}/export/pdf`, { responseType: "arraybuffer", } ); return response.data; } async exportBookPlainText(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/books/${id}/export/plaintext` ); return response.data; } async exportBookMarkdown(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/books/${id}/export/markdown` ); return response.data; }
  • src/index.ts:124-126 (registration)
    Dispatch logic in MCP server's CallToolRequest handler that routes 'export_book' (via inclusion in contentToolNames) to handleContentTool for execution.
    if (contentToolNames.includes(name)) { result = await handleContentTool(name, args, bookStackClient); } else if (searchUserToolNames.includes(name)) {

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lautarobarba/bookstack_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server