pdf-tables-mcp
README.md
> **Want your AI agent to read a folder of supplier invoices or bank statements and tell you what doesn't add up? Start here.**
> pdf-tables-mcp gives Claude, Cursor or any MCP client four read-only tools that turn text-layer invoice and statement PDFs into checked, structured data, without uploading anything.
<div align="center">
# pdf-tables-mcp
**Invoice and bank-statement PDFs to structured, arithmetic-checked data for AI agents. Local and sandboxed.**
[](https://github.com/purkat0301-sys/pdf-tables-mcp/actions/workflows/ci.yml)
[](LICENSE)
[](pyproject.toml)
<img src="docs/demo.png" alt="pdf-tables-mcp scanning a folder of invoices and flagging a mismatch" width="900">
<sub>Real output of <code>pdf-tables-mcp examples/invoices --scan</code>: the same data the agent gets from <code>extract_folder</code>. The example PDFs are synthetic.</sub>
</div>
---
## Why
Asking a chat model to "read these invoices" usually means uploading PDFs and hoping the numbers it reads back are the ones on the page.
This server does the reading with a deterministic parser on your machine, checks the arithmetic (line amounts, subtotal + VAT = total, running bank balances) and hands the agent clean JSON plus a list of what failed the checks. The agent then does what it is good at: explaining, comparing and drafting the follow-up.
## Features
- ๐งพ **Invoices**: number, date, seller, buyer, currency, subtotal, VAT, total and line items (description, qty, unit price, amount)
- ๐ฆ **Bank statements**: account holder, account, period, opening / closing balance, transactions with debit, credit and balance
- โ
**Arithmetic checks** on every document; mismatches come back as readable issues, not silent numbers
- ๐ **Folder tools**: one summary row per PDF, invoice totals per currency, flagged and unreadable files; or all line items as one flat table
- ๐ฆ **No silent empties**: every document has a `status` of `ok`, `NO_ROWS` or `NEEDS_REVIEW`; documents where no line items or transactions were found are listed separately in `no_rows`, so an agent never mistakes an empty extraction for a clean one
- ๐ **Sandboxed and read-only**: only folders you pass on the command line are reachable (`..` and symlink escapes are refused), 25 MB and 200-file limits, nothing is written
- ๐ฅ๏ธ **CLI too**: `--scan` for a terminal summary, `--call TOOL` to see the exact JSON a tool returns
- ๐ชถ Parser: [invoice-pdf-extractor](https://github.com/purkat0301-sys/invoice-pdf-extractor) v0.2.0, pinned to a commit (pure Python, `pypdf`); MCP protocol implemented without an SDK
## Quick start
```bash
pip install git+https://github.com/purkat0301-sys/pdf-tables-mcp
pdf-tables-mcp ~/Invoices --scan
pdf-tables-mcp ~/Invoices # run as an MCP server on stdio
```
MCP client config (Claude Desktop, Cursor, VS Code, ...), as in [examples/mcp.json](examples/mcp.json):
```json
{ "mcpServers": { "invoices": { "command": "pdf-tables-mcp", "args": ["/path/to/Invoices"] } } }
```
Then ask, for example: *"Which invoices in November don't add up, and what is the total per currency?"*
## How it works
```mermaid
flowchart LR
A[AI agent] -->|tools/call| S[pdf-tables-mcp]
S -->|path check| X{inside allowed folders?}
X -- no --> E[error returned to agent]
X -- yes --> P[invoice-pdf-extractor<br/>pypdf text layer]
P --> C[parse fields, lines,<br/>transactions]
C --> V[arithmetic checks]
V --> S --> A
```
| Tool | Input | Returns |
|---|---|---|
| `list_pdfs` | `folder`, `recursive` | PDF files and sizes |
| `extract_pdf` | `path`, `doc_type`, `password` | full document with lines or transactions and `validation_issues` |
| `extract_folder` | `folder`, `recursive`, `doc_type` | summary rows with `status`, `invoice_totals` per currency, `flagged` (checks failed), `no_rows` (nothing extracted), `failed` (unreadable) |
| `invoice_lines` | `folder`, `recursive` | every invoice line item as one table |
What one document looks like (the PDF on the left, the tool result on the right):
<p>
<img src="docs/sample_invoice.png" alt="sample invoice PDF" width="380">
<img src="docs/extract.png" alt="extract_pdf JSON for the sample invoice" width="500">
</p>
## Compared with the inspiration
Built on my own [invoice-pdf-extractor](https://github.com/purkat0301-sys/invoice-pdf-extractor) after looking at general PDF-table MCP servers such as [wesseltl/pdf-mcp](https://github.com/wesseltl/pdf-mcp).
| | pdf-tables-mcp | wesseltl/pdf-mcp |
|---|---|---|
| Focus | invoices and bank statements | any table in PDF and Word documents |
| Named invoice / statement fields | โ
| via configurable profiles (per its README) |
| Arithmetic checks (totals, VAT, balances) | โ
built in | see project |
| Folder summary and totals per currency | โ
| see project |
| Generic table extraction, Word files | โ | โ
|
| Browser app, Excel export | โ (CLI + JSON) | โ
|
| Scanned PDFs (OCR) | โ | โ (per its README) |
| Path sandbox | โ
| see project |
If you need any table from any document, use pdf-mcp. If you need "read my invoices and show me the ones that are wrong", use this.
## FAQ
**Scanned invoices?** Not supported: they have no text layer. Run OCR first (for example `ocrmypdf in.pdf out.pdf`); the tool says so when it meets one.
**Which invoice layouts work?** Text-layer PDFs with labelled fields (Invoice No, Date, Subtotal, VAT, Total) and line items in rows. Run `--scan` on your own folder to see before connecting an agent.
**Does anything leave my machine?** The server makes no network calls. What your MCP client sends to its model is up to the client.
## Limitations
- Layout-based parsing, reliable only on layouts similar to the parser's test samples. Unusual layouts can miss fields; the document is then marked `NEEDS_REVIEW` or `NO_ROWS`. Parser benchmark on 11 public real invoices (a development set, not blind): see [invoice-pdf-extractor](https://github.com/purkat0301-sys/invoice-pdf-extractor#benchmark-on-real-invoices).
- Text-layer PDFs only; no OCR.
- Installs its parser from GitHub; not on PyPI yet.
## Roadmap
See [ROADMAP.md](ROADMAP.md): duplicate-invoice detection, CSV/XLSX export tool (opt-in folder), supplier filter, date-range filter.
## Related tools
By the same author: [invoice-pdf-extractor](https://github.com/purkat0301-sys/invoice-pdf-extractor) (the parser as a CLI) ยท
[recon-kit](https://github.com/purkat0301-sys/recon-kit) (match invoices to payments) ยท
[sheets-mcp](https://github.com/purkat0301-sys/sheets-mcp) (read-only SQL over CSV/XLSX) ยท
[mcp-preflight](https://github.com/purkat0301-sys/mcp-preflight)
## Contributing
Issues and pull requests are welcome; a synthetic PDF that parses wrongly is the most useful bug report.
`pip install -e '.[dev]' && pytest`.
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues