Skip to main content
Glama
ttpears

BookStack MCP Server

by ttpears

Export Book

export_book

Export an entire book from BookStack in HTML, PDF, Markdown, plain text, or ZIP format using the book ID.

Instructions

Export an entire book in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesBook ID
formatYesExport format

Implementation Reference

  • Tool handler for 'export_book' that calls the BookStack client and formats the response.
    async (args) => {
      const content = await client.exportBook(args.id, args.format);
    
      if (typeof content === 'object' && content.download_url) {
        const format = args.format.toUpperCase();
        return {
          content: [{
            type: "text",
            text: `✅ **${format} Book Export Ready**\n\n` +
                  `📚 **Book:** ${content.book_name}\n` +
                  `📁 **File:** ${content.filename}\n\n` +
                  `🚀 **Direct Download Link:**\n${content.download_url}\n\n` +
                  `â„šī¸  **Note:** ${content.note}`
          }]
        };
      }
    
      const text = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
      return {
        content: [{ type: "text", text }]
      };
  • src/index.ts:269-278 (registration)
    Registration of 'export_book' tool with its schema definition.
    server.registerTool(
      "export_book",
      {
        title: "Export Book",
        description: "Export an entire book in various formats",
        inputSchema: {
          id: z.coerce.number().min(1).describe("Book ID"),
          format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"]).describe("Export format")
        }
      },
  • Implementation of exportBook logic in the BookStack client.
    async exportBook(id: number, format: 'html' | 'pdf' | 'markdown' | 'plaintext' | 'zip'): Promise<any> {
      // For binary formats (PDF, ZIP), return BookStack web URL using slug
      if (format === 'pdf' || format === 'zip') {
        // First fetch the book data to get slug
        const book = await this.getBook(id);
        
        // Construct the correct web URL with slug
        const directUrl = `${this.baseUrl}/books/${book.slug}/export/${format}`;
        const filename = `${book.slug}.${format}`;
        const contentType = format === 'pdf' ? 'application/pdf' : 'application/zip';
        
        return {
          format: format,
          filename: filename,
          download_url: directUrl,
          content_type: contentType,
          export_success: true,
          book_id: id,
          book_name: book.name,
          direct_download: true,
          note: "This is a direct link to BookStack's web export. You may need to be logged in to BookStack to access it."
        };
      }
      
      // For text formats, fetch the content via API
      const response = await this.client.get(`/books/${id}/export/${format}`);
      return response.data;
    }
    
    async exportChapter(id: number, format: 'html' | 'pdf' | 'markdown' | 'plaintext' | 'zip'): Promise<any> {
      // For binary formats (PDF, ZIP), return BookStack web URL using slugs
      if (format === 'pdf' || format === 'zip') {
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Export') but doesn't mention whether this requires authentication, affects system state, has rate limits, or what the output looks like (e.g., file download vs. text return). This leaves significant gaps for a tool that likely generates files.

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 zero wasted words. It's front-loaded with the core action and resource, making it easy to scan and understand quickly.

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?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain the export behavior (e.g., file generation, download mechanism, or content structure), which is critical given the complexity of exporting an entire book in multiple formats.

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 already fully documents both parameters (id and format with enum values). The description adds no additional parameter semantics beyond what's in the schema, such as explaining what 'zip' format includes or how book IDs are obtained.

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 verb ('Export') and resource ('an entire book'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like export_chapter or export_page, which export smaller components rather than the entire book.

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 for partial exports or get_book for metadata retrieval. It mentions 'various formats' but doesn't specify which formats are best for different use cases.

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/ttpears/bookstack-mcp'

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