DP

diyaluo/pdf-extract-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

0 stars 0 forks 质量 83 趋势 14MIT

MCP服务器:从数字PDF发票/银行对账单中提取表格,转为带有PII编辑的CSV/JSON/Excel表格

概览

一个模型上下文协议(MCP)服务器,能够自动将表格和文本——如银行对账单、发票、账单——提取到中。 是发票提取器产品的一部分。该软件包是MCP分发渠道(“生态系统寄生”:一个后端,多个主机工作流)。网页演示存在于父项目中。 - extract_pdf — 上传数字PDF(base64或URL),返回结构化表行,格式为CSV / JSON记录 / XLSX。- 健康 — 服务状态和免费层限制。 每页尝试三种策略:带条的表→基于头部行自身 x 位置的显式列(处理无网格线的报表 PDF,西方银行常见情况)→通用文本对齐。 那些模糊的银行标识符(如路由/账户/排序代码)会被遮蔽,因此参考编号和金额保持可读性。金额、日期和描述从不被更改。

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,用于从中提取表和文本 数字(文本层)PDF——银行对账单、发票、账单——转为 CSV / JSON / Excel,并自动删除PII。

发票提取器产品的一部分。这个包是MCP 分发渠道(“生态系统寄生”:一个后端,多个主机) 工作流程)。网页演示存在于父项目中。

它的作用

  • extract_pdf — 上传数字PDF(base64或URL),返回结构化 表格行以 CSV / JSON 记录 / XLSX 形式表示。
  • health — 服务状态和免费套餐限制。

表检测每页尝试三种策略:带规则表→显式表 从头部行自身的 x 位置派生的列(处理语句 PDF 没有网格线,西方银行常见的情况))→通用文本 阵营。

PII编辑(默认开启)涵盖:

地区 蒙面
美国 / 国际 SSN、EIN/TIN、IBAN、SWIFT/BIC、路由/ABA、账户号码、卡号(普通和 4111 1111 1111 1111/虚线)、美国及国际电话、电子邮件

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

pdf-extract-mcp

A Model Context Protocol (MCP) server that extracts tables and text from digital (text-layer) PDFs — bank statements, invoices, bills — into CSV / JSON / Excel, with automatic PII redaction.

Part of the invoice-extractor product. This package is the MCP distribution channel (“ecosystem parasite”: one backend, many host workflows). Web demo lives in the parent project.

What it does

  • extract_pdf — upload a digital PDF (base64 or URL), get back structured table rows as CSV / JSON records / XLSX.
  • health — service status and free-tier limits.

Table detection tries three strategies per page: ruled tables → explicit columns derived from the header row’s own x-positions (handles statement PDFs with no grid lines, the common case for Western banks) → generic text alignment.

PII redaction (on by default) covers:

Region Masked
US / international SSN, EIN/TIN, IBAN, SWIFT/BIC, routing/ABA, account numbers, card numbers (plain and 4111 1111 1111 1111 / dashed), US & international phone, email
China 18/15-digit national ID, mobile phone, bank card, USCC (统一社会信用代码), passport, 2–3 char personal names, organization keywords

Bank identifiers that are ambiguous as bare numbers (routing/account/sort code) are masked only when they follow a label, so reference numbers and amounts stay readable. Amounts, dates and descriptions are never altered.

Scanned / image-only PDFs are explicitly rejected (SCANNED_PDF_UNSUPPORTED) — the free tier covers digital PDFs only (OCR is a paid-tier candidate).

Limits (free tier)

  • 100 pages / rolling 30 days / client (anonymous, keyed by client hash).
  • 50 MB per file.
  • Above quota the tool returns a structured QUOTA_EXCEEDED response with an in-band upgrade pointer. It never silently bills.
  • Set PDF_EXTRACT_API_KEY to a paid key to bypass the quota (billing gateway is a P1 item; current free tier has no paid keys issued).

Run (local stdio — Claude Desktop / Cursor / any MCP client)

pip install -e .
pdf-extract-mcp

Client config example:

{
  "mcpServers": {
    "pdf-extract": {
      "command": "pdf-extract-mcp",
      "env": {}
    }
  }
}

Run (remote streamable-http, for hosted MCP clients)

REMOTE_TRANSPORT=http MCP_HOST=127.0.0.1 MCP_PORT=5060 \
  python -m pdf_extract_mcp.server
# POST JSON-RPC to http://127.0.0.1:5061/mcp

Tool schema

extract_pdf(
  pdf_base64: str | None,     # preferred: PDF bytes as base64
  pdf_url:    str | None,     # alternative: direct https .pdf URL
  output:     "csv"|"json"|"xlsx",   # default csv
  redact_pii: bool = true,
  api_key:    str | None,    # paid key, optional
) -> {
  ok, type: "tables"|"text", pages, tables, rows, columns,
  csv | rows_json | xlsx_base64,   # depends on output
  elapsed_ms
}

Telemetry

Every call is appended (best-effort, never blocks extraction) to

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "pdf-extract": { "command": "pdf-extract-mcp", "env": {} } } }