npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fairbooks-three-way-match

v0.2.0

Published

Fairbooks Three-Way Match: an MCP agent that investigates accounts-payable three-way-match exceptions (PO, receipt, invoice) from CSV/JSON exports, including partial receipts, per-vendor tolerances and near-duplicate invoices, and writes a worklist, PO st

Readme

Fairbooks Three-Way Match (fairbooks-three-way-match)

Investigate AP three-way-match exceptions from PO, receipt and invoice exports. Clearing an invoice for posting is one human click; it never posts or pays.

Part of Fairbooks Machine domain agents: one agent, one process, nothing outside its lane. Built on fairbooks-core. MIT, Node ≥ 20, runs on your machine, no account or API key needed.

What it does

Give Fairbooks Three-Way Match three exports (CSV/JSON; column names matched loosely): PO lines (po, line, item, vendor, qty, unit_price), receipts (po, line, qty, date) and invoice lines (invoice, vendor, po, line, qty, unit_price, date). For each invoice line it reports:

  • no PO, or a PO line that does not exist;
  • vendor name different from the PO;
  • nothing received; billed more than received (counting earlier invoices on the same line); billed more than ordered;
  • unit price outside tolerance (default 2%, plus an optional absolute amount), optionally per vendor from a tolerance profile;
  • possible duplicate invoices (same vendor, number and line) and near-duplicates (same vendor, PO line and amount with an invoice number that differs only in punctuation or leading zeros, or by one character on the same date);
  • notes that do not block: partial receipt, invoice dated before receipt; and blank quantity or price.

Each exception gets an estimated $ impact, a plain explanation and a suggested next step. The worklist has blank owner, resolution and resolved_date columns.

Partial receipts and several invoices per PO line. Billing is counted cumulatively per PO line and each invoice is allocated to receipts first-in, first-out, so every invoice line lists the receipt(s) (receipts) it was matched against. Exact and near-duplicates are not counted as billing.

PO line status and GRNI. match_po_status shows ordered, received and billed quantities per PO line, what is left to receive, received-not-billed (a GRNI accrual estimate at PO price) and billed-not-received.

Tolerance profiles. Pass tolerance_profile (a JSON file under --root) to set tolerances per vendor. Order of precedence: the vendor's entry, then the run's arguments (price_pct, price_abs, qty_tolerance), then the profile's default, then the built-in defaults. Each invoice line reports the tolerance it used and where it came from. Check a profile before use:

fairbooks-three-way-match validate-config tolerances tolerances.json
{ "default": { "price_pct": 2 },
  "vendors": { "Globex Furniture (fictional)": { "price_pct": 10, "note": "freight surcharge" } } }

Unknown keys, wrong types and a missing vendors object fail with JSON-pointer errors.

Vendor scorecard and HTML report. match_match returns by_vendor (lines, exception rate, $ at issue, top codes). match_write_report writes ap-report.html (self-contained, no scripts or network) and ap-po-status.csv; the HTML's sha256 is returned as output_sha256 and recorded in the audit line (signed when the audit log is signed).

Exports it reads

Table inputs can be CSV, TSV, semicolon- or pipe-separated text, Excel .xlsx, JSON or JSONL. A file already in this agent's own columns is read as it is. The exports below are recognised by their column names and mapped onto those columns; dates become YYYY-MM-DD, amounts plain decimals (both decimal marks), and yes/no columns yes/no. Each result lists, under sources, which export was recognised, which columns were mapped, and any rows skipped or dates that could be read two ways.

Purchase order lines (argument pos)

| System | Export | Layout checked against vendor docs | |---|---|---| | NetSuite | Transaction saved search (default column labels) | no |

Goods receipt lines (argument receipts)

| System | Export | Layout checked against vendor docs | |---|---|---| | NetSuite | Transaction saved search (default column labels) | no |

Vendor invoice (bill) lines (argument invoices)

| System | Export | Layout checked against vendor docs | |---|---|---| | NetSuite | Transaction saved search (default column labels) | no | | Xero | Bills > Export (CSV) | no |

Columns named differently? Run npx fairbooks-three-way-match inspect <file> to see how a file is read (column names and shapes only, never values), then name your columns in fairbooks-sources.json in the root:

{ "files": { "exports/users.csv": { "columns": { "email": "Work E-mail" }, "date_order": "dmy" } } }

Where a layout says "checked", its column names were compared with the vendor's documentation on that date. The other layouts were written from knowledge of the export and were not checked. None was tested against a live account. If a real export does not match, the result says which columns were missing; please report it.

Install

npm install -g fairbooks-three-way-match
fairbooks-three-way-match demo        # runs on the bundled fictional sample data

As an MCP server

Claude Code

claude mcp add fairbooks-three-way-match -- npx -y [email protected] mcp --root /path/to/your/exports

Cursor / Claude Desktop / VS Code / Windsurf

{ "mcpServers": { "fairbooks-three-way-match": { "command": "npx", "args": ["-y", "[email protected]", "mcp", "--root", "/path/to/your/exports"] } } }

--root is the only folder the tools can read or write. Paths outside it are refused.

Tools

| Tool | Policy | What it does | |---|---|---| | match_match | allow | Three-way match with tolerances and $ impact | | match_explain_exception | allow | Explain one invoice: why it matters, next step | | match_write_worklist | allow | Write ap-exceptions.csv + ap-match.json to fairbooks-out/match | | match_po_status | allow | PO line status: received, billed, GRNI estimate, billed-not-received | | match_write_report | allow | Write ap-report.html + ap-po-status.csv; logs the report hash | | match_request_posting | ask · one-click | After a named human approves, record that an invoice is cleared for posting | | erp_post_invoice | block | Listed so agents see the refusal. Fairbooks Three-Way Match never writes to an ERP. |

Any other tool name is blocked. fairbooks_info shows the pinned model, mode, caps and every decision.

MCP prompt

ap_exception_review (arguments pos, receipts, invoices, optional tolerance_profile) walks a host model through match → explain → PO status → worklist and report, and stops at the human click for posting.

Modes

  • Review (--mode review): read and report only.
  • Assist (default): the policy above. ask returns an approval_id; a person approves once with fairbooks-three-way-match approve <id> --as "Your Name".
  • Auto (--mode auto --auto <tool,...>): off by default, opt-in per action, with step/spend caps (--max-steps, --max-spend) and a kill switch (fairbooks-three-way-match kill).

Clearing an invoice for payment is move_money: it stays one-click even in Auto, and --auto match_request_posting is refused. Auto still runs matching and worklists without stopping. Posting to an ERP stays blocked.

Go-live, revoking access, deleting personal data, moving money, legally binding sends and production deploys always need a person's click, in every Fairbooks pack.

CLI

fairbooks-three-way-match tools
fairbooks-three-way-match call match_match '{"pos":"pos.csv","receipts":"receipts.csv","invoices":"invoices.csv","price_pct":2}'
fairbooks-three-way-match eval          # private evals on the bundled fixtures

Every call is written to .fairbooks/audit.jsonl (hash-chained JSONL; arguments stored as a hash). Read it with fairbooks-audit-evidence or npx -y -p fairbooks-core fairbooks-verify-log .fairbooks/audit.jsonl.

What it is not

  • Not an AP automation suite or ERP. It does not approve, post or pay invoices; AP does that in the ERP.
  • $ impact is an estimate of the amount at issue, not a recovery figure.
  • Matching relies on PO and line numbers in your exports. It does not read invoice PDFs.
  • Near-duplicate detection is rule-based and can miss duplicates with different amounts or vendors; it can also flag a legitimate invoice. A person decides.
  • GRNI is valued at PO price and is an estimate for review, not an accrual entry.
  • No ERP connector: it reads exports only.
  • Not accounting advice.
  • Not fully autonomous: anything risky waits for a named person.

Data

Everything runs locally on files you choose. No network calls, no telemetry. The bundled fixtures are fictional.

License

MIT © 2026 Kurt Francisco. Source: https://github.com/fpavia111-creator/fairbooks-agents/tree/master/packages/fairbooks-three-way-match