MCP cover image
See in Github
2025-03-14

Un servidor MCP simple que le permite convertir documentos HTML en PDFS

1

Github Watches

1

Github Forks

0

Github Stars

E-Book MCP Server with PDF Conversion

A server for creating e-books and PDF documents from HTML content with embedded images. This project provides robust functionality for converting HTML files to PDF while properly handling embedded images.

Features

  • Convert HTML files to PDF documents with proper image handling
  • Support for both pdfkit (wkhtmltopdf) and reportlab PDF generation engines
  • Robust error handling and logging
  • Temporary file management with automatic cleanup
  • Detailed diagnostic information during conversion process

Requirements

  • Python 3.9+
  • wkhtmltopdf (optional but recommended for better PDF quality)
  • Python packages:
    • fastapi
    • python-docx
    • pdfkit
    • reportlab
    • pydantic
    • uvicorn
    • pillow

Installation

  1. Clone this repository
  2. Install the required Python packages:
    pip install fastapi python-docx pdfkit reportlab pydantic uvicorn pillow
    
  3. Install wkhtmltopdf (optional):
    • Windows: Download and install from wkhtmltopdf.org
    • Linux: sudo apt-get install wkhtmltopdf
    • macOS: brew install wkhtmltopdf

Usage

The server provides a function called handle_call_tool that accepts the following arguments:

arguments = {
  "text_file": "path/to/input.html",
  "images": {
    "image1.png": "path/to/image1.png",
    "image2.jpg": "path/to/image2.jpg"
  },
  "output_pdf": "path/to/output.pdf"
}

Example

result = await handle_call_tool("CREATE_DOC", {
    "text_file": "document.html",
    "images": {
        "header.png": "images/header.png",
        "footer.jpg": "images/footer.jpg"
    },
    "output_pdf": "output/document.pdf"
})

How It Works

  1. The server processes the input HTML file
  2. It replaces image references in the HTML with absolute paths
  3. It attempts to convert the HTML to PDF using pdfkit (if available)
  4. If pdfkit fails or is not available, it falls back to reportlab
  5. The resulting PDF is saved to the specified output path

Project Structure

  • main.py: Contains the core functionality for PDF conversion
  • pyproject.toml: Project metadata and dependencies

License

MIT

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • OffchainLabs
  • Implementación de la prueba de estaca Ethereum

  • modelcontextprotocol
  • Servidores de protocolo de contexto modelo

  • huahuayu
  • Una puerta de enlace de API unificada para integrar múltiples API de explorador de blockchain similar a Esterscan con soporte de protocolo de contexto modelo (MCP) para asistentes de IA.

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

    Reviews

    2 (1)
    Avatar
    user_txpeMiMb
    2025-04-16

    As a loyal user of MCP-server-PDF--Conversion, I can confidently say this tool by rmcendarfer2017 is a game-changer. It's highly efficient in converting PDFs with simple steps, making my workflow smoother. The seamless integration and user-friendly interface make it stand out among others. Highly recommended! Check it out: https://github.com/rmcendarfer2017/MCP-server-PDF--Conversion