Benspdf

io.github.benbergner由 GitHub 账号 benbergner 发布v0.3.0更新于 Oct 24, 2026

Read PDFs locally: text, pages, metadata, scan detection, layout, permissions, render, OCR.

已验证STDIO仅桌面文件与存储知识与记忆

概览

AI 生成的概览

在本地读取和检查 PDF 文件——文本、页数、元数据、版面、权限、渲染和 OCR——无需上传。

可以做什么
BensPDF 通过 MCP 提供 PDF 工具:统计页数、读取文档元数据、逐页提取文本、查看页面尺寸与页面框、检查加密与打印/复制/编辑权限、将页面渲染为图片,以及对扫描件做 OCR 并可添加可搜索文本层。它还能生成临时测试 PDF、用导出工具把结果保存到磁盘,并列出或删除临时产物。新文件先放入暂存目录,以短 id 引用,其他工具可直接用该 id 代替路径。
适用场景
适合让助手回答关于本机 PDF 的问题,例如页数、内容、元数据,或判断文件是否为需要 OCR 的扫描件。也适合在决定如何处理文档前检查权限或将页面渲染为图片。
运行要求
以 stdio 本地进程运行,通过 uvx benspdf-mcp 启动,因此需要 uv(首次运行会获取合适的 Python)。OCR 需要单独安装 tesseract 系统程序,仅在调用 pdf_ocr 时检查。未声明账号、API 密钥或请求头。暂存目录默认为 ~/.benstools/work,可用 BENSTOOLS_WORKSPACE 更改。
安装前请注意
PDF 在本地读取、不会上传,但使用托管模型时你的问题仍会发送到该模型;搭配本地 Ollama 模型则完全不离开本机。export 是唯一会写入你自己文件夹的工具,discard 会立即删除临时结果。服务器启动时会清理超过 7 天的暂存文件。部分客户端支持自动批准工具,会跳过确认提示。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Benspdf,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

BensPDF

PDF tools for AI agents. Your files never leave your machine.

[PyPI] [Python versions] [License] [MCP registry]

Install in one click

[Install in VS Code]   [Install in Cursor]


Ben's PDF tools for AI agents, exposed over the Model Context Protocol (MCP).

[!NOTE] Your PDFs are read on your own machine and never uploaded. With a hosted model your questions still reach that model; pair the tools with a local Ollama model and nothing leaves the machine at all.

Works with Claude Desktop, Claude Code, VS Code, Kiro, Cursor, the ChatGPT desktop app, and any other MCP client. The one-click buttons above need uv; for every other client, or to do it by hand, see Setup.

Tools

ToolWhat it does
pdf_page_countCounts the pages in a PDF
pdf_metadataReads document properties: title, author, dates, producer
pdf_check_textSays whether a PDF is readable text or a scan that needs OCR
pdf_extract_textReads the text a PDF holds, page by page
pdf_page_layoutPage sizes, orientation, rotation and page boxes
pdf_check_accessEncryption, and what the file permits: printing, copying, editing
pdf_render_pagesRenders pages to images, so a page can be looked at
pdf_ocrReads a scan with OCR, and can add a searchable text layer to it
create_test_pdf_fileGenerates a throwaway PDF, handy for trying things out
exportSaves results to a real location on disk
list_artifactsLists recent temporary results
discardDeletes temporary results now

Every tool but one needs nothing beyond the package. pdf_ocr uses tesseract, a system program rather than a Python package, and only looks for it when you actually call it — so install it if and when you want OCR (brew install tesseract, sudo apt install tesseract-ocr, or winget install UB-Mannheim.TesseractOCR), and everything else works either way.

Where results go

When a tool makes a new PDF, it goes into a scratch folder instead of your own folders, and you get back a short id like art_a1b2c3d4.pdf. Tools accept those ids anywhere they accept a file path, so several steps can be chained together.

Results carry the artifact's path as well as its id, so you can open a rendered page or an intermediate file straight away without exporting it first.

export is the only tool that writes into your folders, so nothing shows up until you ask for it. Each time the server starts it clears out scratch files older than 7 days. Set BENSTOOLS_WORKSPACE to put the scratch folder somewhere other than ~/.benstools/work.

Setup

Install uv once, then point your client at uvx benspdf-mcp and uv fetches the package, plus a suitable Python, on first run.

bash
# macOS and Linuxcurl -LsSf https://astral.sh/uv/install.sh | sh
# Windowspowershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

On macOS, brew install uv works too.

Add the server to your client with one of the configs below, then restart the server from your client's UI. Once connected, just ask in plain language:

How many pages are in ~/Downloads/report.pdf?

Claude Desktop

Edit claude_desktop_config.json, which lives at ~/Library/Application Support/Claude/ on macOS and %APPDATA%\Claude\ on Windows. You can also open it from Settings → Developer → Edit Config.

json
{  "mcpServers": {    "benspdf": {      "command": "uvx",      "args": ["benspdf-mcp"]    }  }}

Claude Code

One command, no config file. Add --scope user to enable it everywhere rather than just the current project.

bash
claude mcp add benspdf -- uvx benspdf-mcp

Check it connected with claude mcp list.

VS Code

.vscode/mcp.json in your workspace, or the same file in your user profile. Note VS Code uses servers rather than mcpServers, and wants an explicit type.

json
{  "servers": {    "benspdf": {      "type": "stdio",      "command": "uvx",      "args": ["benspdf-mcp"]    }  }}

Kiro

.kiro/settings/mcp.json in your workspace, or ~/.kiro/settings/mcp.json to enable it everywhere. autoApprove skips the confirmation prompt for tools you trust.

json
{  "mcpServers": {    "benspdf": {      "command": "uvx",      "args": ["benspdf-mcp"],      "autoApprove": ["pdf_page_count"]    }  }}

Cursor

The button at the top does this for you. By hand, it's ~/.cursor/mcp.json to enable it everywhere, or .cursor/mcp.json in a project.

json
{  "mcpServers": {    "benspdf": {      "type": "stdio",      "command": "uvx",      "args": ["benspdf-mcp"]    }  }}

Windsurf

~/.codeium/windsurf/mcp_config.json. You can also reach it from Cascade: Settings → Cascade → Manage MCPs → View raw config, which is worth using since the path has moved between versions.

json
{  "mcpServers": {    "benspdf": {      "command": "uvx",      "args": ["benspdf-mcp"]    }  }}

Continue

~/.continue/config.yaml, or a .yaml file under .continue/mcpServers/ in a project. Continue is the one client here that doesn't take the JSON shape above: its config is YAML, and mcpServers is a list rather than an object keyed by name.

yaml
mcpServers:  - name: benspdf    command: uvx    args:      - benspdf-mcp

ChatGPT desktop app, Codex CLI, Codex IDE extension

All three are Codex clients and share one config file, ~/.codex/config.toml, so adding the server once covers all of them. Note this one is TOML, not JSON.

toml
[mcp_servers.benspdf]command = "uvx"args = ["benspdf-mcp"]

Any other MCP client

Almost every client uses the same JSON as Claude Desktop above — an mcpServers object, with command set to uvx and args to ["benspdf-mcp"]. Some want an explicit "type": "stdio"; adding it is harmless where it isn't required.

If a client just asks for a command to run, it's:

uvx benspdf-mcp

Fully offline with Ollama

The clients above keep your PDFs local, but they answer using a hosted model. Pair the tools with a local model instead and nothing leaves your machine.

You'll need Ollama with a model pulled, plus this package:

bash
pip install benspdf-mcp ollamaollama pull llama3.1

Then run the bundled CLI:

bash
benspdf-cli                        # uses the first model you havebenspdf-cli --model llama3.1       # or pick oneBENSPDF_MODEL=llama3.1 benspdf-cli # or set it once

python -m benspdf.cli does the same thing, handy from a source checkout.

You: how many pages in ~/Downloads/report.pdf?[Using tool: pdf_page_count][Result: 12 pages in report.pdf]Assistant: The PDF has 12 pages.

Reference

Each tool's own description tells your client what it does and when to use it, so in normal use there is nothing to look up. If you want the detail — every field a tool returns, and the reasoning behind the answers it gives — see the tool reference.

To work on the code, see CONTRIBUTING.md.

License

Apache 2.0

来源:README.md,提交 b446478

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分