PDF Card MCP

io.github.velyan由 GitHub 账号 velyan 发布v0.1.2更新于 Oct 25, 2026

Local-first MCP server + CLI that turns PDFs into source-linked, card-based HTML readers.

已验证STDIO仅桌面效率与工作流文件与存储

概览

AI 生成的概览

本地优先的 MCP 服务器与命令行工具,把本地 PDF 转成可携带、带来源链接的 HTML 卡片阅读器,支持笔记、高亮与静态发布。

可以做什么
把本地 PDF 路径转换为独立 HTML 阅读器,内嵌样式、页面图像以及表格、插图、公式的裁剪图,并生成卡片、页面与警告的清单文件。用生成的阅读器校验笔记与高亮附属文件。从已有阅读器和可选注释发布只读静态 HTML 文件或目录包。可选让宿主模型挑选受限样式标记或建议卡片边界润色,同时保留原文。
适用场景
适合需要阅读、引用或检查密集文本层 PDF 的场景,希望把长文档拆成较小的带来源链接卡片,并忠实保留表格、插图和公式的图像裁剪。也适合把自建笔记与高亮导出为 Markdown,或分享只读的带注释阅读器。
运行要求
以本地 Python 进程通过 stdio 运行;推荐方式通过 uv 安装 pdf-card-mcp 包,Claude Desktop 安装包会自行管理 Python。未声明认证、环境变量或请求头。扫描版 PDF 需要可选 OCR 支持,更强的表格检测需要可选的 gmft 扩展,容器使用需挂载 PDF 与输出目录。
安装前请注意
它会读取本地 PDF 路径,并向指定路径写入 HTML、清单和打包文件。当 style_engine 或 postprocess_engine 设为 sampling 时,受限的样式提示或卡片文本片段会发送给宿主模型;若不想让文档文本离开本机,请使用 fixed 或 pdf 样式并设 postprocess_engine 为 none。发布的阅读器可能包含提取的 PDF 文本、页面图像和笔记,只发布你有权分享的内容,仅在确有需要时包含私人笔记。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

PDF Card MCP

[CI] [Source Install] [Python 3.11-3.13] [License: MIT] [MCP Registry]

PDF Card MCP is a local-first MCP server and CLI for turning dense local PDFs into portable, source-linked HTML readers. An MCP host can ask it to convert a PDF path, validate notes/highlights, or publish a static annotated reader bundle. The converter preserves source text, renders source pages for verification, crops detected tables, figures, and display formulas as images, derives safe reader styling from the original PDF palette, and writes a standalone HTML file that can be moved across devices without losing assets.

Default conversion runs locally and does not require a hosted service. Optional MCP sampling is deliberately bounded: the host model may choose validated style tokens or suggest card-boundary polish operations, but raw CSS and source-text rewrites are rejected.

The default reader is designed for comfortable reading: large type, small cards, search, section navigation, next/previous controls, keyboard navigation, a font-size slider, and source-page previews.

PDF Card MCP is meant for PDFs you actually need to read, cite, or inspect. It turns long documents into smaller source-linked cards, keeps tables/figures/formulas as faithful image crops, and lets you export your own notes and highlights as Markdown.

Quick Install (one-click)

PDF Card MCP is a Python server, so it needs a runtime. The one thing to install first is uv — it manages Python for you, so you do not have to. This is the only prerequisite for every install path below:

bash
# macOS / Linuxcurl -LsSf https://astral.sh/uv/install.sh | sh
powershell
# Windows (PowerShell)powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Then add the server with one click. The buttons run the published pdf-card-mcp package through uv:

[Add to Cursor] [Add to VS Code]

Claude Code (terminal):

bash
claude mcp add pdf-card -- uvx --from pdf-card-mcp pdf-card-mcp-server

Claude Desktop (no terminal, no prerequisites): download pdf-card-mcp-desktop.mcpb from the latest release and double-click it to install as an extension. This bundle declares the uv runtime, so Claude Desktop installs Python and dependencies for you — you do not need the uv step above for this path.

After installing, restart (or reload MCP servers in) your client so it picks up the new server.

Real Screenshots

These screenshots are from a generated reader for Agents in Software Engineering and the same source PDF opened side by side for comparison.

Quick Examples

Convert a local PDF into one portable HTML reader:

bash
pdf-card-mcp ./paper.pdf --output ./out/paper-reader.html

Use the explicit subcommand form with PDF-derived styling:

bash
pdf-card-mcp convert ./paper.pdf \  --output ./out/paper-reader.html \  --style-engine pdf

Run the MCP server so a compatible host can generate readers from local PDF paths:

bash
python -m pdf_card_mcp.server

Publish a read-only static reader with selected public annotations:

bash
pdf-card-mcp publish ./out/paper-reader.html \  --annotations ./paper.annotations.json \  --output ./published/paper-reader.html

Output At A Glance

OutputWhat it contains
paper-reader.htmlStandalone reader with embedded CSS, JavaScript, page images, and detected crops.
paper.manifest.jsonStructured metadata for cards, pages, warnings, and source anchors.
Markdown exportUser-authored notes and highlights from the reader UI.
Published bundleRead-only static HTML or a directory bundle for sharing public annotations.

Status

This is an early open-source implementation. It is useful for text-layer PDFs now, with best-effort table detection via pdfplumber, permissive raster rendering via pypdfium2, and optional richer local table detection via gmft. Scanned PDFs need optional OCR support.

Install

Most people should use the one-click install above. To install the package directly instead, from PyPI:

bash
python -m pip install pdf-card-mcp

Or install the latest unreleased changes directly from the repository:

bash
python -m pip install "pdf-card-mcp @ git+https://github.com/velyan/pdf-card-mcp.git"

For local development:

bash
git clone https://github.com/velyan/pdf-card-mcp.gitcd pdf-card-mcppython3 -m venv .venv. .venv/bin/activatepython3 -m pip install -e ".[dev]"

uv is recommended for MCPB packaging:

bash
uv syncuv run pdf-card-mcp path/to/document.pdf --output out/document.html

Install the optional local ML table detector when you want stronger table crops:

bash
uv sync --extra table-mluv run --extra table-ml pdf-card-mcp path/to/document.pdf --table-engine gmft

Use In An MCP Client

Add it to Claude Code or another CLI-compatible MCP client with uvx (requires uv):

bash
claude mcp add pdf-card -- uvx --from pdf-card-mcp pdf-card-mcp-server

Generic MCP host configuration:

json
{  "mcpServers": {    "pdf-card": {      "command": "uvx",      "args": ["--from", "pdf-card-mcp", "pdf-card-mcp-server"]    }  }}

For local development before the PyPI release, point the client at this checkout:

json
{  "mcpServers": {    "pdf-card-local": {      "command": "uv",      "args": [        "--directory",        "/path/to/pdf-card-mcp",        "run",        "python",        "-m",        "pdf_card_mcp.server"      ]    }  }}

Claude Desktop can also install the .mcpb bundle from the latest GitHub release.

Docker / Registry Scanners

The repository includes a minimal Dockerfile so registries such as Glama can build the server, start it over stdio, and inspect its MCP tool schemas. The server still works on local file paths, so container users must mount any PDFs and output directories they want the tool to read or write:

bash
docker build -t pdf-card-mcp .docker run --rm -i \  -v "$PWD/examples:/docs" \  pdf-card-mcp

CLI Usage

bash
pdf-card-mcp path/to/document.pdf --output examples/out/document.html

The command writes:

  • document.html: standalone reader with embedded CSS, JavaScript, table crops, figure crops, formula crops, and source-page images.
  • document.manifest.json: structured metadata without embedded image payloads.

The explicit subcommand form is also supported:

bash
pdf-card-mcp convert path/to/document.pdf --output examples/out/document.html

Notes, Highlights, And Static Publishing

Generated readers include a local annotation overlay:

  • A highlight is selected source text.
  • A note is selected source text plus your own typed note text.

Select text in a text card, choose Highlight or Note, and use Export Markdown to download a readable .annotations.md file. Import is intentionally not exposed in the reader UI yet. Notes and highlights are user-authored data and are kept separate from the source-derived document.manifest.json.

The lower-level CLI and MCP publishing tools still accept a structured annotation bundle when you need to build a read-only static reader with embedded annotations. Validate that bundle against a reader:

bash
pdf-card-mcp validate-annotations examples/out/document.html document.annotations.json

Publish a shareable static reader with public annotations:

bash
pdf-card-mcp publish examples/out/document.html \  --annotations document.annotations.json \  --output published/document-reader.html

If --output is a directory instead of an .html file, the command writes a static bundle:

  • index.html
  • reader.manifest.json
  • reader.annotations.json
  • bundle.json

Publishing includes only visibility: public annotations by default, redacts the local source_pdf path by default, and renders the published reader read-only by default. Use --include-private only when you intentionally want private local notes included in the published output. Publishing fails if any included annotation cannot be anchored to the reader; run validate-annotations to inspect mismatches before publishing.

MCP Tool

The MCP server is the automation layer around the same local converter. It accepts local file paths from an MCP client and returns generated reader paths, manifest metadata, warnings, and publishing/validation results.

The server exposes three tools:

text
convert_pdf_to_card_htmlvalidate_reader_annotationspublish_reader_bundle

Inputs:

  • pdf_path: local PDF path.
  • output_path: optional HTML output path.
  • title: optional title override.
  • standalone: defaults to true; asset-folder output is reserved for a later release.
  • ocr: optional OCR fallback if pytesseract is installed.
  • max_pages: optional processing limit.
  • theme: defaults to soft.
  • style_engine: fixed, pdf, or sampling; defaults to pdf. fixed preserves the original soft palette, pdf derives bounded colors and typography hints locally from the source PDF, and sampling asks the host LLM to choose validated style tokens from those local hints.
  • table_engine: auto, pdfplumber, or gmft; auto uses gmft when installed.
  • text_engine: char_geometry or pdfplumber_words; defaults to char_geometry so missing spaces are repaired from PDF character positions instead of trusting fused words.
  • postprocess_engine: none or sampling; defaults to none. When set to sampling, the MCP server asks the host LLM for boundary-only card polish operations, validates exact source-text preservation, and rewrites the generated reader. If the MCP client does not support sampling, deterministic output is returned with a warning.
  • model_cache_dir: optional cache directory for local ML table model weights.
  • offline: use only already-cached optional ML models.

validate_reader_annotations checks a notes/highlights sidecar against a generated reader. publish_reader_bundle writes a publish-ready static HTML file or directory bundle from an existing generated reader and an optional annotation sidecar.

Sampling post-processing is intentionally narrow. For card boundaries, the host LLM may suggest merges, heading extraction, or front-matter/footnote classification, but Python validation rejects any operation that rewrites, deletes, invents, or reorders source text. For style_engine=sampling, the host LLM may only choose bounded style tokens and palette candidate IDs; it cannot return raw CSS, JavaScript, or arbitrary colors. If sampling is unavailable, the reader keeps deterministic PDF-derived styling and returns a warning.

Run the server locally:

bash
python -m pdf_card_mcp.server

MCPB Packaging

This repo is arranged so the root can be packed directly:

bash
python scripts/build_mcpb.py --variant all

This builds three bundles:

  • dist/pdf-card-mcp-lite.mcpb and dist/pdf-card-mcp.mcpb declare server.type = "python" for MCP registry and Smithery directory compatibility. The full bundle additionally installs the table-ml extra. These execute through uv, so the host (or user) must provide uv.
  • dist/pdf-card-mcp-desktop.mcpb declares server.type = "uv" (from manifest.uv.json). Claude Desktop manages Python and dependencies itself, so end users can double-click to install with no prerequisites. This is the bundle linked from the one-click install section above.

No bundle vendors ML model weights; gmft downloads and caches them locally on first use unless offline=true is set with a prewarmed cache.

Privacy

Default PDF processing is local. The deterministic converter does not upload document contents or call external APIs. Optional OCR runs locally when the user has installed OCR dependencies.

When style_engine=sampling or postprocess_engine=sampling is enabled through MCP, the host LLM may receive bounded style hints or card text snippets so it can return validated style-token or boundary-operation plans. Use deterministic fixed/pdf style and postprocess_engine=none when no document-derived text should leave the local process.

Published readers may contain extracted PDF text, source-page images, table/figure/formula crops, and any included public notes or highlights. Only publish generated readers when you have the rights to share the source document content and your annotations.

How It Works

See docs/how-it-works.html for a self-contained visual explainer of the conversion pipeline, including page rendering, table/figure crops, overlap suppression, text-card merging, and standalone HTML output.

How Tables Are Handled

All detected tables are rendered as image cards. The converter uses pdfplumber to find table regions and can optionally use gmft/Table Transformer for stronger local detection. It then uses pypdfium2 to rasterize only the source table region into PNG. Captions are preserved as reader text and alt text, but the table itself remains an image so layout and numeric alignment survive conversion.

If a document mentions tables but no reliable table regions are found, the manifest includes a warning so callers can decide whether to inspect the source pages.

How Formulas Are Handled

Display formulas are treated as image cards when the PDF exposes them as centered, formula-like text blocks. The extracted formula string is retained for alt/search metadata, but the reader shows the source crop so subscripts, superscripts, arrows, and math spacing remain faithful.

License

MIT

来源:README.md,提交 470a16e

工具

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

版本历史

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

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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