paper-extraction-MCP
Enables structured information extraction from academic PDFs using LLMs, integrating with Claude Desktop for natural language querying and batch processing.
README
Paper Extraction MCP
An MCP (Model Context Protocol) server for structured information extraction from academic PDF papers using LLM. It integrates seamlessly with Claude Desktop, allowing you to extract metadata and domain-specific content categories from research papers through natural language conversation.
Typhoon disaster governance is provided as a built-in example. The system is fully customizable for any research domain — see Adapting to Other Domains.
Features
- LLM-Powered Extraction — Uses OpenAI-compatible LLMs to extract structured data from full-text PDFs
- Customizable Schema — Define your own metadata fields and content categories via
config.json - Smart Chunking — Automatically splits long papers and merges results with deduplication
- Dual Output — JSON and CSV formats for downstream analysis
- MCP Protocol — Works directly inside Claude Desktop as a tool server
- Batch Processing — Extract from a single paper or all papers at once
Quick Start
1. Install Dependencies
pip install -r requirements.txt
2. Configure API Key
Copy the template and fill in your API key:
cp config.json.template config.json
Edit config.json:
{
"llm_config": {
"api_key": "sk-your-api-key-here",
"api_base": "https://api.openai.com/v1",
"model": "gpt-4o"
}
}
Any OpenAI-compatible API is supported (OpenAI, Azure OpenAI, local LLMs with OpenAI-compatible endpoints, third-party proxies, etc.).
3. Add PDF Papers
Place your PDF files in the papers/ directory.
4. Configure Claude Desktop
Edit the Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add:
{
"mcpServers": {
"paper-extraction": {
"command": "python",
"args": ["<full-path-to>/paper-extraction-MCP/server.py"],
"cwd": "<full-path-to>/paper-extraction-MCP"
}
}
}
Replace <full-path-to> with your actual path. Then restart Claude Desktop.
5. Use It
In Claude Desktop, simply say:
List the PDF papers available for extraction.
Extract the paper "my_paper.pdf".
Extract all papers and show me a summary.
MCP Tools
| Tool | Description |
|---|---|
list_papers |
List all PDF files in the papers/ directory |
extract_paper |
Extract metadata + categories from a single PDF |
extract_all_papers |
Batch extract all PDFs |
get_extraction_result |
Retrieve a previously extracted result (JSON) |
Project Structure
paper-extraction-MCP/
├── server.py # MCP server (entry point)
├── pdf_extractor.py # Core extraction logic
├── config.json # Your configuration (gitignored)
├── config.json.template # Configuration template
├── requirements.txt # Python dependencies
├── papers/ # Place PDF files here
├── outputs/
│ ├── json/ # JSON extraction results
│ └── csv/ # CSV extraction results
├── setup.bat # Windows quick setup
├── setup.sh # macOS/Linux quick setup
├── CLAUDE_SETUP.md # Detailed Claude Desktop setup guide
├── LICENSE # MIT License
└── README.md
How It Works
PDF file
│
▼
pdfplumber (text extraction)
│
▼
Full text ──► LLM API call ──► Structured JSON
│
config.json defines:
- extraction_prompt (fields & rules)
- llm_config (model, temperature)
│
▼
JSON + CSV output
- Text Extraction:
pdfplumberextracts full text from each PDF page - LLM Extraction: The text is sent to an LLM with your
extraction_prompt, which defines what fields to extract and how - Smart Chunking: If the text exceeds ~100K characters, it is automatically split into chunks, extracted separately, and merged with deduplication
- Output: Results are saved as JSON and CSV
Built-in Example: Typhoon Disaster Governance
The default config.json is pre-configured for extracting information from typhoon disaster governance papers:
Metadata fields (5):
- DOI, Title, Journal, Author Affiliations, Publication Date
Content categories (7):
| Category | Description |
|---|---|
| Detection & Early Warning | Monitoring, forecasting, alert systems |
| Engineering Protection | Seawalls, drainage, building reinforcement |
| Emergency Response | Evacuation, shelters, rescue operations |
| Post-disaster Recovery | Reconstruction, ecological restoration |
| Policy & Management | Regulations, institutional coordination |
| Digital Technology | AI, big data, remote sensing, GIS, IoT |
| Other Measures | Community-based, education, insurance |
Adapting to Other Domains
The core of this tool is domain-agnostic. You only need to modify config.json — no code changes required. Here is a step-by-step guide:
Step 1: Define Your Categories
Decide what information you want to extract. For example:
| Domain | Possible Categories |
|---|---|
| Climate Change Adaptation | Mitigation measures, Adaptation strategies, Carbon reduction technologies, Policy instruments, Financial mechanisms |
| Urban Planning | Land use strategies, Transportation planning, Green infrastructure, Zoning regulations, Community engagement |
| Public Health | Prevention measures, Treatment protocols, Surveillance systems, Policy interventions, Technology applications |
| Cybersecurity | Threat detection, Prevention measures, Incident response, Recovery procedures, Governance frameworks |
| Supply Chain | Risk identification, Mitigation strategies, Resilience measures, Technology solutions, Regulatory compliance |
Step 2: Write Your Extraction Prompt
Edit the extraction_prompt field in config.json. The prompt should:
- Describe the assistant's role for your domain
- List metadata fields (DOI, title, journal, etc. — usually the same across domains)
- Define each content category with clear descriptions and examples
- Set extraction rules (no hallucination, preserve original text, deduplication)
- Specify the output JSON format with exact key names
Here is a template you can adapt:
{
"extraction_prompt": [
"You are an academic information extraction assistant specialized in [YOUR DOMAIN].",
"",
"From each paper, extract:",
"1) Bibliographic metadata",
"2) Domain-specific content, categorized as follows:",
"",
"METADATA FIELDS:",
"- 论文DOI: Full DOI URL",
"- 题目: Paper title",
"- 期刊名称: Journal name",
"- 作者机构: Author affiliations (semicolon-separated)",
"- 发表日期: Publication date (Month Year)",
"",
"CONTENT CATEGORIES:",
"- [Category1_Key]: [Description of what to extract]",
"- [Category2_Key]: [Description of what to extract]",
"- ... (add as many as needed)",
"",
"RULES:",
"- Only extract content explicitly present in the paper",
"- Preserve original text, do not summarize",
"- Output as JSON with metadata as strings, categories as arrays of strings"
]
}
Step 3: Update the Field Mapping in pdf_extractor.py
If you change the Chinese key names in your extraction prompt (e.g., use "预防措施" instead of "检测预警措施"), update the _format_result() and _merge_chunk_results() methods in pdf_extractor.py to map your new keys to the internal field names.
For example, if your domain is public health:
# In _format_result():
final_result = {
# ... metadata fields stay the same ...
"prevention_measures": self._join_measures(result_data.get("预防措施", [])),
"treatment_measures": self._join_measures(result_data.get("治疗措施", [])),
"surveillance_measures": self._join_measures(result_data.get("监测措施", [])),
# ... add your categories ...
}
Step 4: Update server.py Display (Optional)
If you want the MCP tool output to show your custom category names, update the call_tool() function in server.py where it formats the extraction result display.
Tips for Writing Good Extraction Prompts
- Be specific: Provide concrete examples of what belongs in each category
- Set boundaries: Clearly state what does NOT belong in each category to avoid overlap
- Request detail: Ask for full paragraphs, not just keywords — this prevents information loss
- Use the paper's language: Tell the LLM to preserve the original language (Chinese/English)
- Test iteratively: Try your prompt on 2-3 papers, review the results, and refine
Configuration Reference
config.json
| Field | Type | Description |
|---|---|---|
papers_dir |
string | Directory containing PDF files (default: "papers") |
output_dir |
string | Output directory (default: "outputs") |
extraction_prompt |
string or string[] | The LLM prompt defining extraction fields and rules |
llm_config.enabled |
bool | Enable/disable LLM extraction |
llm_config.provider |
string | LLM provider (currently "openai") |
llm_config.model |
string | Model name (e.g., "gpt-4o", "gpt-4-turbo") |
llm_config.api_key |
string | Your API key |
llm_config.api_base |
string | API base URL |
llm_config.temperature |
number | Generation temperature (0 = deterministic) |
Recommended Models
| Model | Speed | Quality | Cost |
|---|---|---|---|
gpt-4o |
Fast | High | Medium |
gpt-4-turbo |
Medium | Highest | High |
gpt-3.5-turbo |
Fastest | Good | Low |
Any OpenAI-compatible model works (DeepSeek, Qwen, local Ollama, etc.).
Cost Estimate
Using GPT-4o:
- Single paper (~10 pages): ~$0.04-0.07
- 100 papers: ~$4-7
Troubleshooting
| Problem | Solution |
|---|---|
| MCP server not visible in Claude | Check config path, restart Claude Desktop |
| API call fails | Verify API key, check network, check account balance |
| Empty extraction | Ensure PDF is text-based (not scanned images) |
| Incomplete results | Paper may be too long — chunking handles this automatically |
See CLAUDE_SETUP.md for a detailed setup and troubleshooting guide.
License
If this project helps your research, please give it a star!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。