cash-forecast-13wk
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
cash-forecast-13wk
A 13-week direct-method cash forecast for a services business, with revolver logic, a collections priority list, data checks, an MCP server and an Excel export. An AI assistant can call it to answer "where is cash lowest, do we need to draw, and who should we chase this week?" and every number in the answer comes from the code.
It's a companion to fpa-variance-mcp and follows the same patterns: plain Python functions do the work, the MCP server is a thin layer on top, the checks run before anything is trusted, and a failed check sets the status to BLOCKED. All data is synthetic.
The problem
A 13-week cash forecast is the main tool treasury uses to see a cash squeeze before it happens. Building one by hand every week means re-pulling AR and AP, re-timing collections and payments, re-running the revolver math, and checking that it all still ties to the bank and the GL. The mechanics are the slow part, and they're where mistakes slip in: AR that doesn't tie to the control account, a borrowing base that's off, a week that doesn't roll.
The useful part is the judgment: which week is tight, whether to draw, and which invoices to push on. I wanted the mechanics done the same way every week so the time goes into that.
Related MCP server: fincon
What it does
Weekly forecast, direct method. Receipts split between existing AR and new billings. Disbursements for payroll, existing and new AP, rent/insurance/software, term loan principal and interest, and revolver interest and fees. Net cash flow, cash before the revolver, draw/repay, ending cash, revolver balance, borrowing base, availability and liquidity, with flags by week.
Collections timing from customer behavior. Each invoice is collected in the week of its due date plus that customer's average days late. Invoices more than 120 days past due are listed separately and not forecast.
Borrowing base with standard ineligibles. 85% of eligible AR, where eligible excludes invoices 90+ days from invoice date, all of a customer's AR when more than half of it is past 90 (cross-age), and any customer's AR above 20% of the eligible total (concentration). It's recalculated every week on the AR still open.
Revolver logic. Draws just enough to hold minimum cash, limited by availability (the lesser of the commitment and the borrowing base, less what's drawn). Repays with cash above minimum plus a $1M cushion. Interest and the unused fee accrue weekly on the beginning balance and are paid on the first business day of each month.
Liquidity check. Lowest cash week (before and after the revolver), lowest liquidity week, peak revolver balance (incl. opening), and any week below minimum cash or the liquidity floor. The peak counts the opening revolver balance, so a forecast that only pays the line down reports the opening balance as its peak.
Collections priorities. AR over 60 days, grouped by customer and ranked by how much cash collecting it now would bring into the 13-week window, then by how much would land before the low-cash week. Each customer shows its invoices, oldest days outstanding, usual lateness, and whether it's cross-aged out of the borrowing base. This is the agenda for the weekly cash call.
Checks. AR detail ties to the AR control total, opening cash ties to the bank, the borrowing base recalculates from invoice detail and matches the certificate, the opening revolver is inside the borrowing base, and ending cash rolls forward every week. Any failure sets the status to
BLOCKED.Scenarios.
customer_delay(customer, extra_days)andstretch_ap(days)rerun the forecast and report the change in the lowest liquidity, peak revolver balance (incl. opening), total draws and receipts in the window against the base case, plus the same comparison for the base case's low-cash week (week 7).Liquidity stress.
stress()(MCP:run_scenario(kind="stress")) is a downside case built to break the $5M liquidity floor. The largest customer by billings (Northfield Transit Authority) stops billing from week 3 and its open AR pays 60 days later; the lender takes a $3.5M borrowing-base reserve in every week and treats that customer's AR as ineligible from week 3. Liquidity bottoms at about $4.68M in week 7 (w/e 2027-01-17), $324K under the floor, andliquidity_checkflags the week and setspolicy_breached. Tuning note: the first cut (stop billing plus a $2M reserve) only took liquidity down to about $7.49M, mainly because the delayed AR still counts in the borrowing base. Treating the stressed customer's AR as ineligible and raising the reserve to $3.5M is what pushes week 7 under the floor.Excel export. One workbook: 13-Week Forecast, Liquidity, Collections Priorities, Checks. Inputs are blue. Totals, net cash flow, beginning and ending cash, the revolver draw and repay (
MIN/MAXformulas that refer to the minimum-cash and cushion input cells), revolver interest and the unused fee, eligible AR, the borrowing base, availability and liquidity are live formulas. If you change minimum cash, the cushion or the revolver rate in the workbook, the revolver and its interest re-run. After writing, the export recalculates every formula, confirms there are zero errors, and ties ending cash, the revolver balance, revolver interest and liquidity back to the engine. The Liquidity tab ends with a summary: peak revolver balance (incl. opening) as=MAX(opening revolver, weekly balances), lowest liquidity, and aCOUNTIFof weeks below the floor; the flag row marks those weeks BELOW FLOOR. It also shows the lender-excluded AR and the borrowing-base reserve as inputs.
Tools
Tool | What it does |
| The weekly forecast with all lines, flags, AR not forecast, and the status |
| Lowest cash and liquidity weeks, peak revolver balance (incl. opening), policy breaches |
| AR over 60 days by customer, ranked by cash it would bring into the window |
|
|
| The controls on their own, with the status |
| The formatted workbook, recalculated and tied out |
The server instructions tell the client to lead with the lowest cash and liquidity weeks, never to invent or estimate numbers, and to state the status.
Sample company
sample_data.py builds a SQLite database for the same made-up ~$100M services business as fpa-variance-mcp: six divisions in two regions. The forecast starts Monday, November 30, 2026 and runs 13 weeks.
Opening cash of $4.05M in one operating account
25 customers on net 30/45/60, each with an average days late and a variability. Most pay 0–10 days late. Northfield Transit Authority, the largest, runs about 20 days late on net 45.
About 300 open AR invoices ($12.06M), aged up to 200+ days, about 6% over 90 days
New billings of about $1.9M a week by division, light over the holidays and ramping in January
Biweekly payroll of $1.3M on Fridays, with the first January run higher because employer payroll taxes reset
150 open vendor invoices ($2.2M), including an $800K subcontractor milestone due Jan 12; new AP accrues at 45% of billings and is paid on 21-day terms
Rent on the 1st, software on the 15th, a quarterly insurance premium in January
A $15M revolver with $3M drawn, 85% advance on eligible AR (exclusions above), SOFR + 3.00%, 0.375% unused fee. A $20M term loan at SOFR + 3.50% with 1% quarterly amortization, paid on the last business day of the quarter. SOFR is a flat 3.65% assumption.
Policy: $2M minimum operating cash, $5M liquidity floor (cash plus availability)
Planted stories:
Week 5 (w/e Jan 3): a payroll run, the quarter-end term loan principal and interest, and light holiday collections land together. Cash before the revolver gets down to about $2.07M, just above minimum.
Week 7 (w/e Jan 17): the January payroll with the tax reset, the insurance premium, software and the subcontractor milestone hit while collections from the light December billings are still coming in. Cash before the revolver falls to about $1.45M and the forecast draws about $548K to hold the $2M minimum.
Northfield: its lateness is the biggest swing. Several of its large invoices are due to land in weeks 6 and 7. If it pays 30 days later still, they slip past the trough: week 7 cash drops another $516K, the week 7 draw nearly doubles, about $957K of receipts leave the window, and the lowest liquidity drops $273K. The delay also ages its invoices past 90 days and pushes it over the 20% concentration cap, so availability falls too. If it paid on terms, the week 7 draw would shrink to about $146K.
Cross-age: Hillsborough Flats HOA has more than half its AR past 90 days, so all of it is out of the borrowing base in week 1.
See examples/sample_output.md for the full demo output.
Setup
The virtual environment lives outside the repo (this folder syncs to iCloud):
python3.15 -m venv ~/.venvs/cash-forecast-13wk
source ~/.venvs/cash-forecast-13wk/bin/activate
pip install -e ".[dev]"
python scripts/generate_data.py # optional: the server builds data/cash.db on first run
python scripts/demo.py # 13-week summary, scenarios, and an Excel export in exports/
pytestClaude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"cash-forecast-13wk": {
"command": "/Users/YOU/.venvs/cash-forecast-13wk/bin/python",
"args": ["-m", "cash_forecast.server"]
}
}
}Optional environment variables: CASH_DB_PATH (database location, default data/cash.db) and CASH_EXPORT_DIR (default exports/).
Layout
src/cash_forecast/
sample_data.py synthetic company, seeded and deterministic
forecast.py engine: forecast, liquidity_check, collections_priorities, run_checks, scenarios
export.py Excel workbook, plus the recalculation and tie-out
server.py MCP server (thin layer over forecast.py and export.py)
scripts/ generate_data.py, demo.py
tests/ pytest
examples/ sample_output.mdAssumptions and limits
Collections use each customer's average days late. The variability is stored and shown on the collections list but not used to spread the forecast.
Invoices already past a customer's usual pay date (but not more than 120 days past due) are assumed to come in three weeks out.
The borrowing base covers past-90, cross-age and concentration. It doesn't model contras, government receivables or other lender-specific ineligibles.
Each monthly revolver interest payment covers what accrued through the prior week, so a partial week of interest rolls into the next month's payment.
In Excel, the ineligible AR amounts are inputs from the engine; they're invoice-level calculations that don't belong in a formula.
The liquidity floor isn't tested in the base case: with a $15M commitment and about $9–12M of borrowing base, liquidity stays above $10M. The
stressscenario is what tests it (low of about $4.68M in week 7).
What I'd add next
Forecast vs actual tracking. Save each week's forecast and compare it with what happened, by line, so the collection and payment assumptions get better over time.
Indirect-method bridge. Tie the 13-week view to the monthly P&L and balance sheet (EBITDA to cash through working capital), so the treasury and FP&A numbers reconcile.
Multi-entity. Several legal entities and bank accounts, intercompany sweeps, and cash that's trapped in one entity versus available to the borrower.
How this was built
I designed it and built it with Claude Code. I set the logic, the controls and the assumptions, and I checked the numbers.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Purchase orders, approvals, accruals and month-end close for finance teams, from your AI assistant.
Read-only finance and operations controls for AI agents with evidence and safe next actions.
Week-by-week cash forecast for 13 weeks, based on how customers actually pay.
Personal wealth planning and forecasting. 53 read/write tools: accounts, goals, plans and forecasts.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to perform financial analysis, budget forecasting, compliance checks, expense categorization, and risk assessment, returning structured JSON with audit-ready governance receipts.5105 npm1Business Source 1.1
- FlicenseBqualityDmaintenanceEnables AI assistants to perform financial reconciliation with a deterministic proof engine: intake files, match transactions, verify proofs, resolve exceptions, and sign off on balanced journals under the user's authority.21-

OpenVariance MCP Serverofficial
AlicenseNot gradedqualityBmaintenanceEnables AI agents to perform variance analysis, generate reconciling driver bridges and three-statement forecasts, export Excel workbooks, and analyze SEC or private-company financial data locally with engine-verified calculations.MIT- AlicenseNot gradedqualityCmaintenanceEnables small-business owners to turn bank CSVs and open invoices into spoken cash-position answers, 13-week forecasts, affordability checks, and ranked cash-shortfall plans, with human-confirmed sandbox actions.MIT