Skip to main content
Glama

PDF2ZH — FeatherFlow MCP Server for PDF Translation

A slim MCP (Model Context Protocol) tool server that translates scientific PDF documents while preserving formulas, charts, table of contents, and layout. Designed to be launched and managed by FeatherFlow.

Based on PDFMathTranslate, stripped down to a single OpenAI-compatible translation backend — reusing the same LLM that FeatherFlow is already connected to.

Features

  • MCP stdio transport — plug-and-play with FeatherFlow (or any MCP-compatible host)

  • Preserves formulas & layout — powered by ONNX-based document layout analysis + pdfminer/pymupdf

  • Dual output — generates both mono (translated-only) and dual (bilingual side-by-side) PDFs

  • Shares FeatherFlow's LLM — OpenAI-compatible endpoint via environment variables, no extra API key needed

  • Cross-platform — works on Linux and Windows; all paths use pathlib for portability

Related MCP server: PDF2MD MCP Server

MCP Tools

Tool

Description

translate_pdf

Translate a PDF file. Accepts file, lang_in, lang_out, optional output_dir. Returns absolute paths to mono & dual PDFs.

list_supported_languages

List all supported language codes (en, zh, ja, ko, fr, de, etc.)

File Path Resolution

The file parameter of translate_pdf supports both absolute and relative paths:

  • Absolute path — used as-is (e.g. /home/user/.featherflow/workspace/paper.pdf)

  • Relative path — resolved against the workspace directory (defaults to ~/.featherflow/workspace, overridable via the WORKSPACE_DIR environment variable)

Output PDFs are written to the workspace directory by default. The returned paths are always absolute, making them directly usable by other MCP tools (e.g. feishu-mcp upload_file / upload_file_and_share).

Requirements

⚠️ Python Environment Isolation — Important

This project depends on babeldoc / onnxruntime, which require Python ≥3.10, <3.13. FeatherFlow itself may run on a different Python version (e.g. 3.13+). You must create a separate Python environment for this project and point FeatherFlow's MCP config to this project's Python executable — not FeatherFlow's own Python.

  • Python 3.10 – 3.12 (recommended: 3.12)

  • uv (recommended), Conda, or virtualenv for environment isolation

Installation

uv can automatically download and manage any Python version — no need to install Python 3.12 manually.

# Linux / macOS
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Restart your terminal after installation, then verify:

uv --version

1. Create a dedicated Python 3.12 environment

Using uv (recommended — auto-downloads Python 3.12 even if you only have 3.13+):

cd /path/to/pdftranslate-mcp
uv venv .venv --python 3.12

Activate the environment:

# Linux / macOS
source .venv/bin/activate

# Windows PowerShell
.venv\Scripts\Activate.ps1

# Windows CMD
.venv\Scripts\activate.bat

Alternative: Conda

conda create -p /path/to/pdftranslate-mcp/.venv python=3.12 -y
conda activate /path/to/pdftranslate-mcp/.venv

Alternative: venv (only if system Python is already 3.10–3.12)

python3.12 -m venv .venv
source .venv/bin/activate        # Linux/macOS
# .venv\Scripts\Activate.ps1     # Windows PowerShell

2. Install the package

pip install -e .

Or with uv (10-100x faster):

uv pip install -e .

This installs all dependencies: pymupdf, pdfminer-six, babeldoc, onnxruntime, openai, mcp, etc.

3. Verify

python -m pdf2zh.mcp_server --help

FeatherFlow Configuration

Edit ~/.featherflow/config.json (or the config file for your setup). Add pdf2zh under tools.mcpServers.

Key point: The command must point to this project's own Python executable, not FeatherFlow's Python. This project requires Python <3.13, while FeatherFlow may run on a newer version.

Example (Linux — production server)

{
  "tools": {
    "mcpServers": {
      "pdf2zh": {
        "command": "/opt/PDFMathTranslate/.venv/bin/python",
        "args": ["-m", "pdf2zh.mcp_server"],
        "toolTimeout": 600,
        "env": {
          "OPENAI_BASE_URL": "https://openrouter.ai/api/v1",
          "OPENAI_API_KEY": "sk-or-v1-xxxxxxxx",
          "OPENAI_MODEL": "anthropic/claude-opus-4-5"
        }
      }
    }
  }
}

Example (Windows — development)

{
  "tools": {
    "mcpServers": {
      "pdf2zh": {
        "command": "C:/Users/<you>/code/PDFMathTranslate/.venv/python.exe",
        "args": ["-m", "pdf2zh.mcp_server"],
        "toolTimeout": 600,
        "env": {
          "OPENAI_BASE_URL": "https://openrouter.ai/api/v1",
          "OPENAI_API_KEY": "sk-or-v1-xxxxxxxx",
          "OPENAI_MODEL": "anthropic/claude-opus-4-5"
        }
      }
    }
  }
}

Tip: On Windows, use forward slashes / in JSON paths — they work fine with Python's pathlib.

Tool Timeout — Critical for PDF Translation

⚠️ You MUST set toolTimeout for the pdf2zh MCP server.

FeatherFlow's default MCP tool timeout is 30 seconds. PDF translation is a heavy operation — a 6-page paper typically takes 1–5 minutes depending on the LLM speed. Without increasing toolTimeout, the tool call will be cancelled mid-translation, and the agent will report a failure.

Recommended: "toolTimeout": 600 (10 minutes). For very long documents (50+ pages), consider 1200 (20 minutes).

"pdf2zh": {
  "command": "...",
  "args": ["-m", "pdf2zh.mcp_server"],
  "toolTimeout": 600,
  ...
}

Environment Variables

Variable

Required

Description

OPENAI_BASE_URL

Yes

API base URL (e.g. https://openrouter.ai/api/v1, https://api.openai.com/v1)

OPENAI_API_KEY

Yes

API key for the provider

OPENAI_MODEL

Yes

Model identifier (e.g. anthropic/claude-opus-4-5, gpt-4o)

OPENAI_TEMPERATURE

No

Override LLM temperature. Omit for reasoning models (e.g. kimi-k2.5) which enforce their own temperature. Set to 0 for deterministic output with standard models.

WORKSPACE_DIR

No

Shared workspace directory. Defaults to ~/.featherflow/workspace (same as FeatherFlow's built-in file tools and paper_download). Override this if your workspace is at a non-standard location.

The OPENAI_* variables are the same credentials FeatherFlow uses — just pass them through via env. WORKSPACE_DIR usually does not need to be set; it automatically uses FeatherFlow's default workspace.

Standalone Usage (without FeatherFlow)

stdio mode (default)

python -m pdf2zh.mcp_server

SSE mode (for web-based MCP clients)

python -m pdf2zh.mcp_server --sse --host 0.0.0.0 --port 3001

Cross-MCP Workflow: pdf2zh + feishu-mcp

This project is designed to work alongside feishu-mcp. A typical end-to-end flow:

User: "Translate this paper and share it in the Feishu group"
  ↓
FeatherFlow (LLM orchestration):
  1. paper_download → ~/.featherflow/workspace/paper.pdf
  2. pdf2zh.translate_pdf(file="paper.pdf", lang_in="en", lang_out="zh")
     → ~/.featherflow/workspace/paper-mono.pdf
     → ~/.featherflow/workspace/paper-dual.pdf
  3. feishu-mcp.upload_file_and_share(file_path="/home/user/.featherflow/workspace/paper-dual.pdf")
     → share_url
  4. feishu-mcp.send_message(chat_id, share_url)

Why this works seamlessly:

  • pdf2zh writes output to ~/.featherflow/workspace by default

  • feishu-mcp upload_file / upload_file_and_share accepts absolute file paths

  • pdf2zh returns absolute paths in its result — the LLM can extract and pass them directly to feishu-mcp

  • Both MCP servers run as local processes on the same machine, sharing the same filesystem

Project Structure

pdf2zh/
  __init__.py        # Package entry, exports translate_stream
  mcp_server.py      # MCP server (entry point, tools definition)
  translator.py      # BaseTranslator + OpenAITranslator
  converter.py       # PDF content conversion & layout processing
  high_level.py      # Core translation pipeline (translate_stream)
  config.py          # Configuration & constants
  cache.py           # Translation cache (SQLite via peewee)
  doclayout.py       # ONNX document layout model loading
  pdfinterp.py       # Extended PDF interpreter
pyproject.toml       # Dependencies & build config

License

AGPL-3.0

Credits

Available Tools

2 tools
list_supported_languagesA

List language codes supported for translation.

    Returns a table of common language codes that can be used as
    lang_in or lang_out parameters.
    
ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, but description accurately states it returns a table of codes. Simple read-only tool; no further behavioral traits needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the main action, no extraneous words. Perfectly concise for a zero-parameter utility tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Low complexity tool with no parameters and an output schema. Description fully explains purpose, usage context, and relation to sibling. No gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters needed—schema is empty. Description adds value by explaining the codes' purpose (translation parameters), which is not apparent from schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the verb 'list' and resource 'language codes supported for translation'. Directly distinguishes from sibling translate_pdf by specifying that these codes are used as translation parameters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explains that the returned codes can be used as lang_in or lang_out parameters, implying the tool should be called before translation. Lacks explicit when-not-to-use guidance but sufficient given one sibling.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

translate_pdfA

Translate a PDF file while preserving formulas and layout.

    Args:
        file: Path to the input PDF file.  Absolute paths are used
              as-is; relative paths are resolved against the shared
              workspace directory (~/.featherflow/workspace by default,
              overridable via WORKSPACE_DIR env var).
        lang_in: Source language code (e.g. "en", "auto" for auto-detect).
        lang_out: Target language code (e.g. "zh", "ja", "ko", "fr", "de").
        output_dir: Directory for output files. Defaults to the shared
                    workspace directory so that other MCP tools
                    (e.g. feishu-mcp upload_file) can access the outputs.

    Returns:
        A summary with absolute paths to the mono (translated-only) and
        dual (bilingual side-by-side) output PDF files.  These paths
        can be passed directly to feishu-mcp upload_file / upload_file_and_share.

    Environment variables that control the LLM used for translation:
        OPENAI_BASE_URL – API base URL
        OPENAI_API_KEY  – API key
        OPENAI_MODEL    – Model name
    
ParametersJSON Schema
NameRequiredDescriptionDefault
fileYes
lang_inYes
lang_outYes
output_dirNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully bears the transparency burden. It discloses that the tool preserves formulas and layout, uses an LLM controlled by environment variables, returns absolute paths, and produces two output files. It does not mention any destructive actions or limitations, but it is sufficiently transparent for a translation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with an 'Args' and 'Returns' section, front-loading the main purpose. It contains several sentences but each earns its place by providing necessary context. Slight improvement could condense some details, but it is not overly verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the 4 parameters, no output schema (though description covers returns), and sibling tool presence, the description covers input handling, output paths, integration hints, and environment variables. It lacks explicit error handling or size limits, but overall it provides a complete picture for usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must add meaning. It does so by explaining path resolution logic (absolute vs relative), providing example language codes, and describing the output directory's default and purpose. This adds significant value beyond the schema's bare type definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Translate a PDF file while preserving formulas and layout.' This is a specific verb+resource combination that distinguishes it from the sibling tool 'list_supported_languages'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides context about path resolution, environment variables, and output directory integration with other MCP tools, but it does not explicitly state when to use this tool versus alternatives or when not to use it. It mentions the sibling tool's existence only through context, not in guidelines.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv1.9.11
    • First observedlist_supported_languages
    • First observedtranslate_pdf

TDQS

A4.2/5.0
Disambiguation5/5

Only two tools with clearly distinct purposes: one lists supported languages, the other translates PDFs. No overlap or ambiguity.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern: list_supported_languages and translate_pdf. No mixing of conventions.

Tool Count3/5

With only 2 tools, the server feels thin for a broader translation service, but it is scoped to a single core task. The count is borderline acceptable.

Completeness4/5

The core workflow (translating a PDF with language selection) is fully covered. Missing optional features like output format control, but no critical gaps for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lichman0405/pdftranslate-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server