mcp-server-pdf--conversion
A Simple MCP Server that allows you to convert HTML documents to PDFs
Documentation
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 pillow3. Install wkhtmltopdf (optional):
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
Frequently asked questions
What is mcp-server-pdf--conversion?
mcp-server-pdf--conversion is A Simple MCP Server that allows you to convert HTML documents to PDFs
How do I install mcp-server-pdf--conversion?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-server-pdf--conversion open source?
Yes — it is hosted on GitHub at https://github.com/rmcendarfer2017/MCP-server-PDF--Conversion and has 1 stars.
Related MCP tools
This MCP server integrates with your Google Drive and Google Sheets, to enable creating and modifying spreadsheets. Python-based implementation.
🙌 OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.
Universal memory layer for AI Agents; Announcing OpenMemory MCP - local and secure memory management. Python-based implementation.
基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择ChatGPT/Claude/DeepSeek/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
Cognee is the open-source AI memory platform for agents. Give your AI agents persistent long-term memory across sessions with a self-hosted knowledge graph engine.
An LLM agent that conducts deep research (local and web) on any given topic and generates a long report with citations. Built for the Model Context Protocol to
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP