Skip to main content

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

  1. Python 3.12+: Modern Python with async support
  2. PDFMathTranslate-next: The core translation engine
  3. 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

  1. Specify PDF Path: Use any supported path format
  2. Automatic Validation: File existence and format verification
  3. Progress Tracking: Real-time updates during translation
  4. Quality Assurance: Output file verification
  5. 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:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huoshui_pdf_translator-0.1.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

huoshui_pdf_translator-0.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

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

Hashes for huoshui_pdf_translator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b51dedda48bbaaa2fd6226ccf11a1544eb3622f22fea73ae51bde43cc37405f
MD5 a3d0d7086ef674d21e4b239705a819ab
BLAKE2b-256 309396a9609b05ba81adb5f0b8ecb29fcb241898a7108337e19306ce0c271a5f

See more details on using hashes here.

File details

Details for the file huoshui_pdf_translator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for huoshui_pdf_translator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3719ecf505fae16e048160f25fdca1e6c5445051428d2f024e884bb859630de5
MD5 e075e0d9b8b4aa2145e7cafe63b32e52
BLAKE2b-256 82195059b6791a30772739aae1506cf85ea7510683a669f04f0a6653621af4bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page