This MCP server provides multiple file conversion tools for converting various document and image formats. This project is built using the [Model Context Protocol (MCP)](https://modelcontextprotocol.io) and is designed to serve AI agents that need file conversion capabilities.
Features
**DOCX to PDF**: Convert Microsoft Word documents to PDF
**PDF to DOCX**: Convert PDF documents to Microsoft Word format
**Image Format Conversion**: Convert between various image formats (JPG, PNG, WebP, etc.)
**Excel to CSV**: Convert Excel spreadsheets to CSV format
**HTML to PDF**: Convert HTML files to PDF format
**Markdown to PDF**: Convert Markdown documents to PDF with proper styling
**Generic Conversion**: A versatile tool that attempts to handle various format conversions
Various conversion libraries:
- [docx2pdf](https://pypi.org/project/docx2pdf/) - for DOCX to PDF conversion
- [pdf2docx](https://pypi.org/project/pdf2docx/) - for PDF to DOCX conversion
- [Pillow](https://pypi.org/project/Pillow/) - for image format conversions
- [pandas](https://pypi.org/project/pandas/) - for Excel to CSV conversion
- [pdfkit](https://pypi.org/project/pdfkit/) - for HTML to PDF conversion
- [markdown](https://pypi.org/project/markdown/) - for Markdown to HTML conversion
Installation
**Clone the Repository**
```bash
git clone https://github.com/wowyuarm/file-converter-mcp.git
cd file-converter-mcp
```
**Create a Virtual Environment (optional but recommended)**
```bash
python -m venv venv
source venv/bin/activate # On Unix-based systems
venv\Scripts\activate # On Windows
```
**Install Dependencies**
Install the required packages using pip:
```bash
pip install mcp docx2pdf pdf2docx pillow pandas pdfkit markdown
```
Alternatively, if you are using [uv](https://docs.astral.sh/uv/):
```bash
uv add "mcp[cli]" docx2pdf pdf2docx pillow pandas pdfkit markdown
```
Note: Some conversion libraries may have additional system dependencies. Please check their documentation for details.
Usage
Running the Server in Development Mode
To test the server, run:
Installing for Claude Desktop
Optionally, you can install the server on Claude Desktop with:
API / Tools
The MCP server exposes the following tools:
Path-Based Tools (Also Support Content Input)
docx2pdf
Command: `docx2pdf`
**Input Option 1**: Path to a .docx file
```
input_file: path/to/document.docx
```
**Input Option 2**: Base64 encoded content of the DOCX file
```
file_content_base64: [base64 encoded string]
```
**Output**: Base64 encoded string of the converted PDF file
pdf2docx
Command: `pdf2docx`
**Input Option 1**: Path to a PDF file
```
input_file: path/to/document.pdf
```
**Input Option 2**: Base64 encoded content of the PDF file
```
file_content_base64: [base64 encoded string]
```
**Output**: Base64 encoded string of the converted DOCX file
**Content-Based Conversion** (works even when path lookup fails)
```
@File Converter
docx2pdf
file_content_base64: [base64 encoded string]
```
This dual-mode approach provides maximum flexibility and reliability:
When in doubt, use content-based input for guaranteed processing
All intermediate files are created with unique names in temporary directories
Temporary files are automatically cleaned up after processing
Handling Claude-Specific File Uploads
When using with Claude, if a file upload fails to be found:
Try using the original filename with a preceding path:
```
@File Converter
docx2pdf
input_file: /tmp/file.docx
```
If that fails, obtain the file content directly from Claude:
```
@File Converter
docx2pdf
file_content_base64: [base64 content obtained from Claude]
```
Error Handling
Each tool validates file existence using multiple search strategies
Detailed error messages are returned in a structured JSON format: `{"success": false, "error": "error message"}`
The server includes comprehensive logging for troubleshooting
The server gracefully handles exceptions and returns informative error messages
Contributing
Contributions are welcome! If you'd like to contribute, please follow the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md) ( : [ ](CONTRIBUTING.md), English: [Contributing Guidelines](CONTRIBUTING_EN.md)).
License
This project is licensed under the MIT License see the [LICENSE](LICENSE) file for details.
GitHub Repository
Visit the GitHub repository at: https://github.com/wowyuarm/file-converter-mcp