MCP server for converting PDF files to PNG images with paper download capabilities
Project description
PDF to PNG Converter MCP
一個 MCP (Model Context Protocol) 服務器,讓 Claude Code 能夠:
- 將 PDF 檔案轉換為高品質 PNG 圖片(支援最高 1200 DPI)
- 從網路下載學術論文 PDF
- 根據期刊名稱和論文標題自動建立資料夾結構
- 下載論文後自動轉換為 PNG
功能特色
- 高品質轉換:支援 72-2400 DPI,預設 1200 DPI
- 批次處理:一次轉換整個資料夾的 PDF 檔案
- 自動整理:根據期刊和標題自動建立資料夾結構
- 多平台支援:Windows、macOS、Linux
- GUI 介面:提供獨立的圖形化介面(可選)
系統需求
- Python 3.10 或更高版本
- Poppler(用於 PDF 處理)
安裝 Poppler
Windows:
- 下載 Poppler for Windows
- 解壓縮到任意位置(例如
C:\poppler) - 將
bin資料夾加入系統 PATH(例如C:\poppler\bin)
macOS:
brew install poppler
Linux (Ubuntu/Debian):
sudo apt install poppler-utils
Claude Code Plugin 安裝
你可以直接從 marketplace 安裝為 Claude Code Plugin:
# Step 1: 加入 marketplace
/plugin marketplace add LostSunset/pdf_to_png_converter_mcp
# Step 2: 安裝 plugin
/plugin install pdf-to-png@pdf-to-png-marketplace
安裝後可使用的 Skills:
/pdf-to-png:convert-pdf— 將 PDF 轉換為 PNG/pdf-to-png:download-paper— 下載學術論文/pdf-to-png:search-paper— 搜尋 Semantic Scholar
快速安裝(推薦)
發布到 PyPI 後,只需一行指令即可在 Claude Code 中添加此 MCP:
# 使用 uvx(推薦)
claude mcp add pdf-to-png -- uvx pdf-to-png-converter-mcp
# 或使用 pipx
claude mcp add pdf-to-png -- pipx run pdf-to-png-converter-mcp
從源碼安裝
方法一:使用 uv(推薦)
# 克隆專案
git clone https://github.com/LostSunset/pdf_to_png_converter_mcp.git
cd pdf_to_png_converter_mcp
# 使用 uv 建立虛擬環境並安裝
uv venv .venv --python 3.12
uv pip install -e .
方法二:使用 pip
# 克隆專案
git clone https://github.com/LostSunset/pdf_to_png_converter_mcp.git
cd pdf_to_png_converter_mcp
# 建立虛擬環境並安裝
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# 或
.venv\Scripts\activate # Windows
pip install -e .
在 Claude Code 中使用
設定 MCP 服務器
編輯 Claude Code 的設定檔(位於 ~/.claude/settings.json 或專案目錄下的 .claude/settings.json):
{
"mcpServers": {
"pdf-to-png": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/pdf_to_png_converter_mcp",
"pdf-to-png-mcp"
]
}
}
}
或使用 Python 直接執行:
{
"mcpServers": {
"pdf-to-png": {
"command": "/path/to/pdf_to_png_converter_mcp/.venv314/Scripts/python.exe",
"args": [
"-m",
"pdf_to_png_converter_mcp.server"
]
}
}
}
可用工具
安裝並設定完成後,Claude Code 將可以使用以下工具:
1. convert_pdf_to_png
將單個 PDF 檔案轉換為 PNG 圖片。
參數:
- pdf_path (必填): PDF 檔案的完整路徑
- dpi (選填): 輸出解析度,預設 1200
- output_dir (選填): 輸出目錄,預設與 PDF 同目錄
2. download_paper
從網路下載學術論文 PDF。
參數:
- url (必填): 論文 PDF 的下載網址
- journal (必填): 期刊名稱(用於建立資料夾)
- title (必填): 論文標題(用於命名檔案和資料夾)
- base_dir (選填): 基礎目錄,預設為當前目錄
3. download_and_convert
下載論文 PDF 並自動轉換為 PNG 圖片。
參數:
- url (必填): 論文 PDF 的下載網址
- journal (必填): 期刊名稱
- title (必填): 論文標題
- base_dir (選填): 基礎目錄
- dpi (選填): 輸出解析度,預設 1200
4. batch_convert_pdfs
批次轉換資料夾中的所有 PDF 檔案。
參數:
- folder_path (必填): 包含 PDF 檔案的資料夾路徑
- dpi (選填): 輸出解析度,預設 1200
- recursive (選填): 是否遞迴搜尋子資料夾,預設 True
5. search_paper
搜尋學術論文(使用 Semantic Scholar API)。
參數:
- query (必填): 搜尋關鍵字
- max_results (選填): 最大結果數量,預設 5,最大 20
使用範例
在 Claude Code 中,你可以這樣使用:
請幫我把 C:\Papers\paper.pdf 轉換成 PNG,使用 1200 DPI
請下載這篇論文並轉換成 PNG:
URL: https://example.com/paper.pdf
期刊: Nature
標題: Deep Learning for Image Recognition
請把 D:\Research\Papers 資料夾中的所有 PDF 都轉換成 PNG
GUI 介面
除了 MCP 服務器,本專案也提供獨立的 GUI 介面:
# 安裝 GUI 依賴
uv pip install -e ".[gui]" --python .venv314/Scripts/python.exe
# 啟動 GUI
pdf-to-png-gui
開發
安裝開發依賴
uv pip install -e ".[dev]" --python .venv314/Scripts/python.exe
執行測試
# 設定 UTF-8 編碼
set PYTHONIOENCODING=utf-8 # Windows
export PYTHONIOENCODING=utf-8 # macOS/Linux
# 執行測試
pytest
程式碼檢查
# 檢查並自動修復
ruff check --fix
ruff format
版本歷史
請參閱 CHANGELOG.md
授權
本專案採用 MIT 授權條款 - 詳見 LICENSE 檔案
Star History
Version: 0.2.1
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf_to_png_converter_mcp-0.2.1.tar.gz.
File metadata
- Download URL: pdf_to_png_converter_mcp-0.2.1.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e33233d402f553806b194b1c8f2ad0b8ed803e8fe9dfa95b134866b0e920161
|
|
| MD5 |
df6af2ceb207da26d300c3955738e4a0
|
|
| BLAKE2b-256 |
0791a7aa87e415a287eacbc9f10a8acc6c9877dcf982fe715ed6db09938b0285
|
Provenance
The following attestation bundles were made for pdf_to_png_converter_mcp-0.2.1.tar.gz:
Publisher:
publish.yml on LostSunset/pdf_to_png_converter_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_to_png_converter_mcp-0.2.1.tar.gz -
Subject digest:
3e33233d402f553806b194b1c8f2ad0b8ed803e8fe9dfa95b134866b0e920161 - Sigstore transparency entry: 990999521
- Sigstore integration time:
-
Permalink:
LostSunset/pdf_to_png_converter_mcp@7126e914e2848388df3f7bccdb33f559f7acbe76 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/LostSunset
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7126e914e2848388df3f7bccdb33f559f7acbe76 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pdf_to_png_converter_mcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pdf_to_png_converter_mcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1632ef8528c98f9d9b6d1109ec75944ac5dad15b4676fd9baf27aebb52ca1faf
|
|
| MD5 |
b33410ab40c5b9e53914a5b93e22539c
|
|
| BLAKE2b-256 |
68d0ba76fc4facc0a898caf24f663e0870348e6023be24c84ae96d79b332f3e7
|
Provenance
The following attestation bundles were made for pdf_to_png_converter_mcp-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on LostSunset/pdf_to_png_converter_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_to_png_converter_mcp-0.2.1-py3-none-any.whl -
Subject digest:
1632ef8528c98f9d9b6d1109ec75944ac5dad15b4676fd9baf27aebb52ca1faf - Sigstore transparency entry: 990999572
- Sigstore integration time:
-
Permalink:
LostSunset/pdf_to_png_converter_mcp@7126e914e2848388df3f7bccdb33f559f7acbe76 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/LostSunset
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7126e914e2848388df3f7bccdb33f559f7acbe76 -
Trigger Event:
release
-
Statement type: