Your agent can read an invoice. What it can't do is show you where each number came from, or do the same thing reliably across 10,000 invoices.

Ask Claude Code or Codex to pull the total from a scanned PDF and you usually get one of three things: a guess, a value from the wrong table row, or a confident answer with no way to check where it came from. That's fine for a demo. It isn't fine when the number goes into an accounting system.

This post gives you 10 copy-paste prompts that let an agent read documents properly: pull fields from invoices, tables from statements and text from scans, each value with its source. The agent connects to a data extraction APIover the Model Context Protocol (MCP). Every prompt below was run with the live server connected, and the outputs shown are real.

Where agents fall short on document data

I tested this on a tilted, noisy scan of a supplier invoice: an image with no text layer at all. Claude read it on its own and got the invoice date and the total right. When I asked where those values were, the best it could do was "top right, about 13% down the page" for the date, and "right side, about 55% down" for the total.

The extraction API returned the same values with evidence:

Field

Value

Bounding box (x, y, w × h, px)

Groundedness

OCR confidence

invoice_date

October 14, 2026

887, 215, 316 × 28

0.9983

0.93

total_due

$1,997.91

676, 814, 504 × 131

0.9998

0.93

One caveat: a citation points to the source region, not always the exact word. The date's box is tight and covers the label and the value. The total's box covers the whole totals block, from subtotal to total. A review screen highlights that block, which is still far quicker to check than "about 55% down".

A PDF doesn't store "a table" or "a paragraph". It stores characters at coordinates. Everything a human sees has to be reconstructed: reading order, columns, table cells, which number belongs to which label. Scans are worse, because there's no text at all until OCR runs.

When a general-purpose model reads a PDF directly, four things tend to go wrong:

  • Tables collapse. Cells merge, rows shift, and a debit ends up in the credit column.
  • Reading order breaks. Two-column layouts get read straight across the page.
  • Scans are harder. Tilted or noisy pages produce more misreads, and nothing tells you which values to check.
  • There's no evidence. You get a value, but not the page and position it came from.

The fix is to give the agent a document data extraction tool that does the parsing and returns structured output with a source location for every value. The agent keeps doing what it's good at: deciding what to ask for and what to do with the answer.

Setup in 60 seconds

The server is hosted, so there's nothing to install and no API key in a config file. You sign in once with OAuth.

Claude Code

claude mcp add --transport http --scope user nutrient https://mcp.nutrient.io/mcp

Then start a new session, run /mcp, choose nutrient, and select Authenticate.

Codex

codex mcp add nutrient --url https://mcp.nutrient.io/mcp && codex mcp login nutrient

Claude app: Settings → Connectors → add a custom connector with https://mcp.nutrient.io/mcp.

Full setup details are in the MCP server guide.

The 10 data extraction prompts

Each prompt is written the way you'd type it to your agent. Swap in your own file names.

1. Invoice to JSON

When to use it: any time a number from a document goes into another system.

Extract vendor, invoice number, date, line items and total from invoice.pdf.

What came back: every field correct. Shortened, showing 2 of the 6 line items:

{ 
  "vendor": "Halvorsen Tool & Supply Co.", 
  "invoice_number": "HTS-26-1187", 
  "invoice_date": "2026-10-14", 
  "line_items": [ 
    { "sku": "HB-2210", "description": "Galvanized steel bracket, 4 in (box of 50) T", "quantity": 12, "unit_price": 84.5, "amount": 1014 }, 
    { "sku": "AB-1620", "description": "Anchor bolt M16 x 200 mm T", "quantity": 300, "unit_price": 1.95, "amount": 585 } 
  ], 
  "total": 1997.91 
} 

All 6 line items came back, including a −$169.00 credit for returned brackets. The total matches the invoice: $1,835.00 subtotal + $48.00 shipping + $114.91 tax = $1,997.91.

Every value comes with its page, a bounding box and a groundedness score. Here's the citation for the total, as returned:

"total": {   "pageNumber": 1,   "bbox": { "x": 874, "y": 1060.75, "width": 667, "height": 158.25 },   "match": "id_match",   "citation": { "status": "cited", "confidence": { "groundedness": 0.9997 } } } 

You don't need to ask for locations; they come back anyway. My first version of this prompt ended with "Show the page and source location for each value." The server turned that into extra fields filled with descriptions like "Upper right, beside 'Invoice date'", which added nothing and caused review flags (see prompt 2).

Two more things to know. The field names are generated for each document: vendor and total here, not a fixed schema. And the output keeps what’s printed: line-item descriptions kept the invoice’s tax marker, as in “Anchor bolt M16 x 200 mm T”.

2. Confidence check

When to use it: before you import anything automatically.

For every value you extracted, flag anything with low confidence so I can review it before import.

What came back: one value flagged for review: the unit price on the −$169.00 credit line, with a groundedness score of 0.18. The value was correct. Every other field scored between 0.97 and 0.9997 and was marked ready to import.

That's the behavior you want from a review step: it leans towards asking a person. An earlier run, using my first version of prompt 1, came back with 14 flags, mostly on the extra "source location" fields that prompt created. It's a good reason to keep extraction prompts to the fields you need.

3. PDF to Markdown for RAG

When to use it: before chunking documents for retrieval.

Parse report.pdf to Markdown, keeping tables and reading order, and save it as report.md.

What came back: clean headings, the abstract and introduction in order, and the results table intact (as an HTML table, which keeps merged cells). A chart even came back as a table. The test file was a three-page, two-column research paper, and reading order wasn't perfect:

  • A table and a methodology paragraph landed after the Results section.
  • Two headings merged into one line: "V. Discussion VII. Conclusion".
  • One table's cells shifted by a column.

Check the Markdown of a multi-column document before you index it. Single-column documents are much easier.

4. Read a scanned document

When to use it: contracts, faxes, anything that arrived as an image.

This is a scanned contract. Parse it with OCR and list the parties, the effective date and who signed.

What came back: the test file was a 3-page image-only scan, slightly tilted and noisy. Parsing took about 13 seconds and cost $0.054 ($0.018 a page). The answer:

  • Parties: Nexus Digital Solutions, LLC (Service Provider) and Bridgewater Logistics Partners, Inc. (Client)

  • Effective date: February 14, 2024

  • Signed by: Elena V. Marchetti, Chief Executive Officer, and Derek L. Fontaine, Chief Operating Officer, both dated February 14, 2024

    All correct. The noise left stray characters in the parsed text, such as "oo", "ve" and "fe" between two sections, and "Derek L. Fontaine t t" on the signature page. That's normal for scans. The agent's answer stayed clean, and the citations tell you which region to check if something looks off.

5. Tables only

When to use it: statements, price lists, reports.

Pull every table from statement.pdf into JSON, then save each table as its own CSV file.

What came back: both tables, the account summary and all 7 transactions, saved as two CSV files. Shortened:

Date,Description,Debit,Credit,Balance 06/03/2026,Rent — Oakview Apartments,"1,850.00",,"2,360.35" … 06/28/2026,Payroll — Brightline Logistics Inc.,,"2,891.44","7,692.81" 

Empty debit and credit cells came back empty, not as zero, which matters if you sum the columns later. The closing balance matched the statement: $7,692.81.

6. Sort a pile of documents

When to use it: an inbox or upload folder with mixed file types.

Classify every file in ./inbox as invoice, receipt, contract or ID document, and move each file into a folder named after its type.

What came back: 4 of 4 correct.

File

Label

Score

Runner-up

invoice_halvorsen.pdf

invoice

0.98

receipt 0.18

receipt_photo.jpg

receipt

0.93

invoice 0.03

contract_excerpt.pdf

contract

0.98

ID document 0.02

id_card.jpg

ID document

0.96

receipt 0.004

The server classifies; the agent moves the files. Run this one in Claude Code or Codex rather than a chat app.

7. Same fields from many files

When to use it: monthly invoice runs, batches of forms.

Extract the same fields from all invoices in ./invoices in one batch, and build one spreadsheet with a row per invoice.

What came back: three invoices from three different suppliers, each with a different layout. The server generated one 20-field schema and applied it to all three. A few columns from the spreadsheet:

File

invoice_number

invoice_date

total_due

currency

invoice_halvorsen.pdf

HTS-26-1187

October 14, 2026

1997.91

USD

invoice_tidewell.pdf

TS-0457

2026-10-30

4652.5

$

invoice_ferrymark.pdf

FM-778201

31-OCT-2026

2207.62

USD

All three totals are correct. On the Tidewell invoice, it took the balance due after a $1,500 retainer, not the $6,152.50 in fees.

Tip: run files of one kind together, and say how you want values formatted. Without that, our batch came back with "USD" on two invoices and "$" on the third, and three different date formats. Adding "Use ISO 4217 codes for currency and YYYY-MM-DD for dates" fixed all three. Two things to check after a run like this. A "$" with no country is the model's best guess: here it said USD, citing the supplier's Oregon address. And a field that doesn't fit the format can come back empty: one invoice listed three ship dates, and with the date rule that field came back blank.

8. Preview the fields before you pay

When to use it: a new document type you haven't processed before.

Show me which fields you'd extract from claim.pdf before running the extraction.

What came back: 19 proposed fields for a property damage claim form, including claimant_name, policy_number, date_of_loss, type_of_loss and account_number. Each field comes with a rule. Every rule starts with "If no value is observed, return null rather than inventing a value", and then adds specifics. For example, the rule for police_or_fire_report_number is "including an explicit N/A; null if blank". The response said: "Nothing was extracted, billed or stored."

The list isn't fixed. An earlier run on a similar form proposed 21 fields. Edit the list until it has what you need, then use the same list for every file of that type.

9. Redact before sharing

When to use it: before sending a document to a vendor, a model, or a colleague who doesn't need the personal data.

Redact names, email addresses, phone numbers and bank account numbers in claim.pdf, then save a redacted copy.

What came back: the claimant's name, email, phone number and account number were removed, both in the form fields and in the free-text description. It also caught the name of a neighbour mentioned in the description. The text is gone from the file, not just covered by a black box. The policy number, address and routing number stayed, because the prompt didn't ask for them.

Two things to watch. The bank name was removed even though the prompt didn't ask for it. And thetyped signature "R. M. Okafor" was removed in one run and left in another. If something must go, name it in the prompt ("…and signatures"), and open the redacted copy before you send it.

10. Estimate the cost before a batch

When to use it: before you process a folder of documents.

Count the pages in ./invoices and estimate what extracting them will cost at $0.015 per page.

What came back: 3 invoices, 1 page each, so about $0.045. The agent counted the pages itself, locally, without sending anything to the server, so the estimate is free. The rate comes from your prompt. Extraction currently costs $0.015 per page, and parsing $0.009 or $0.018 depending on the mode. To see what you've actually used, check the Nutrient dashboard.

How to use it without overcomplicating it

Start with prompt 1 on one real document from your own work, and open the cited regions to check them. Once you trust the output for that document type, move to batches.

The parsing mode decides most of the cost:

  • Extraction (prompts 1, 5 and 7) ran in understand mode, at $0.015 per page.

  • Parsing a document to Markdown (prompts 3 and 4) defaults to agentic mode, at $0.018 per page.

  • On the clean three-page research paper, I reran the parse in understand mode at $0.009 per page. The Markdown was nearly identical, at half the price, in 1.2 seconds.

  • Agentic mode is for messy scans and complex layouts. For clean digital PDFs, ask for understand mode and compare both on a sample before you process thousands of pages.

Finally, keep a person in the loop for anything that moves money or makes a decision. The citations and confidence scores are there so the review takes seconds, not so you can skip it.