Skip to main content
Glama
ThaLoc0one

Documentation MCP Server

by ThaLoc0one

docs_export_pdf

Export documentation to PDF format from built sites or documentation paths using Puppeteer/Playwright for professional documentation management.

Instructions

Generate PDF from documentation using Puppeteer/Playwright

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docsPathYesPath to documentation or built site
outputPathYesOutput path for PDF file
includePagesNoSpecific pages to include (optional, includes all by default)

Implementation Reference

  • The main handler function for the 'docs_export_pdf' tool. It generates detailed instructions for exporting documentation to PDF using Puppeteer or alternative tools.
    export async function exportPdf(args: any) {
      const { docsPath, outputPath, includePages } = args as ExportPdfArgs;
    
      const instructions = `📄 PDF Export Instructions:
    
    1. Install dependencies:
       npm install --save-dev puppeteer
    
    2. Create export script (pdf-export.js):
    
    \`\`\`javascript
    const puppeteer = require('puppeteer');
    const path = require('path');
    
    async function exportPdf() {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      
      // Navigate to your built documentation
      await page.goto('file://${docsPath}/index.html', {
        waitUntil: 'networkidle0'
      });
      
      // Generate PDF
      await page.pdf({
        path: '${outputPath}',
        format: 'A4',
        printBackground: true,
        margin: {
          top: '20mm',
          right: '20mm',
          bottom: '20mm',
          left: '20mm'
        }
      });
      
      await browser.close();
      console.log('PDF generated: ${outputPath}');
    }
    
    exportPdf();
    \`\`\`
    
    3. Run the script:
       node pdf-export.js
    
    Alternative tools:
    - prince (commercial, excellent quality)
    - wkhtmltopdf (free, good quality)
    - md-to-pdf (for simple Markdown)
    
    For Docusaurus, check:
    - docusaurus-prince-pdf
    - docusaurus-pdf`;
    
      return {
        content: [
          {
            type: "text",
            text: instructions,
          },
        ],
      };
    }
  • Input schema defining the parameters for the docs_export_pdf tool: docsPath, outputPath, and optional includePages.
    inputSchema: {
      type: "object",
      properties: {
        docsPath: {
          type: "string",
          description: "Path to documentation or built site",
        },
        outputPath: {
          type: "string",
          description: "Output path for PDF file",
        },
        includePages: {
          type: "array",
          items: { type: "string" },
          description: "Specific pages to include (optional, includes all by default)",
        },
      },
      required: ["docsPath", "outputPath"],
    },
  • src/index.ts:156-178 (registration)
    Tool registration in the tools array, including name, description, and input schema.
    {
      name: "docs_export_pdf",
      description: "Generate PDF from documentation using Puppeteer/Playwright",
      inputSchema: {
        type: "object",
        properties: {
          docsPath: {
            type: "string",
            description: "Path to documentation or built site",
          },
          outputPath: {
            type: "string",
            description: "Output path for PDF file",
          },
          includePages: {
            type: "array",
            items: { type: "string" },
            description: "Specific pages to include (optional, includes all by default)",
          },
        },
        required: ["docsPath", "outputPath"],
      },
    },
  • src/index.ts:310-311 (registration)
    Switch case in the CallToolRequestSchema handler that routes to the exportPdf function.
    case "docs_export_pdf":
      return await exportPdf(args);

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/ThaLoc0one/documentation-mcp-server'

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