Skip to main content
Glama

export_chapter

Export BookStack wiki chapters to HTML, PDF, plain text, or markdown formats for sharing, archiving, or offline use.

Instructions

Export a chapter in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesChapter ID
formatYesExport format

Implementation Reference

  • The handler logic within handleContentTool function that executes the export_chapter tool by parsing id and format, then calling the appropriate BookStackClient export method based on format.
    case "export_chapter": { const id = parseInteger(args.id); const format = args.format; switch (format) { case "html": const html = await client.exportChapterHtml(id); return html; case "pdf": return "PDF export is binary data - use API directly for file download"; case "plaintext": const text = await client.exportChapterPlainText(id); return text; case "markdown": const markdown = await client.exportChapterMarkdown(id); return markdown; default: throw new Error(`Unsupported export format: ${format}`); } }
  • The Tool object definition including name, description, and inputSchema for the export_chapter tool.
    { name: "export_chapter", description: "Export a chapter in various formats", inputSchema: { type: "object", properties: { id: { type: "number", description: "Chapter ID" }, format: { type: "string", enum: ["html", "pdf", "plaintext", "markdown"], description: "Export format", }, }, required: ["id", "format"], }, },
  • src/index.ts:88-88 (registration)
    The export_chapter tool is listed in the contentToolNames array, which determines if handleContentTool is called for this tool.
    "export_chapter",
  • Helper method in BookStackClient that performs the HTTP GET request to export chapter as HTML.
    async exportChapterHtml(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/chapters/${id}/export/html` ); return response.data; }
  • Helper method in BookStackClient that performs the HTTP GET request to export chapter as PDF (binary).
    async exportChapterPdf(id: number): Promise<Buffer> { const response: AxiosResponse<Buffer> = await this.api.get( `/chapters/${id}/export/pdf`, { responseType: "arraybuffer", } ); return response.data; }
  • Helper method in BookStackClient that performs the HTTP GET request to export chapter as plain text.
    async exportChapterPlainText(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/chapters/${id}/export/plaintext` ); return response.data; }
  • Helper method in BookStackClient that performs the HTTP GET request to export chapter as Markdown.
    async exportChapterMarkdown(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/chapters/${id}/export/markdown` ); return response.data; }

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