AI-powered PDF translation assistant using PDFMathTranslate-next, specialized for academic papers with mathematical formulas
Project description
Huoshui PDF Translator
Version: 0.1.0
Powered by: FastMCP & PDFMathTranslate-next
An intelligent PDF translation assistant that specializes in academic papers with mathematical formulas. Built using the FastMCP framework and powered by PDFMathTranslate-next, it provides comprehensive translation capabilities with context-aware assistance.
๐ Features
Core Translation Capabilities
- ๐ Academic Papers: Excellent handling of mathematical formulas and equations
- ๐ฌ Technical Documents: Preserves formatting and technical terminology
- ๐ Multi-language Support: Auto-detection with Chinese โ English specialization
- ๐จ Layout Preservation: Maintains original PDF structure and formatting
Smart Assistant Features
- ๐ง Context-Aware Prompts: Multiple specialized prompts for different scenarios
- ๐ ๏ธ Tool Status Checking: Verify translation tool installation and availability
- ๐ PDF Analysis: Get detailed information about PDF files before translation
- ๐ Flexible Path Handling: Support for both absolute and relative file paths
- โก Progress Reporting: Real-time progress updates during translation
- ๐จ Intelligent Error Handling: Comprehensive error diagnosis and troubleshooting
MCP Features
- ๐ Resources: Translation capability listings and PDF file information
- ๐ฏ Tools: Translation, PDF analysis, and tool status checking
- ๐ฌ Prompts: Role definitions, path guidance, options explanation, and error troubleshooting
- ๐ Security: Safe path validation with system directory protection
๐ง Prerequisites
Required Software
- Python 3.12+: Modern Python with async support
- PDFMathTranslate-next: The core translation engine
- FastMCP: Framework for intelligent assistant capabilities
Installation Commands
# Install PDFMathTranslate-next
pip install pdf-math-translate-next
# Verify installation
pmt --version
# Install project dependencies
uv sync
๐ Installation
Using UV (Recommended)
# Clone the repository
git clone https://github.com/your-username/huoshui-pdf-translator.git
cd huoshui-pdf-translator
# Install dependencies with uv
uv sync
# Run the server
uv run python main.py
Using Traditional pip
# Clone and setup
git clone https://github.com/your-username/huoshui-pdf-translator.git
cd huoshui-pdf-translator
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the server
python main.py
๐ Usage
MCP Tools
translate_pdf
Translates PDF documents while preserving mathematical formulas and layout.
# Basic usage
translate_pdf(pdf_path="Desktop/paper.pdf")
# With custom output path
translate_pdf(
pdf_path="Documents/research.pdf",
output_path="Documents/translated/research_cn.pdf"
)
pdf_get
Retrieves detailed information about a PDF file.
pdf_info = pdf_get(path="Desktop/document.pdf")
# Returns: PDFResource with path, size_bytes, page_count
check_translation_tool
Verifies PDFMathTranslate-next installation and status.
status = check_translation_tool()
# Returns: status, version, message
MCP Resources
translation_capability_list
Lists all supported translation capabilities and methods.
MCP Prompts
role_and_rules
Core identity and operational rules for the PDF translation assistant.
explain_pdf_paths
Help users understand how to specify PDF file paths correctly.
explain_translation_options
Explain available translation options and best practices.
troubleshoot_translation_error
Provide helpful guidance for common translation errors.
explain_translation_result
Explain translation results and provide next steps.
File Path Examples
The assistant supports flexible path specifications:
# Absolute paths
/Users/john/Desktop/research.pdf
C:\Users\John\Documents\paper.pdf
# Relative to home directory
Desktop/research.pdf
Documents/papers/study.pdf
# Simple filenames (assumes home directory)
paper.pdf
๐ฏ Translation Workflow
- Specify PDF Path: Use any supported path format
- Automatic Validation: File existence and format verification
- Progress Tracking: Real-time updates during translation
- Quality Assurance: Output file verification
- Result Reporting: Detailed success information with next steps
๐ Troubleshooting
Common Issues
Translation Tool Not Found
# Check if pmt is installed
pmt --version
# Install if missing
pip install pdf-math-translate-next
PDF File Not Found
- Verify file path is correct
- Use absolute paths for clarity
- Check file hasn't been moved or deleted
Translation Fails
- Ensure PDF contains selectable text (not scanned images)
- Check internet connection (required for translation)
- Try with a simpler PDF first
Error Diagnosis
The assistant provides intelligent error diagnosis with specific solutions for:
- File not found errors
- Invalid PDF files
- Translation tool issues
- Network connectivity problems
- File size limitations
๐ ๏ธ Development
Project Structure
huoshui-pdf-translator/
โโโ main.py # FastMCP server with tools, prompts, and resources
โโโ pyproject.toml # Project configuration and dependencies
โโโ manifest.json # MCP manifest
โโโ README.md # This file
โโโ uv.lock # Dependency lock file
Testing
# Run the server directly
uv run python main.py
# Check tool status
# Use MCP client to call check_translation_tool
# Test with sample PDF
# Use MCP client to call translate_pdf with test file
Development Dependencies
# Install development tools
uv sync --group dev
# Format code
black main.py
# Lint code
ruff check main.py
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
๐ License
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.
๐ Acknowledgments
- PDFMathTranslate-next: Core translation engine
- FastMCP: Framework for intelligent assistant capabilities
- Anthropic: MCP protocol and ecosystem
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huoshui_pdf_translator-0.1.0.tar.gz.
File metadata
- Download URL: huoshui_pdf_translator-0.1.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b51dedda48bbaaa2fd6226ccf11a1544eb3622f22fea73ae51bde43cc37405f
|
|
| MD5 |
a3d0d7086ef674d21e4b239705a819ab
|
|
| BLAKE2b-256 |
309396a9609b05ba81adb5f0b8ecb29fcb241898a7108337e19306ce0c271a5f
|
File details
Details for the file huoshui_pdf_translator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: huoshui_pdf_translator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3719ecf505fae16e048160f25fdca1e6c5445051428d2f024e884bb859630de5
|
|
| MD5 |
e075e0d9b8b4aa2145e7cafe63b32e52
|
|
| BLAKE2b-256 |
82195059b6791a30772739aae1506cf85ea7510683a669f04f0a6653621af4bf
|