late-interest
README.md
# late-interest
UK statutory **late payment interest** and **fixed compensation** for business-to-business invoices, as a TypeScript library, a command-line tool and an [MCP](https://modelcontextprotocol.io) server. No network calls, no runtime data fetching; one small dependency pair (`@modelcontextprotocol/sdk`, `zod`) used only by the MCP server.
It runs the same tested code and the same verified Bank of England Bank Rate table as the free calculator at **[claimlateinterest.co.uk](https://claimlateinterest.co.uk/?utm_source=npm&utm_medium=package&utm_campaign=late-interest)**, which shows the working step by step and can raise the claim invoice and chase the debt for you.
> **Not legal advice.** This package gives general information about the [Late Payment of Commercial Debts (Interest) Act 1998](https://www.legislation.gov.uk/ukpga/1998/20) and does not take your contract or circumstances into account. It assumes a business-to-business debt with no contractual late payment rate. Check the sources below, and take advice if a lot is at stake or the debt is disputed. No warranty (see the [MIT licence](./LICENSE)).
## What it calculates
| Part | Rule | Source |
|---|---|---|
| Interest | 8% a year over the Bank of England Bank Rate, simple interest, daily rate = yearly ÷ 365, from the day after the due date | [Act s.4](https://www.legislation.gov.uk/ukpga/1998/20/section/4), [GOV.UK](https://www.gov.uk/late-commercial-payments-interest-debt-recovery/charging-interest-commercial-debt) |
| Which Bank Rate | The rate in force on 30 June (interest starting 1 Jul to 31 Dec) or 31 December (interest starting 1 Jan to 30 Jun) immediately before interest starts, then fixed | [Rate of Interest (No. 3) Order 2002, art. 4](https://www.legislation.gov.uk/uksi/2002/1675/article/4/made) |
| Fixed compensation | £40 under £1,000; £70 from £1,000 to £9,999.99; £100 from £10,000. Once per debt | [Act s.5A](https://www.legislation.gov.uk/ukpga/1998/20/section/5A), [GOV.UK](https://www.gov.uk/late-commercial-payments-interest-debt-recovery/claim-debt-recovery-costs) |
Not covered: consumer debts, contractual rates, part-payments, public-authority customers, the 60-day "grossly unfair" cap on payment terms, and extra recovery costs above the fixed sum (s.5A(2A)). Interest and compensation carry no VAT.
Bank Rate data: Bank of England, [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). The table is **bundled with each release** (currently verified to 24 September 2026; the next Monetary Policy Committee decision is 5 November 2026). The package warns when a result depends on a rate it cannot know yet. The website keeps its table up to date automatically; update this package after a rate change.
## Install and use
```bash
npm install late-interest # library
npx late-interest 2500 --due 2026-06-30 --paid 2026-09-28
```
### Library
```js
import { lateInterest, fixedCompensation, bankRateOn } from "late-interest";
const r = lateInterest({ amount: 2500, dueDate: "2026-06-30", paidDate: "2026-09-28" });
// { daysLate: 90, bankRatePercent: 3.75, statutoryRatePercent: 11.75,
// interest: 72.43, compensation: 70, total: 142.43, pence: { ... },
// warnings: [], sources: { ... }, notLegalAdvice: "...", moreInfo: "https://claimlateinterest.co.uk/" }
fixedCompensation("999.99").compensation; // 40
bankRateOn("2025-12-31").bankRatePercent; // 3.75
```
Leave out `paidDate` for an unpaid invoice and it counts to today (UK time). Amounts may be numbers or strings like `"£2,500.00"`; totals are also given in whole pence (`pence`) so you can add them exactly. Bad input throws an `Error` with a plain message.
### CLI
```
late-interest <amount> --due YYYY-MM-DD [--paid YYYY-MM-DD] [--json]
late-interest compensation <amount> [--json]
late-interest rate <YYYY-MM-DD> [--json]
late-interest history [--since YYYY-MM-DD] [--csv | --json]
late-interest mcp
```
Exit code `0` on success, `2` for bad input (message on stderr).
### MCP server (Claude Desktop, Cursor and other MCP clients)
`late-interest mcp` (or the `late-interest-mcp` command) starts an MCP server over stdio. Nothing to install first: `npx` fetches it.
**Claude Desktop:** open *Settings → Developer → Edit Config* (the file is `claude_desktop_config.json`: `~/Library/Application Support/Claude/` on macOS, `%APPDATA%\Claude\` on Windows), add the server, save and restart Claude Desktop:
```json
{
"mcpServers": {
"late-interest": {
"command": "npx",
"args": ["-y", "late-interest", "mcp"]
}
}
}
```
Needs Node.js 18.17 or later on your PATH. Then ask Claude something like *"An invoice for £2,500 was due on 30 June 2026 and paid on 28 September 2026. How much statutory interest and compensation can I claim?"*
The same block works in Cursor (`~/.cursor/mcp.json`) and other MCP clients.
Tools (all read-only, no network): `calculate_late_payment_interest`, `late_payment_fixed_compensation`, `bank_rate_on_date`, `bank_rate_history`. Every answer includes the sources, the not-legal-advice text and a link back to the site.
## How it stays the same as the website
`src/core/calc.ts` and `src/core/baseRates.ts` are copies of the calculator and Bank Rate table behind [claimlateinterest.co.uk](https://claimlateinterest.co.uk), made by `scripts/sync-core.mjs` (the only edit is `.js` on relative imports). The website's own test suite fails if the copies drift, and a new release of this package follows each Bank Rate change.
## Develop
```bash
npm install
npm test # builds, then unit tests, CLI tests and an end-to-end MCP test over stdio
```
## Licence
MIT. Source: [github.com/DannyWolfofTech/late-interest](https://github.com/DannyWolfofTech/late-interest). Issues: [github.com/DannyWolfofTech/late-interest/issues](https://github.com/DannyWolfofTech/late-interest/issues). Website: [claimlateinterest.co.uk](https://claimlateinterest.co.uk/?utm_source=npm&utm_medium=package&utm_campaign=late-interest).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues