PyMuPDF4LLM Enhanced MCP
基于 PyMuPDF4LLM 和 Tiktoken 的 PDF 解析与分块 MCP 服务器。
功能特性
- 🔍 PDF 转 Markdown 格式
- 📊 基于 Token 的智能分块(使用 Tiktoken o200k_base)
- 💾 SHA256 哈希缓存机制
- 🔄 可配置的块重叠
- 📡 完整 MCP 协议支持
Claude Code 配置
claude mcp add -s local pymupdf4llm-enhanced pymupdf4llm-enhanced-mcp
使用方法
parse_pdf - 解析 PDF
将 PDF 转换为 Markdown 并分块。
parse_pdf(
file_path="/path/to/document.pdf",
chunk_size_tokens=2000,
chunk_overlap_tokens=200
)
# 返回: {"chunks_count": 15, "cached": false}
read_chunk - 读取分块
从缓存读取指定分块。
read_chunk(
file_path="/path/to/document.pdf",
chunk_index=0
)
# 返回: {"chunk_index": 0, "content": "...", "file_path": "..."}
工作原理
- 计算 PDF 文件的 SHA256 哈希值
- 转换为 Markdown 并按 Token 数分块
- 缓存到
.pymupdf4llm-enhanced-mcp/目录 - 文件变更时自动重建缓存
使用场景
- 大型文档分析:处理长篇论文、技术手册
- RAG 系统:为检索增强生成准备文档块
- 批量处理:高效处理多个相同文档的查询
最佳实践
- 块大小:根据 LLM 上下文窗口设置(1000-3000 tokens)
- 重叠率:建议 10-15% 保持上下文连贯性
- 缓存管理:定期清理旧缓存释放空间
常见问题
Q: 缓存占用过大
A: 删除 .pymupdf4llm-enhanced-mcp/ 目录
Q: PDF 返回空内容 A: 检查 PDF 是否损坏或需要 OCR
相关链接
Metadata
Release files for pymupdf4llm-enhanced-mcp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymupdf4llm_enhanced_mcp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pymupdf4llm_enhanced_mcp-0.1.2-py3-none-any.whl |
Release files / pymupdf4llm_enhanced_mcp-0.1.2-py3-none-any.whl
| Download URL | pymupdf4llm_enhanced_mcp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4761c26fbd08ccf79b42cafaf109bfac4d7a487c1a5effeb35170a9cb9928c2
|
|
BLAKE2b-256 checksum How to use checksums |
edb60570429df72f580c462cee84a0c3cd7145853e8f0a1a3f01f52cfb0c0105
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.2
|
Security for pymupdf4llm-enhanced-mcp 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.