PDF Memo MCP Server
Enables safe interaction with PDFs, including listing files, extracting highlights with exact text, reading annotations and page text, and viewing metadata, all restricted to configured directories.
README
PDF Memo MCP Server
A Model Context Protocol (MCP) server that lets Claude (or any MCP client) work with your PDFs safely. It can list PDFs, extract highlights with their exact text, return raw notes/annotations, read specific pages, and show metadata—all strictly limited to the directories you allow.
Features
- Annotation extraction: parse PDF annotations with sensible filtering (e.g., include
Highlight, Textby default; ignore noisyLink/Popupunless requested). - Highlight→text mapping: map highlight quads/rects to the underlying page text.
- Flexible page ranges:
first,last,N,S-E, or omit for all. - Metadata: title, author, subject, creator/producer, creation/mod dates.
- Configurable directories: allow multiple roots via positional args or repeated
--allow-dir. - Safety: access limited to allowed directories, file size/extension checks.
Requirements
- Python 3.10+ (3.11 recommended)
pip install -r requirements.txt
PyPDF2>=3.0.0,<4
pdfplumber>=0.11.0,<0.12
mcp>=0.4.0
Installation
# 1) Clone this repo
# Windows PowerShell / macOS / Linux
cd <your-workspace>
git clone <this-repo-url> pdf-memo-mcp
cd pdf-memo-mcp
# 2) (Optional) Create a virtualenv
python -m venv .venv
# Windows
. .venv\Scripts\Activate.ps1
# macOS/Linux
source .venv/bin/activate
# 3) Install dependencies
pip install -r requirements.txt
Running the server
You can pass allowed directories either as positional args or with --allow-dir (repeatable). If you pass none, the server falls back to defaults: ~/Downloads, ~/Desktop, ~/Documents, and the current working directory.
# Example: two directories (mixed platforms shown for clarity)
python main.py ~/Downloads C:\\Temp
# Same via explicit flags (repeatable)
python main.py --allow-dir ~/Downloads --allow-dir C:\\Temp
# Optional tuning
python main.py ~/Downloads --max-file-size 52428800 --log-level DEBUG
Tip (Windows): If you run into import issues while developing, ensure your repo root is on
PYTHONPATH, e.g.set PYTHONPATH=C:\\mcp-servers\\pdf-memo-mcp.
Claude Desktop integration
Create or update your claude_desktop_config.json to register this MCP server. Below is a minimal example.
{
"mcpServers": {
"pdf-memo": {
"command": "C:/Users/yong/AppData/Local/Programs/Python/Python311/python.exe",
"args": [
"C:/mcp-servers/pdf-memo-mcp/main.py",
"~/Downloads",
"C:/Temp"
],
"env": {
"PYTHONPATH": "C:/mcp-servers/pdf-memo-mcp"
}
}
}
}
macOS/Linux variant:
{
"mcpServers": {
"pdf-memo": {
"command": "/usr/bin/python3",
"args": [
"/Users/you/mcp-servers/pdf-memo-mcp/main.py",
"~/Downloads",
"/Users/you/PDFs"
],
"env": {
"PYTHONPATH": "/Users/you/mcp-servers/pdf-memo-mcp"
}
}
}
}
Notes
- The server communicates over STDIO; Claude Desktop will handle transport automatically.
- You can add/remove directories later by editing
argsand restarting Claude Desktop.
Available tools (names & typical usage)
-
extract_annotations(file_path, page_range=None, include_types="Highlight,Text", drop_empty=True)Return raw annotations as JSON. Useinclude_typesto includeLink, Popupif you really need them. -
extract_highlights_with_context(file_path, page_range=None, drop_empty=True)Return a JSON array of highlight contexts:{page, author, highlighted_text, note, position}. -
read_pdf_text(file_path, page_range=None)Return JSON withextracted_pages(page text & char counts) and basicmetadata. -
list_pdf_files(directory="all")Human‑readable list of PDFs under allowed directories.directoryfilters by basename substring. -
show_accessible_directories()JSON withaccessible_directories,directory_count,max_file_size_mb,allowed_extensions.
Page range examples
"first"→ first page"last"→ last page"3"→ page 3"10-20"→ pages 10 through 20 (inclusive)- omit the argument → all pages
Quick start in Claude
Ask natural-language prompts like:
- “List the PDFs you can see under C:\Temp.” →
list_pdf_files - “What annotations are on page 162 of ‘Foo.pdf’?” →
extract_annotationswithpage_range: "162" - “Show me the highlighted text for page 162.” →
extract_highlights_with_contextwithpage_range: "162" - “Read the first page text and metadata.” →
read_pdf_textwithpage_range: "first"
Troubleshooting
-
ModuleNotFoundError: No module named 'pdf_memo'Ensure your repo root is onPYTHONPATH(see examples above) or runmain.pyfrom the repo root. This repo also injectssys.pathinmain.pyfor convenience. -
No highlights found
extract_highlights_with_contextonly returns Highlight annotations. If your file only has links/popups, useextract_annotationsand adjustinclude_types. -
Jumbled text in highlights The mapper prefers
QuadPointswhen present and falls back toRect. It first trieswithin_bbox().extract_text()and then a (y,x) word grouping heuristic. Some PDFs with complex layouts may still need tuning.
License
MIT License
Copyright (c) 2025 Yong Choi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。