关于 Pdf(paper) Figures Extraction Mcp Serever
Figure Extractor API and MCP Server 使用 PDFFigures 2.0 从学术 PDF 中提取图表、标题、表格及相关信息,适用于研究分析和 RAG 等应用与工作流。
主要功能
- 01提取 PDF 图表与表格
- 02处理本地和远程 PDF
- 03返回结构化 JSON 结果
- 04提供提取统计信息
- 05提供 PDF 解析可视化
适用场景
- 01利用研究图表构建数据集
- 02为文献综述整理视觉材料
- 03汇编教学用图表
MCP 相关
FastMCP 服务通过 `/mcp` 端点提供 `extract_figures_from_pdf` 工具,接收 PDF URL,并以结构化 JSON 返回提取的图表和表格。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
图表提取器 API 和 MCP 服务
使用这个基于 FastAPI 的服务从 PDF 文档中提取图表和表格。图表提取器 API 和 MCP 服务为 PDFFigures 2.0 提供了简洁的 HTTP 接口。PDFFigures 2.0 是由 Allen Institute for AI 开发的强大图表提取系统。
此 API 封装便于集成到各种应用和工作流中,尤其适用于检索增强生成(RAG)应用。
由 FastMCP 驱动的 MCP 服务将 PDF 提取功能作为 MCP 工具公开。这样便可与 AI Agent 和能够自动调用提取服务的工作流无缝集成。
- 服务提供
extract_figures_from_pdf工具,可通过向/mcp端点发送 HTTP 请求来调用。此工具接收 PDF URL,处理文档,并以结构化 JSON 格式返回提取出的图表和表格。
MCP 服务的默认 URL:
http://localhost:5001/mcp
关于 PDFFigures 2.0
此 API 服务基于由 Allen Institute for AI 开发的 Scala 项目 PDFFigures 2.0 构建。PDFFigures 2.0 专为从计算机科学领域的学术文档中提取图表、说明文字、表格和章节标题而设计。相关原始研究详见其学术论文:“PDFFigures 2.0: Mining Figures from Research Papers”(Clark 和 Divvala,2016)。你可以点击此处阅读论文,并访问 PDFFigures 2.0 网站。
┌─────────────────┐ ┌──────────────────┐ ┌────────────────┐
│ Your App │ HTTP │ Figure Extractor │ JNI │ PDFFigures │
│ (Any Language) │──────► API & MCP Server│──────► 2.0 │
│ │ │ Python(FastAPI) │ │ (Scala/JVM) │
└─────────────────┘ └──────────────────┘ └────────────────┘
功能
- PDF 图表和表格提取
- 支持本地和远程 PDF 文件
- 提取出的表格和图表的统计数据
- 支持 Docker,便于部署
- PDF 解析可视化选项
FastMCP 工具
此项目现已包含一个 FastMCP 工具,可通过编程方式调用 PDF 提取服务。extract_figures_from_pdf 工具可根据 PDF URL 提取 PDF 中的图表。
使用场景
-
机器学习数据集创建 从临床试验报告和研究论文中提取视觉数据,以构建用于医学图像分析和 AI 模型的训练数据集,帮助研究人员高效汇总图表,用于训练医疗诊断领域的机器学习算法。
-
临床研究数据挖掘 自动提取医学研究文章中的图表并编目,捕捉治疗效果图、患者结局图表和实验结果示意图等关键可视化内容,为系统综述和荟萃分析提供支持。
-
学术文献综述与教育 快速汇编学术出版物中的综合视觉资料库,让研究人员和教育工作者能够创建教学资源、比较研究方法,并追踪各科学领域的视觉趋势。
Docker 部署
构建并启动提取服务:
docker build -t pdffigures2 .
docker run -d -p 5001:5001 pdffigures2
镜像大小约为 286MB,通过 Alpine 基础镜像、jlink 精简 JRE 和 pip 清理进行了优化:
| 指标 | 原始版本 | 优化后 | 变化 |
|---|---|---|---|
| 基础镜像 | slim | alpine | -70MB |
| JRE | apt | jlink | +42MB |
| pip 包 | 原始 | 已清理 | -24MB |
| 系统包 | apt | apk | -12MB |
| 镜像大小 | 452MB | 286MB | -166MB (-37%) |
测试 API
-
打开
http://localhost:5001/docs查看 API 文档。 -
使用
curl测试从 PDF URL 提取内容:curl -X POST http://localhost:5001/api/extract \ -F "pdf_url=https://example.com/sample.pdf"
Agent 技能(非 MCP)
一个调用提取服务并在本地下载渲染图表的 API 客户端。专为不支持 MCP 的 Agent 环境设计。
# Copy config and point to the server
cp .env.example .env
# (edit .env if the server is remote)
# Run extraction against a local PDF
skills/pdffigures2/scripts/pdffigures2 paper.pdf -o ./extracted/
该脚本会将 PDF POST 到 PDFFIGURES2_API_URL,下载每个渲染后的图表,并将结构化 JSON 摘要打印到 stdout。完整的面向 Agent 的文档请参阅 skills/pdffigures2/SKILL.md。
用法
从 PDF 中提取图表和表格
/api/extract 端点现在支持上传 PDF 文件和提供 PDF URL。
使用 API
你可以向 /api/extract 发送 POST 请求,并提供以下任一内容:
- 包含 PDF 的
file(multipart/form-data)。 - 包含 PDF URL 的
pdf_url(form-data)。
API 将返回包含提取出的图表和表格的 JSON 响应,其中包含完整的 renderURL 路径。
JSON 响应示例(为简洁起见,截断了 imageText):
[
{
"caption": "TABLE III CMAPSS DATASET ATTRIBUTES",
"captionBoundary": {
"x1": 113.12599182128906,
"x2": 225.1184844970703,
"y1": 116.80506896972656,
"y2": 130.57305908203125
},
"figType": "Table",
"imageText": [
"Required", "fan", "conversion", "speed", "rpm", "High-pressure", "turbines", "cool", "air", "flow",
"lbm/s", "Low-pressure", "turbines", "cool", "air", "flow", "lbm/s", "Bleed", "enthalpy", "-", "Required"
],
"name": "III",
"page": 5,
"regionBoundary": {
"x1": 46.8,
"x2": 291.12,
"y1": 140.88,
"y2": 385.91999999999996
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-TableIII-1.png"
},
{
"caption": "Fig. 3. Agentic AI implementation with Google ADK.",
"captionBoundary": {
"x1": 335.4129943847656,
"x2": 516.9002685546875,
"y1": 228.6050567626953,
"y2": 233.40704345703125
},
"figType": "Figure",
"imageText": [],
"name": "3",
"page": 5,
"regionBoundary": {
"x1": 302.88,
"x2": 549.12,
"y1": 86.88,
"y2": 216
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-Figure3-1.png"
},
{
"caption": "TABLE I COMPARISON BETWEEN AI AGENTS AND AGENTIC AI",
"captionBoundary": {
"x1": 204.9189910888672,
"x2": 390.3569641113281,
"y1": 54.10902404785156,
"y2": 67.87701416015625
},
"figType": "Table",
"imageText": [
"pert", "systems", "LLM-based", "agents,", "multi-agent", "coordination,", "intent-based", "workflows", "Task",
"Scope", "Focused", "on", "short-term,", "well-defined", "tasks", "Oriented", "toward", "long-term,", "dynamic,",
],
"name": "I",
"page": 2,
"regionBoundary": {
"x1": 51.839999999999996,
"x2": 543.12,
"y1": 77.75999999999999,
"y2": 217.92
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-TableI-1.png"
},
{
"caption": "Fig. 1. Traditional AI Agent vs. Agentic AI",
"captionBoundary": {
"x1": 224.30499267578125,
"x2": 370.9708251953125,
"y1": 448.1660461425781,
"y2": 452.968017578125
},
"figType": "Figure",
"imageText": [],
"name": "1",
"page": 2,
"regionBoundary": {
"x1": 45.839999999999996,
"x2": 549.12,
"y1": 230.88,
"y2": 436.08
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-Figure1-1.png"
},
{
"caption": "TABLE IV SUMMARY OF ENGINE MAINTENANCE ACTIONS",
"captionBoundary": {
"x1": 215.99301147460938,
"x2": 379.2913513183594,
"y1": 54.10902404785156,
"y2": 67.87701416015625
},
"figType": "Table",
"imageText": [
"#", "Engines", "RUL", "Range", "Recommended", "Action", "Priority", "Cost", "(USD)", "Labor", "Hours", "Assigned",
"Staff", "Scheduled", "Time", "15", "82–124", "MONITOR", "low", "0", "0", "[jr", "mechanic]", "Within", "7", "days"
],
"name": "IV",
"page": 7,
"regionBoundary": {
"x1": 48.96,
"x2": 549.12,
"y1": 77.75999999999999,
"y2": 135.12
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-TableIV-1.png"
},
{
"caption": "TABLE II KEY COMPONENTS OF INTENTION PROCESSING",
"captionBoundary": {
"x1": 345.09295654296875,
"x2": 507.22100830078125,
"y1": 417.8482666015625,
"y2": 431.6162414550781
},
"figType": "Table",
"imageText": [
"Targets", "Specify", "the", "resources", "or", "entities", "to", "which", "the", "intent", "applies.", "Can", "be",
"defined", "statically", "(explicit", "list)", "or", "dynamically", "(using", "filters", "or", "criteria).", "Context"
],
"name": "II",
"page": 3,
"regionBoundary": {
"x1": 302.88,
"x2": 549.12,
"y1": 441.84,
"y2": 677.04
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-TableII-1.png"
},
{
"caption": "Fig. 2. Proposed framework for Industry 5.0 applying intent-based and Agentic AI.",
"captionBoundary": {
"x1": 159.51600646972656,
"x2": 435.7596435546875,
"y1": 288.3310241699219,
"y2": 293.13299560546875
},
"figType": "Figure",
"imageText": [],
"name": "2",
"page": 4,
"regionBoundary": {
"x1": 45.839999999999996,
"x2": 549.12,
"y1": 49.68,
"y2": 276
},
"renderDpi": 300,
"renderURL": "http://localhost:5001/resources/4-Figure2-1.png"
}
]
开发环境设置
如果你想修改代码或在不使用 Docker 的情况下本地运行,请克隆此仓库:
git clone https://github.com/vlln/pdffigures-mcp-server.git
cd pdffigures-mcp-server
使用 figure_extractor.py 进行测试
figure_extractor.py 是一个 CLI 工具,用于针对正在运行的 API 服务测试提取功能。它会将本地 PDF 发送到 API,并下载提取出的图表:
# Start the server first (via Docker or uvicorn), then:
python figure_extractor.py <path-to-pdf> --output_dir ./output
选项:
--output_dir— 保存下载图表的目录(默认值:./output)--url— 自定义 API 端点(默认值:http://localhost:5001/api/extract)
应用结构
project/
├── Dockerfile # Multi-stage Alpine image (server + jlink JRE + pdffigures2 JAR)
├── .dockerignore
├── .env.example # Example config for the Agent Skill
├── app/ # FastAPI web service code
│ ├── __init__.py
│ ├── app.py # API endpoints and MCP Server
│ ├── service.py # Runs pdffigures2 JAR via subprocess
│ └── utils.py # File I/O helpers
├── skills/ # Agent Skills (non-MCP alternative)
│ └── pdffigures2/ # API client wrapper for pdffigures2
├── figure_extractor.py # CLI tool for testing extraction
└── README.md
致谢
本项目是 Huang-lab/figure-extractor 的分支。我们感谢原作者所做的工作。
许可证
本项目采用 Apache License 2.0 许可。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。