finance-mcp
> **Does your AI agent still do loan, VAT and cost-split arithmetic in its head?**
> finance-mcp is a small MCP server that gives it exact decimal tools instead: loan payments and schedules, NPV, IRR, future value, VAT, and splitting a sum to the cent. No network, no files, zero dependencies.
<div align="center">
# finance-mcp
**Exact money arithmetic for AI agents, checked through the real protocol.**
[](https://github.com/purkat0301-sys/finance-mcp/actions/workflows/ci.yml)
[](LICENSE)
[](pyproject.toml)
[](pyproject.toml)
<img src="docs/loan.svg" alt="finance-mcp call printing the first three rows of a 12-month loan schedule" width="700">
<sub>Real output on made-up numbers, made with <a href="https://github.com/purkat0301-sys/readme-shots">readme-shots</a>.</sub>
</div>
---
## Why
Language models are good at deciding that a loan payment or a VAT split is needed and unreliable at computing it: a rounding slip of one cent, a balloon with the wrong sign, a split of 100.00 into three parts that adds up to 99.99. These tools do the arithmetic with `Decimal`, return amounts as strings so no digit is lost, and say so plainly when an argument is wrong so the model can correct it.
## Quick start
```bash
pip install git+https://github.com/purkat0301-sys/finance-mcp
```
Add it to an MCP client (stdio), for example in a client's `mcpServers` config ([examples/mcp-config.json](examples/mcp-config.json)):
```json
{ "mcpServers": { "finance": { "command": "finance-mcp" } } }
```
Try a tool without any client:
```bash
finance-mcp tools
finance-mcp call vat '{"amount":"119.00","rate_pct":19,"mode":"gross"}'
finance-mcp call allocate '{"amount":"100.00","weights":[1,1,1]}'
```
## Tools
| Tool | What it does |
|---|---|
| `pmt` | Level payment for a loan (rate, periods, payments per year, optional balloon, payment at start or end). |
| `loan_schedule` | Schedule in whole cents: rounded payment, rounded interest each period, last payment clears the balance. Totals plus the first `max_rows` rows. |
| `fv` | Future value of regular payments and a starting amount. |
| `npv` | Net present value; the first flow is discounted one period like spreadsheet NPV, or set `first_flow_at_time_zero`. |
| `irr` | Internal rate of return, searched from -99.99% to 1,000,000%; with several roots, the one nearest the guess. |
| `allocate` | Split an amount by weights so the parts add up exactly (largest remainder, ties to the earlier weight). |
| `vat` | Net, VAT and gross from a net or a gross amount, VAT rounded half away from zero. |
Every tool is read-only and offline. Bad arguments come back as a tool error with a message (for example "periods must be between 1 and 1200"), not a protocol error. Numbers can be JSON numbers or strings; use strings for exact digits. Limits: 1,200 periods, 1,000 cash flows, magnitudes up to 1e15.
<div align="center"><img src="docs/allocate.svg" alt="finance-mcp allocate splitting 100.00 three ways into 33.34, 33.33 and 33.33" width="600"></div>
## What was measured
[docs/EVAL.md](docs/EVAL.md) has the numbers. Every call goes through the server over stdio using the official MCP Python SDK as the client.
- **6,000 calls** to `pmt`, `fv`, `npv`, `irr` and `vat` compared with LibreOffice Calc formulas: **0 differences**, after two bugs the first run found (a balloon with the wrong sign, and an IRR search range that stopped at 1,000%).
- **1,000 loan schedules** (233,544 cells) compared with a LibreOffice sheet using the same rounding recurrence: **0 cells differ**. The recurrence is my design choice, so this checks the arithmetic, not that your lender rounds the same way.
- **20,000 allocations** checked with exact fractions: the parts always add up to the amount and stay within a cent of their exact share.
- The SDK client validates all 7 input schemas and gets tool errors for 7 of 7 bad calls.
- The harness is not blind: a flipped balloon sign, half-even VAT rounding and an allocation without its remainder step were each caught. 55 unit tests, on Python 3.10 to 3.13.
## Limits
- Arithmetic only: no day counts (actual/365, 30/360), fees, variable rates, tax rules or currencies. Check a lender's conventions before relying on a schedule.
- The server speaks the handshake-era MCP versions (2024-11-05 to 2025-11-25) over stdio. The newer discover-based era is not implemented; the official SDK falls back correctly, other clients are untested.
- It does not verify that a model passes the right numbers.
## Compared with other options
- A spreadsheet or a Python REPL tool gives the same answers if the model writes the right formula; this exposes a fixed set so there is nothing to get wrong. Not run as an alternative.
- A GitHub search on 2026-11-29 for MCP loan and finance calculators found one small project; I did not run it and make no claim about it.
## Develop
```bash
python -m pip install -r requirements-dev.txt -e .
python -m pytest
```
`eval/` needs the `mcp` SDK and LibreOffice and is not run in CI. Dependencies are pinned in `requirements-dev.txt`, and the workflow actions are pinned to commit SHAs. Plan: [ROADMAP.md](ROADMAP.md). Changes: [CHANGELOG.md](CHANGELOG.md).
## License
MIT, see [LICENSE](LICENSE).
TDQS
Scored across 7 tools
Each tool maps to a distinct financial computation: npv vs irr (valuation vs rate), fv vs pmt (growth vs loan payment), and allocate/vat are clearly separate operations. The only mild overlap is pmt vs loan_schedule, though the descriptions make clear one returns a single payment and the other a full amortisation table.
All names are short lowercase domain terms, with snake_case used only for the one multi-word tool (loan_schedule). This is a predictable, consistent convention (abbreviation or snake_case for compounds) with no style mixing.
Seven tools is a tight, well-scoped set for a finance calculator; each one covers a distinct and non-redundant computation, with no filler or wrapper tools.
The core time-value-of-money surface is well covered (npv, irr, fv, pmt, loan_schedule) plus allocation and VAT, so common workflows have no dead ends. Gaps are minor: no date-based XNPV/XIRR and no nominal/effective rate conversion, but agents can work around these.