Skip to content

feat: Support unlock pro #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ Configure your cursor/windsurf/... and other MCP client to this server:
}
}
```

Set `PYMUPDF_PRO_PASSWORD` environment variable to enable pro features: parse DOC/DOCX, XLS/XLSX, PPT/PPTX, HWP/HWPX and more.
12 changes: 12 additions & 0 deletions pymupdf4llm_mcp/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import os
from pathlib import Path
from typing import Annotated, Any

import pymupdf4llm
from mcp.server.fastmcp import FastMCP
from pydantic import Field

PRO_UNLOCKED = False
if pymupdf_pro_password := os.getenv("PYMUPDF_PRO_PASSWORD"):
import pymupdf.pro

pymupdf.pro.unlock(pymupdf_pro_password)
# FIXME: Detect unlock failure
PRO_UNLOCKED = True

mcp = FastMCP("pymupdf4llm-mcp")


Expand All @@ -16,6 +25,9 @@
"This tool will also convert the PDF to images and save them in the `image_path` directory. "
"For larger PDF files, use `save_path` to save the markdown file then read it partially. "
)
+ "\n**This tool now supports DOC/DOCX, XLS/XLSX, PPT/PPTX, HWP/HWPX as PRO version.**"
if PRO_UNLOCKED
else ""
)
def convert_pdf_to_markdown(
file_path: Annotated[str, Field(description="Absolute path to the PDF file to convert")],
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies = [
"mcp[cli]>=1.6.0",
"pydantic>=2.11.3",
"pymupdf4llm>=0.0.21",
"pymupdfpro>=1.25.5",
"typer>=0.15.2",
]

Expand Down
Loading