Skip to main content

MinerU MCP Server

基于 FastMCP 3.x 的 MCP 服务器,将 MinerU 的文档转 Markdown API 暴露为 MCP 工具。

支持 PDF、Word、PPT 及图片格式(JPG、PNG)的解析。

工具

工具 说明
parse_documents 将文件转换为 Markdown(支持本地路径和 URL,可批量处理)
get_ocr_languages 获取 OCR 支持的语言列表

安装

pip install mineru-mcp-server

从源码安装:

git clone https://github.com/Tongzhao9417/mineru_mcp.git
cd mineru_mcp
pip install -e .

核心依赖仅 3 个:fastmcp>=3.0.0、python-dotenv>=1.0.0、httpx>=0.24.0

环境变量

在项目根目录创建 .env 文件(参考 .env.example),或直接设置环境变量:

变量 说明 默认值
MINERU_API_KEY MinerU API 密钥(官网申请) 必填
MINERU_API_BASE 远程 API 基础 URL https://mineru.net
OUTPUT_DIR 转换结果保存路径 ./downloads
USE_LOCAL_API 是否使用本地 API false
LOCAL_MINERU_API_BASE 本地 API 地址(USE_LOCAL_API=true 时生效) http://localhost:8080

MCP 客户端配置

Claude Code / Claude Desktop

{
  "mcpServers": {
    "mineru-mcp": {
      "command": "mineru-mcp-server",
      "env": {
        "MINERU_API_KEY": "your-api-key"
      }
    }
  }
}

从源码运行

{
  "mcpServers": {
    "mineru-mcp": {
      "command": "uv",
      "args": ["--directory", "/path/to/mineru_mcp", "run", "mineru-mcp-server"],
      "env": {
        "MINERU_API_KEY": "your-api-key"
      }
    }
  }
}

直接运行

# stdio 模式(默认,MCP 客户端自动管理)
mineru-mcp-server

# HTTP 模式(独立服务,多客户端可连接)
mineru-mcp-server --transport streamable-http --port 8001

推荐使用 streamable-http 传输模式(MCP 规范推荐),SSE 已被标记为 deprecated。

parse_documents 参数

参数 类型 说明 默认值
file_sources string 文件路径或 URL,多个用逗号分隔 必填
enable_ocr bool 启用 OCR false
language string 文档语言(ch/en 等) ch
page_ranges string 页码范围,如 "2,4-6"(仅远程 API) None

常见问题

API 返回 401:检查 MINERU_API_KEY 是否正确设置。

找不到文件:请使用绝对路径。

调用超时:大文档处理耗时较长,建议分批处理或使用本地 API 模式。

License

MIT

Metadata

Release files for mineru-mcp-server 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mineru-mcp-server 0.1.0
File Size Uploaded Provenance Actions
mineru_mcp_server-0.1.0.tar.gz 20.8 kB Without provenance Details for mineru_mcp_server-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mineru-mcp-server 0.1.0
File Interpreter ABI Platform Actions
mineru_mcp_server-0.1.0-py3-none-any.whl Python 3 none any Details for mineru_mcp_server-0.1.0-py3-none-any.whl

Total release size: 43.9 kB

Release files / mineru_mcp_server-0.1.0.tar.gz

Download URL mineru_mcp_server-0.1.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29c628dd129db6f0f32004735f0b15268b985c6ddb1fd848a82a91465172bd53
BLAKE2b-256 checksum
How to use checksums
f983470eaba6130770f809bedec24894b85da9663d741ce88205e58c5c028d8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / mineru_mcp_server-0.1.0-py3-none-any.whl

Download URL mineru_mcp_server-0.1.0-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44a2bbb7fca94e7360011aa719cc45a71f9d4a92990e214e73d4cd20853821d0
BLAKE2b-256 checksum
How to use checksums
9bd5178a37527860ea458cd3cc37fbb401d273cb8ef1f801637cb57fba6c0cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for mineru-mcp-server 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page