Skip to main content

MinerU MCP Server for PDF to Markdown conversion

Project description

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.0python-dotenv>=1.0.0httpx>=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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mineru_mcp_server-0.1.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mineru_mcp_server-0.1.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file mineru_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: mineru_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mineru_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 29c628dd129db6f0f32004735f0b15268b985c6ddb1fd848a82a91465172bd53
MD5 c8b9ee21d60373755e428ac06553e175
BLAKE2b-256 f983470eaba6130770f809bedec24894b85da9663d741ce88205e58c5c028d8f

See more details on using hashes here.

File details

Details for the file mineru_mcp_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mineru_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44a2bbb7fca94e7360011aa719cc45a71f9d4a92990e214e73d4cd20853821d0
MD5 71e8e9413e8470ec20e6f71b95479056
BLAKE2b-256 9bd5178a37527860ea458cd3cc37fbb401d273cb8ef1f801637cb57fba6c0cb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page