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)) {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'various formats' but doesn't specify what the export does (e.g., generates a file, returns content, requires permissions, has rate limits, or side effects). This leaves critical behavioral traits undocumented for a mutation-like operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool that likely performs a mutation (exporting data). It lacks details on what the export produces, any side effects, error conditions, or how it differs from similar export tools, leaving significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (id and format with enum). The description adds no additional meaning beyond implying format options with 'various formats', which the schema already covers explicitly. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Export') and resource ('a book'), specifying the verb+resource combination. However, it doesn't differentiate from sibling tools like 'export_chapter' or 'export_page' that perform similar export operations on different resources, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'export_chapter' or 'export_page', nor does it mention any prerequisites or contextual constraints. It simply states what the tool does without usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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