MCP server mode produces garbled Korean text (OCR fallback) while CLI works correctly on the same PDF
What happened?
When converting a Korean PDF (with embedded text layer) via MCP server mode, pdfmux produces garbled output — Korean characters are misrecognized as Chinese characters. The extraction metadata shows pymupdf4llm + rapidocr was used, indicating an unnecessary OCR fallback occurred.
The same file converted via pdfmux convert CLI produces perfect results using pymupdf4llm only, with 100% confidence.
Expected behavior
Steps to reproduce
Prepare any Korean PDF with an embedded text layer (e.g., generated by "Microsoft: Print To PDF"). Convert via CLI: pdfmux convert "path/to/korean.pdf" → Result: Clean Korean text, 100% confidence, extractor = pymupdf4llm
Convert via MCP tool call: { "tool": "convert_pdf", "arguments": { "file_path": "path/to/korean.pdf", "format": "markdown" } } → Result: Garbled text (Korean → Chinese misrecognition), extractor = pymupdf4llm + rapidocr
The quality parameter does not affect the result — both "standard" and omitted produce the same garbled output. Environment:
OS: Windows 11 pdfmux: installed via npx -y pdfmux-mcp MCP client: OpenCode PDF Creator: PDFium / Microsoft Print To PDF
Steps to reproduce
pip install pdfmuxpdfmux <file>- See error
Environment (pdfmux doctor)
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Extractor ┃ Status ┃ Version ┃ Install ┃
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ PyMuPDF │ ✓ installed │ 1.27.2.2 │ │
│ pymupdf4llm │ ✓ installed │ 1.27.2.2 │ │
│ OpenDataLoader │ ✓ installed │ — │ │
│ Docling │ ✓ installed │ — │ │
│ RapidOCR │ ✓ installed │ — │ │
│ Surya OCR │ ✗ missing │ — │ pip install pdfmux[ocr-heavy] │
│ Gemini Flash │ ✓ installed │ 1.63.0 │ │
└────────────────┴──────────────┴────────────┴───────────────────────────────┘
LLM Providers
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Provider ┃ SDK ┃ API Key ┃ Default Model ┃ Install ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ gemini │ ✓ │ ✗ │ gemini-2.5-flash │ pip install pdfmux[llm] │
│ claude │ ✓ │ ✗ │ claude-sonnet-4-6-20250514 │ pip install pdfmux[llm-claude] │
│ openai │ ✓ │ ✗ │ gpt-4o │ pip install pdfmux[llm-openai] │
│ ollama │ ✓ │ ✗ │ (requires PDFMUX_LLM_MODEL) │ pip install pdfmux[llm-ollama] │
└────────────┴──────────────┴──────────────┴─────────────────────────────┴────────────────────────────────┘
Coverage by Document Type
Digital text ███████████████████░ 95% (pymupdf)
Scanned docs ██░░░░░░░░░░░░░░░░░░ 10% (pymupdf) → add llm for 88%
Tables ████████████░░░░░░░░ 60% (pymupdf) → add docling for 92%
Image-heavy ███░░░░░░░░░░░░░░░░░ 15% (pymupdf) → add llm for 82%
Mixed content ██████████████░░░░░░ 70% (pymupdf) → add opendataloader for 85%
Handwriting ░░░░░░░░░░░░░░░░░░░░ 0% (none) → add llm for 80%
Forms ░░░░░░░░░░░░░░░░░░░░ 0% (none) → add llm for 85%
pdfmux version
1.5.0
Python version
3.14.3
Operating system
Windows
Sample PDF
No response
Root Cause Identified
The issue is that quality="standard" (the default) triggers the multi-pass pipeline: fast extract → audit → OCR re-extraction. Even when the PDF has a perfectly valid text layer, the audit step flags some pages as "bad" or "empty" and sends them to RapidOCR, which does not support Korean — resulting in Chinese character misrecognition.
Using quality="fast" bypasses the audit/OCR pipeline entirely and uses PyMuPDF only, producing correct Korean output identical to the CLI result.
Remaining issue
The CLI pdfmux convert also uses quality="standard" by default, yet it does NOT trigger the OCR fallback on the same file. This suggests the audit logic behaves differently between CLI and MCP server mode — the MCP server path appears to classify pages as needing OCR more aggressively than the CLI path, even for the same input file.
Thanks for the clean repro and the follow-up root-cause — that's genuinely helpful.
One thing doesn't add up with the "CLI quality=standard vs MCP quality=standard" framing though: both the CLI's convert command and the MCP server's convert_pdf tool call the exact same pipeline.process() function with the exact same default (quality="standard"). There's no code-path divergence inside process() itself between the two — so running the identical file through the identical function with the identical argument shouldn't produce different output.
What can differ: npx -y pdfmux-mcp resolves python3/python from PATH independently of whatever environment backs your own pdfmux CLI binary. If that resolved environment already had an older pdfmux importable, the wrapper's old install-check (isPdfmuxInstalled) accepted it as-is — it only checked "does import pdfmux succeed," never "is it at least PDFMUX_MIN_VERSION." So it's plausible the MCP path was silently running an older pdfmux with different (and in this case worse) audit/OCR-trigger behavior on non-Latin scripts, while your CLI binary was a separately-installed, newer version.
Could you check:
python3 -c "import pdfmux; print(pdfmux.__version__)"
pdfmux --version
If those two report different versions, that's almost certainly the actual cause, not a quality divergence.
Either way, I found and fixed a real bug in the wrapper regardless: it never enforced its own declared minimum version against an already-installed pdfmux. Fix is up in #45 (adds a version check + auto-upgrade path) — not yet published to npm since that's a release step, but it'll ship in the next pdfmux-mcp version. Will keep this open until you can confirm the version mismatch (or rule it out).