How to Build a Document Processing Agent with Claude Code and Lido

October 12, 2026

In this tutorial, we'll walk you through how to build a document processing agent using Claude Code and Lido. Simply follow the steps below.

What You Need

  • Node.js 18 or later. Check your version with node --version in your terminal. If you need to install it, grab the LTS release from nodejs.org.
  • Claude Code. Install with npm install -g @anthropic-ai/claude-code and authenticate with your Anthropic API key.
  • A Lido account. Sign up at lido.app and grab your API key from account settings. There's a free tier with enough pages to follow this tutorial.
  • A folder of test documents. Invoices work best for a first run, but any structured document will do. Five to ten files is plenty.

Step 1: Install the Lido MCP Server

Open your terminal and run:

claude mcp add lido -- npx -y @lido-app/mcp-server

That's the entire installation. This registers Lido as an MCP (Model Context Protocol) tool that Claude Code launches automatically whenever you start a session. No repo to clone, no Docker container to spin up, no YAML to edit. If you're using Claude Desktop or another MCP client instead, see the install options on the MCP page.

To verify it worked, start Claude Code and type:

Show me my available MCP tools

You should see four Lido tools: authenticate, extract_file_data, extraction_tips, and extractor_usage. If they appear, you're connected. For a deeper walkthrough of what each tool does and alternative installation methods, see the full Lido MCP setup guide.

The first time Claude uses a Lido tool, it'll call authenticate and open a browser window at localhost. Paste your Lido API key there. Credentials save to .lido-mcp/credentials.json in your project directory and persist across sessions.

Step 2: Set Up Your Document Inbox

Create a folder structure that separates incoming documents from processed output:

mkdir -p ./doc-agent/inbox ./doc-agent/processed ./doc-agent/output
  • inbox/ is where you drop documents to be processed
  • processed/ is where the agent moves files after extraction
  • output/ is where results land (CSVs, JSON files, exception reports)

Drop some test documents into inbox/. Invoices, purchase orders, receipts, bank statements, insurance certificates, or any document with structured data will work. Five to ten documents is enough to validate the pipeline before running a full batch. Even a fillable or scanned PDF form with labeled fields makes a good test file.

Step 3: Write Your Agent Prompt

A good agent prompt is specific about the goal, the fields, the rules, and the output format. Start Claude Code in your project directory and paste something like this:

Paste into Claude Code
Process every PDF in ./doc-agent/inbox/ as a vendor invoice. For each document, extract these fields: vendor name, vendor address, invoice number, invoice date, due date, payment terms, line item descriptions, quantities, unit prices, line item totals, subtotal, tax amount, and grand total. After extracting each file, validate that the line item totals sum to the subtotal within a $0.02 rounding tolerance. Flag any invoice where the math doesn't check out. Write all results to ./doc-agent/output/extraction-results.csv with one row per line item. Include a column for the source filename. After processing each file, move it from inbox/ to processed/. At the end, print a summary: how many invoices processed, how many passed validation, how many flagged.

That single prompt gives Claude enough to run the full pipeline. It calls extract_file_data for each document, applies the validation rule, writes the CSV, manages the file moves, and produces a summary report. No code to write.

For non-invoice documents, adjust the prompt accordingly. A certificate of insurance workflow might look like:

Example: COI Audit
Extract certificate holder, insurer name, policy number, coverage type, coverage limit, and expiration date from every PDF in ./doc-agent/inbox/. Flag any certificate that expires before 2026-07-01. Write results to ./doc-agent/output/coi-audit.csv.

Same pattern. Different fields. The agent handles it the same way.

Step 4: Run Extraction and Validate Results

When you hit enter on that prompt, Claude processes the documents sequentially. For each file, you'll see Claude call the extract_file_data tool, get results back, run its validation checks, and move to the next document. A batch of 20 standard invoices typically completes in two to four minutes.

Here's what the output looks like for a batch of five invoices:

VendorInvoice #DateLine ItemGrand TotalStatus
Acme IndustrialINV-45212026-03-15Hydraulic Pump HP-200 (2 x $1,250)$5,130.00PASS
Acme IndustrialINV-45212026-03-15Replacement Seals Kit (5 x $450)$5,130.00PASS
BrightStar ElectronicsBS-88342026-03-18LED Panel Array 4x8 (10 x $89)$961.20PASS
Summit OfficeSO-220192026-03-20Copy Paper A4 Case (25 x $42)$2,257.20PASS
Summit OfficeSO-220192026-03-20Toner Cartridge TN-450 (8 x $130)$2,257.20PASS

After the run completes, check these things:

  • Spot-check the CSV against a few source PDFs. Look at vendor names, totals, and line item details. Lido's template-free OCR data extraction handles most layouts correctly on the first pass.
  • Review the validation column. Any FAIL rows deserve a manual check. Common causes: discount lines that throw off the subtotal, or tax applied per line item rather than on the total.
  • Check the processed/ folder. Every file from inbox/ should have moved there. If a file is still in inbox/, extraction failed on that document.

If certain fields are consistently off for a specific vendor's layout, you can add field-level instructions. Tell Claude: "For BrightStar Electronics invoices, the invoice number appears in the upper right corner labeled 'Reference #' not 'Invoice #'." For more on this technique, see the extraction tips section of the MCP guide.

Step 5: Export to Spreadsheet or Database

The CSV from Step 4 is already usable. But most workflows need that data somewhere specific. Tell Claude the format you need:

Example: QuickBooks Import
Take the extraction results CSV and reformat it for our QuickBooks import. Columns should be: Vendor, Ref No., Date, Due Date, Item Description, Quantity, Rate, Amount. Map 'vendor_name' to Vendor, 'invoice_number' to Ref No., 'unit_price' to Rate. Drop the validation column. Save as ./doc-agent/output/qb-import.csv.

For JSON output (useful if you're feeding a database or API):

Example: JSON Export
Convert the extraction results to JSON. Group line items under their parent invoice. Structure it as an array of invoice objects, each with header fields and a nested lineItems array. Save to ./doc-agent/output/invoices.json.

Claude reads the source CSV, remaps columns, and writes the import-ready file. You can get more specific: "format dates as MM/DD/YYYY" or "round all amounts to two decimal places" or "add a column called 'Class' with the value 'Operations' for every row."

For teams that want data flowing directly into a spreadsheet, Lido's web app at lido.app has built-in Google Sheets and Excel export. The MCP-based agent approach is better when you need custom transformation logic or conditional routing.

Ready to automate your document processing?

50 free pages. No credit card, no manual setup.

How to Add Business Rules to Your Agent

Raw extraction gets data off documents. Business rules turn that data into something your team can act on. This is where the agent approach goes beyond basic intelligent document processing, and you add rules right in your prompt. No code required.

Fuzzy Vendor Matching

Extracted vendor names almost never match your ERP records exactly. "Acme Corp" on the invoice, "Acme Corporation Inc." in NetSuite.

Add to your prompt
After extraction, compare each vendor name against the list in ./vendor-master.csv and find the closest match. Add columns for matched_vendor_name and vendor_id.

Duplicate Detection

Vendors send the same invoice twice more often than you'd think. APQC research shows duplicate payments average $1,500 each.

Add to your prompt
Before writing results, check for duplicate invoices by matching on vendor name + invoice number + total. If a duplicate is found, skip the second occurrence and log it to ./doc-agent/output/duplicates.csv.

Approval Routing

Add to your prompt
Add a column called 'approver' based on the grand total. Under $1,000 set to 'auto-approve'. Between $1,000 and $10,000 set to 'dept-manager'. Over $10,000 set to 'director'.

Computed Columns

Add to your prompt
Add a column called 'days_until_due' that calculates the number of days between today and the due date. Add another called 'early_payment_eligible' that's TRUE if days_until_due is greater than 20 and payment_terms contains '2/10'.

Each of these rules is one or two sentences added to your prompt. The agent applies them across every document in the batch.

Use Case Examples

Invoice Processing (PDF to ERP)

The full accounts payable automation chain: extract invoices from an inbox folder, match vendors against a master list, apply approval routing, detect duplicates, validate line item math, and produce an ERP-ready import file. The output CSV drops into your ERP's bulk import tool without manual reformatting. For teams that want continuous email-based ingestion, email-based ingestion through Lido's web app handles that side.

Certificate of Insurance Compliance

Construction companies and property managers collect certificates of insurance from every subcontractor. The agent extracts certificate holder, insurer, policy type, coverage limits, and expiration date, compares against required minimums, and flags anything below the requirement or expiring within 60 days. One prompt replaces what most companies do with a spreadsheet that someone manually updates once a quarter.

Bank Statement Reconciliation

Extract transactions from monthly bank statement PDFs, match them against your GL entries by date and amount, and flag unmatched items. The agent finishes in minutes what normally eats the last few days of every month-end close. The exceptions file gives your team a focused list to investigate instead of working through every transaction line by line. GL entries often sit in spreadsheets, so the comparison may also rely on figures pulled from Excel workbooks.

Tips for Better Agent Prompts

  • Be explicit about field names. "Extract the invoice data" is too vague. "Extract vendor_name, invoice_number, invoice_date, due_date, grand_total" gives Claude a concrete schema to work with.
  • Include validation rules in the prompt itself, not as a follow-up step. When Claude validates during extraction, it catches problems while the document context is fresh.
  • Start with a small batch. Test on five documents, review the output, adjust your prompt, then scale.
  • Save working prompts to text files. Store as ./prompts/ap-extraction.txt and reference in future sessions. If you're evaluating dedicated tools for the extraction layer, the best invoice data extraction software comparison covers the landscape.

Frequently Asked Questions

What is a document processing agent and how is it different from an API?

A document processing agent runs multi-step document workflows autonomously. Instead of extracting data from one file at a time, an agent processes a batch of documents, applies business rules like validation, matching, and routing, and produces structured output ready for your downstream systems. With Claude Code and the Lido MCP server, you build agents by writing natural language prompts rather than code.

Can you build a document processing agent without coding?

Yes. The agent prompt is written in plain English. You describe the fields to extract, the rules to apply, and the output format you want. Claude handles the technical execution: calling the extraction API, reading and writing files, applying your business logic, and managing the document pipeline. You do need basic comfort with a terminal since Claude Code runs in the command line, but no programming is required.

How many documents can Claude Code process in a single batch?

Claude Code can process hundreds of documents in a single session. For most accounts, batches of 50 to 200 documents per session work well. Each standard document takes a few seconds to extract, so a batch of 100 invoices typically completes in under ten minutes. Larger volumes are better handled by splitting into multiple runs or using Lido's web app.

Does the Lido MCP server work with Cursor, Claude Desktop, and other AI editors?

Yes. The Lido MCP server implements the open Model Context Protocol standard and works with any MCP-compatible client, including Claude Desktop, Cursor, Windsurf, and Cline. The installation method varies by client, but the extraction capabilities are identical. See the full MCP setup guide for configuration details per client.

How accurate is AI document extraction with Lido's MCP server?

Field-level accuracy on standard document types like invoices, receipts, and purchase orders is typically 95 to 98 percent for header fields and 90 to 96 percent for line items depending on table complexity. The extraction is template-free, so it handles any document layout without per-vendor configuration. Accuracy doesn't degrade when a vendor changes their invoice format.

What document types can a Claude Code processing agent handle?

Any document with structured or semi-structured data: invoices, receipts, purchase orders, bank statements, tax forms, certificates of insurance, medical claims, contracts, packing lists, and shipping manifests. The extraction engine reads PDFs, scanned images, and photos. A single agent session can even process mixed document types if you instruct Claude to identify the document type first.

Ready to grow your business with document automation, not headcount?

Join hundreds of teams growing faster by automating the busywork with Lido.