Skip to main content
Glama
cashflow-mcp-server

cashflow-mcp-server

cashflow-mcp-server

An MCP server that lets an agent evaluate a real financing decision: IRR, NPV, payback, working capital, break-even and sensitivity analysis, exposed as tools.

Built on cashflow-engine, a deterministic project cash flow engine. Every tool is a pure computation. No network, no filesystem, no clock, no state between calls.


Why an MCP server for this

Language models are unreliable at multi-step financial arithmetic and very good at the part around it: eliciting terms from a conversation, naming what is being assumed, and explaining what a number means. Splitting those responsibilities is the point.

The model gathers the deal. The engine does the arithmetic. The model reads the result back.

That split also makes the output auditable, which matters more here than in most domains. The same model always produces the same schedule, the schedule is returned alongside the metrics, and every tool is annotated readOnlyHint and idempotentHint, so any call can be repeated and checked.

Related MCP server: mcp-agent-cost-optimizer

Install

npm install
npm run build

Then register it with your MCP client. For Claude Code:

claude mcp add cashflow -- node /absolute/path/to/cashflow-mcp-server/dist/index.js

Or add it to a client config directly:

{
  "mcpServers": {
    "cashflow": {
      "command": "node",
      "args": ["/absolute/path/to/cashflow-mcp-server/dist/index.js"]
    }
  }
}

Inspect it interactively with npm run inspector.

Tools

Tool

What it answers

cashflow_model_template

"How do I shape a contract?" Returns a filled-in, valid model to edit

cashflow_evaluate_contract

"Is this deal worth doing?" Full schedule and metrics

cashflow_run_sensitivity

"What breaks it?" Scenarios against the base case

cashflow_compare_contracts

"Which of these variants wins?" Two to five, ranked

cashflow_breakeven

"How many units a month do we need?"

cashflow_analyze_flows

"What is the IRR of this vector?" Works on raw flows

cashflow_loan_terms

"What is the payment, and what does the interest cost?"

cashflow_convert_rate

"Is 1% a month the same as 12% a year?" It is not

A worked exchange

User: We would install 3.5 million of equipment at a hospital, run it for five years, and bill a monthly fee plus per-cycle charges. Is that worth doing?

The agent calls cashflow_model_template to get a shape, fills in the terms from the conversation, calls cashflow_evaluate_contract, and gets back an 81% IRR with payback at month 20 and one warning: net working capital exceeds three months of EBITDA.

User: What if they only send us 80% of the volume they promised?

cashflow_run_sensitivity returns the IRR falling by 46 percentage points and payback sliding from month 20 to month 37. That is the answer the deal actually turns on, and it took one more call.

Design decisions worth defending

Absent values are never sentinel numbers. A contract with no outflow has no IRR. irrAnnual comes back null with irrUnavailableReason set, and the markdown says "not reportable". Returning -1 or 0 invites an agent to format it as a percentage and put it in front of a customer. Same for payback: null means "not within the term", not month zero.

Ranking puts missing values last. In cashflow_compare_contracts, a variant with no IRR sorts to the bottom rather than to the top. No IRR is not a low IRR, and "never paid back" is not a fast payback.

Schedules are summarized by default. A 60-month contract is 61 rows of eleven fields. schedule_detail defaults to annual, which is almost always what the question needs, and monthly is there when a specific month is in dispute.

Schemas are strict. An unrecognized field is rejected rather than dropped. An agent that invents taxRate or currency should be told the engine does not model it, not have it silently ignored and the result reported as authoritative.

Both rate conventions are exposed, and named apart. Discounting compounds. Amortization divides. cashflow_convert_rate returns both side by side every time, because the failure mode is not getting the arithmetic wrong, it is not noticing there were two conventions.

Every tool is openWorldHint: false. These are functions, not integrations. The annotation says so, and the test suite asserts it.

Testing

npm test

Twenty tests drive the real server through a real MCP client over an in-memory transport. Nothing is stubbed, so a broken input schema, a mismatched outputSchema or a renamed tool fails in the suite rather than in a host.

Expected values are derived by hand or from known references: the textbook 30-year mortgage payment, a break-even case solvable on paper, a payback that falls on a month you can count to.

Evaluations

evaluations/evaluation.xml holds ten questions that require several tool calls each, with verified answers. Because the engine is deterministic and the templates ship with the server, the answers do not drift.

Scope

This server computes cash flows. It does not convert currencies, apply tax, read files, or recommend a decision. It has no opinion about your industry's numbers: every rate, price and cost is an input.

It is also not investment advice. It is arithmetic you can check.

License

MIT

Available Tools

8 tools
cashflow_analyze_flowsAnalyze a raw cash flow vectorA
Read-onlyIdempotent

Compute NPV, IRR and payback directly on a list of period cash flows, with no contract model involved.

Use this when the numbers already exist, for example flows lifted from a spreadsheet, a schedule produced elsewhere, or a quick sanity check.

The first element sits at period 0 and is not discounted. Outflows are negative.

Args:

  • flows (array of numbers): Cash flow per period, flows[0] at t=0. Needs at least 2 entries.

  • period ('monthly' | 'annual'): What one element represents. Default 'monthly'. Determines how the rate is annualized.

  • discount_rate_annual (number): Effective annual rate for NPV, e.g. 0.14 for 14%. Default 0.

  • interpolate_payback (boolean): Return a fractional payback period instead of whole periods. Default false.

Returns: npv, irrAnnual, irrPeriodic, irrAvailable, irrUnavailableReason, payback and cumulative totals.

irrAnnual is null when the vector has no reportable IRR: no outflow, no inflow, or flows that never sum positive. The reason says which.

A vector whose sign changes more than once may have several real IRRs. The engine returns one and flags nothing, which is a property of IRR itself. signChanges is reported so you can tell when to trust NPV instead.

Examples:

  • Use when: "What is the IRR of -1000, 500, 500, 500?"

  • Use when: "Discount these annual flows at 12% and tell me the NPV."

  • Don't use when: you have contract terms rather than flows (use cashflow_evaluate_contract)

Inputs: flows (required), period, interpolate_payback, discount_rate_annual. Returns: npv, payback, netTotal, irrAnnual, +7 more

cashflow_breakevenBreak-even volumeA
Read-onlyIdempotent

Compute the monthly volume at which a contract stops losing money, without running the full schedule.

Contingency is folded into the contribution margin rather than added to fixed cost, because total cost is (fixed + maintenance + variable x u/u0) x (1 + contingency): contingency multiplies both sides. Fixed revenue offsets fixed cost, so a contract whose flat fee already covers its fixed base breaks even at zero units.

Escalation is excluded on purpose. Break-even is a statement about the base year.

Args:

  • model (object): The contract, same shape as cashflow_evaluate_contract.

  • volume_factor (number): Scales planned volume before solving. Default 1.

Returns: units, revenue, marginOfSafetyPct, averagePrice, variableCostPerUnit and contributionPerUnit. Returns null when the model has no metered streams to break even on, and unitsUnreachable true when contribution per unit is zero or negative.

Examples:

  • Use when: "How many units a month do we need to cover costs?"

  • Use when: "How much headroom is there between plan and break-even?"

Inputs: model (required), volume_factor. Returns: breakeven, hasMeteredVolume

cashflow_compare_contractsCompare contract variantsA
Read-onlyIdempotent

Evaluate two to five named contract variants and rank them side by side.

Built for the question these models exist to answer: pay cash or finance, 24 months interest-free or 36 with interest, higher fixed fee or higher per-unit price, 3-year term or 5-year.

Args:

  • variants (array): 2 to 5 entries of { name, model }.

  • rank_by ('npv' | 'irr' | 'payback'): Which metric orders the result. Default 'npv'.

  • response_format ('markdown' | 'json'): Default 'markdown'.

Returns: variants[] ordered best first by the chosen metric, each with its headline metrics and financing cost, plus the name of the winner.

Ranking by IRR places variants without a reportable IRR last, because an absent IRR is not a low one.

Examples:

  • Use when: "Should we take the 24-month interest-free plan or pay cash?"

  • Use when: "Compare a 3-year and a 5-year term on the same contract."

Inputs: variants (required), rank_by, response_format. Returns: winner, rankedBy, variants

cashflow_convert_rateConvert between rate conventionsA
Read-onlyIdempotent

Convert an annual rate to a monthly one and back, under either convention.

'compound' is the discounting convention: (1 + annual)^(1/12) - 1. 'divide' is the loan convention: annual / 12. A 12% annual rate is 0.9489% per month compounded but 1% per month divided, and using one where the other belongs quietly distorts every downstream number.

Args:

  • value (number): The rate to convert, e.g. 0.14 for 14%.

  • direction ('annual_to_monthly' | 'monthly_to_annual'): Which way to convert.

  • convention ('compound' | 'divide'): 'compound' for discounting, 'divide' for amortization.

Returns: input, output, and both conventions side by side so the difference is visible.

Examples:

  • Use when: "What monthly rate should I discount at for a 14% cost of capital?"

  • Use when: "Is 1% a month the same as 12% a year?"

Inputs: value (required), direction, convention. Returns: input, output, divided, direction, +2 more

cashflow_evaluate_contractEvaluate a contractA
Read-onlyIdempotent

Expand a contract into a month-by-month cash flow schedule and compute the metrics that follow from it: IRR, NPV, simple and discounted payback, MOIC, ROI, working capital, break-even volume, and the financing cost of any asset paid in installments.

Use this as the main entry point whenever someone asks whether a deal, contract, lease, managed-service agreement or equipment purchase is worth doing.

Args:

  • model (object): The contract. Call cashflow_model_template first if you are unsure how to shape it.

  • schedule_detail ('none' | 'annual' | 'monthly'): How much of the schedule to return. Default 'annual'. Ask for 'monthly' only when a specific month matters; a 60-month contract returns 61 rows.

  • response_format ('markdown' | 'json'): Default 'markdown'.

Returns: metrics (IRR, NPV, payback, MOIC, ROI, EBITDA), financing, workingCapital, breakeven, annual rollup, optional schedule, and warnings.

irrAnnual is null when the flows have no reportable IRR, with the reason in irrUnavailableReason. Treat null as "no IRR exists", never as zero. paybackMonth is null when the investment is never recovered within the term.

Examples:

  • Use when: "Is this 5-year service contract worth signing?"

  • Use when: "What is the IRR and payback on this equipment deal?"

  • Don't use when: comparing two or more variants (use cashflow_compare_contracts)

  • Don't use when: stress-testing assumptions (use cashflow_run_sensitivity)

Error handling: Returns a validation error naming the offending field if the model is malformed.

Inputs: model (required), response_format, schedule_detail. Returns: annual, metrics, schedule, warnings, +4 more

cashflow_loan_termsInstallment plan termsA
Read-onlyIdempotent

Compute the level monthly payment that amortizes a principal, plus the total paid and the interest it costs.

Matches the spreadsheet PMT(rate/12, nper, -pv) convention, including the zero-rate case, so the output can be checked against Excel cell by cell.

Note the rate convention: loans divide the annual rate by 12, they do not compound it. This tool divides. Discounting elsewhere in this server compounds. Mixing the two is the most common error in a hand-built model.

Args:

  • principal (number): Amount financed.

  • term_months (integer): Number of level payments. 0 means paid in cash.

  • annual_rate (number): Nominal annual rate, e.g. 0.12 for 12% APR. Use 0 for an interest-free plan.

  • include_amortization (boolean): Return the per-month interest and principal split. Default false.

Returns: monthlyPayment, totalPaid, interestPaid, and optionally an amortization schedule of { month, payment, interest, principal, balance }.

Examples:

  • Use when: "What is the payment on 3.5 million over 36 months at 12%?"

  • Use when: "How much interest does the 36-month plan cost versus 24 months interest-free?"

Inputs: principal (required), term_months (required), annual_rate, include_amortization. Returns: totalPaid, monthlyRate, amortization, interestPaid, +1 more

cashflow_model_templateGet a contract templateA
Read-onlyIdempotent

Return a filled-in, valid contract model to copy and edit.

Call this first when you are about to build a model and are unsure how the fields fit together. Editing a working example is faster and safer than assembling one from the schema, and the returned object is guaranteed to validate.

Three shapes are available:

  • 'managed_service': exercises every field, including metered streams, staged investments, a financed asset with interest, maintenance and working capital.

  • 'subscription': flat fee, no metered volume, no financed asset.

  • 'equipment_lease': fully metered revenue, interest-free installments, residual value.

Args:

  • template ('managed_service' | 'subscription' | 'equipment_lease'): Which shape. Default 'managed_service'.

Returns: model (the object to pass to the other tools), notes (what the shape is for), and conventions (the rules that govern every model).

Examples:

  • Use when: "Help me model a service contract" and no model exists yet.

  • Use when: you need to check what a field is called or how it is shaped.

Inputs: template. Returns: model, notes, template, conventions

cashflow_run_sensitivityStress-test a contractA
Read-onlyIdempotent

Re-evaluate a contract under a set of scenarios and report each one against the base case.

Five scenarios run by default: volume -20%, volume -10%, volume +20%, no price indexation, and operating cost +10%. Pass your own scenarios to override them.

Volume is listed first on purpose: a volume forecast taken from a customer's own estimate is a negotiating position, not a measurement, and it is the assumption that breaks most often.

Args:

  • model (object): The contract, same shape as cashflow_evaluate_contract.

  • scenarios (array, optional): Custom scenarios. Each has id, label, and any of volumeFactor, priceFactor, costFactor, revenueEscalation, costEscalation.

  • response_format ('markdown' | 'json'): Default 'markdown'.

Returns: base (the unmodified case) and scenarios[], each with irrAnnual, npv, paybackMonth, irrDeltaPoints (percentage points against base, null when either side has no IRR) and npvDelta.

Examples:

  • Use when: "What happens to this deal if volume comes in 20% under plan?"

  • Use when: "How fragile is the return to the inflation clause?"

Inputs: model (required), scenarios, response_format. Returns: base, scenarios

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a clearly distinct purpose: raw cash-flow vectors, contract models, sensitivity scenarios, variant comparison, break-even, loan payments, and rate conversion. The closest pair (cashflow_analyze_flows vs cashflow_evaluate_contract) is cleanly separated by explicit use and don't-use guidance. Agent misselection risk is low.

    Naming Consistency4/5

    All tools share the cashflow_ prefix, and most follow a verb_noun pattern such as analyze_flows, evaluate_contract, run_sensitivity, and compare_contracts. A few names like model_template, loan_terms, and breakeven are noun-like deviations, but the overall pattern remains recognizable and predictable.

    Tool Count5/5

    Eight tools is a well-scoped size for a cash-flow modeling server. Each tool earns its place and covers a distinct workflow without redundancy or feature bloat.

    Completeness5/5

    The surface covers the full modeling lifecycle: template generation, contract evaluation, raw flow analysis, sensitivity testing, variant comparison, break-even computation, loan amortization, and rate conversion. Common cash-flow questions all have a direct tool with no obvious dead ends.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      A deterministic what-if scenario simulation MCP server that projects business metrics over time with exact decimal arithmetic, offering sensitivity analysis and break-even solving.
      6
      39 npm
      1
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Provides AI agents with deterministic, offline finance tools for commodity margin analysis, loan covenant compliance, invoice auditing, AP exception classification, and five-day close readiness.
      14
      3 npm
      -
    • A
      license
      B
      quality
      C
      maintenance
      Enables Hermes agents to build and run auditable startup financial models, validate inputs, execute linked-statement scenarios, verify results, summarize outcomes, and perform sensitivity analyses through six finance tools.
      6
      1
      MIT