If you have built an automated Accounts Payable workflow in n8n or Make.com (Email PDF → OpenAI/Claude/Mistral OCR → Google Sheets / ERP), you have probably run into the quietest bug in production AI automation:
LLMs are great at reading unstructured invoices, and terrible at exact arithmetic.
In real B2B invoices, an LLM will confidently output JSON like:
-
quantity: 3,unit_price: 19.99,line_total: 65.00(Actual math:$59.97— a+$5.03hallucination that cascades into wrong tax and wrong grand total) - Silently dropping the minus sign on accounting credit notes like
(50.00), turning a-$50discount into+$50(a$100overpayment error) - Tripping over IEEE-754 floating-point drift (
0.1 + 0.2 = 0.30000000000000004) or mixing 0-decimal currencies (JPY,TWD) with 2-decimal currencies (USD,EUR)
Asking a second LLM prompt to "double-check the math" burns tokens and still hallucinates.
The Fix: Put a Zero-Scraping Deterministic Guardrail Node Between Your LLM and Your ERP
Instead of maintaining fragile custom JS Code nodes for every client workflow, we packaged two stateless, pure-compute, zero-scraping MCP / API tools on Apify Store—plus free MIT-licensed n8n & Make.com workflow JSON blueprints you can import in 10 seconds:
-
Structured Invoice & PO Deterministic Validator (
$0.004 / invoicePay-Per-Event, zero proxy cost)- Runs exact
BigIntminor-unit integer math across every line item, subtotal, tax-inclusive/exclusive calculation, discount, and grand total. - Detects duplicate OCR lines, reversed dates, and validates EU/UK VAT, US EIN, and Taiwan GUI / ROC dates.
- Returns machine-readable diff codes (
hallucinationDetected,expected,actual,delta) plus an auto-correctednormalizedInvoiceJSON. - Live 3-second example catching 4 cascading LLM math errors: https://apify.com/snowy_divide_r1t/structured-invoice-line-validator/examples/catch-llm-math-hallucinations-in-b2b-invoice-live-example
- Apify Store page: https://apify.com/snowy_divide_r1t/structured-invoice-line-validator
- Runs exact
-
RAG Table-Aware Markdown & HTML Chunker (
$0.002 / documentPay-Per-Event)- Fixes the #2 silent killer in AI automation: naive character splitters slicing financial and pricing tables mid-row so downstream chunks lose their column headers.
- Splits oversized tables strictly along row boundaries, auto-repeats the original table header row on every continuation chunk (
tableSplitPart: "1/N"), injectsH1 > H2 > H3heading breadcrumbs, and calculates CJK + English token counts (o200k,cl100k,claude,gemini). - Live financial Markdown table example: https://apify.com/snowy_divide_r1t/rag-table-aware-chunker/examples/split-financial-markdown-report-without-breaking-tables
- Apify Store page: https://apify.com/snowy_divide_r1t/rag-table-aware-chunker
Free Ready-to-Import n8n & Make Blueprints (MIT License)
All templates are open-source with zero hardcoded credentials:
- n8n Invoice OCR + Deterministic Audit Guardrail JSON: https://mcp.miaodui.workers.dev/templates/n8n-invoice-ocr-deterministic-audit.json
- Flow:
Webhook / PDF OCR → LLM Extract → Deterministic BigInt Audit → IF hallucinationDetected → Slack Alert / Clean Google Sheets & ERP
- Flow:
- n8n Table-Safe RAG Ingestion JSON: https://mcp.miaodui.workers.dev/templates/n8n-rag-table-safe-chunking.json
- Make.com HTTP + Router Blueprint & MCP Config JSON: https://mcp.miaodui.workers.dev/templates/make-invoice-audit-and-mcp-config.json
- GitHub Template Repository (MIT): https://github.com/miaoduitw-creator/miaodui-mcp-templates
Use Directly Inside Claude Desktop or Cursor via MCP
Both tools also work natively as MCP tools through @apify/actors-mcp-server:
{ "mcpServers": { "miaodui-pure-compute": { "command": "npx", "args": [ "-y", "@apify/actors-mcp-server", "--actors", "snowy_divide_r1t/structured-invoice-line-validator,snowy_divide_r1t/rag-table-aware-chunker" ], "env": { "APIFY_TOKEN": "<apify-api-token>" } } } } Try Both Algorithms Live in Your Browser (Zero Login, Zero Data Uploaded)
Before wiring anything into n8n or Make, you can test messy invoice JSON or complex Markdown/HTML tables 100% client-side in our interactive sandbox:
https://mcp.miaodui.workers.dev/
If you run AI automation workflows for finance or RAG pipelines, what other "messy LLM output → strict deterministic JSON" edge cases keep breaking your automations?