Skip to main content
Glama
MCP Financial Calculator

MCP Financial Calculator

MCP Financial Calculator

中文说明

A Node.js MCP service that provides:

  • Basic arithmetic: add, subtract, multiply, divide

  • Cash flow and return tools: xnpv, xirr, npv, irr, mirr

  • Time value of money tools: pv, fv, pmt, nper, rate

  • Other metrics: cagr, payback_period, discounted_payback_period

1. Install

npm install

Related MCP server: wealth-engine

2. Start

npm start

The service communicates with MCP clients via stdio.

3. Run Tests

npm test

4. MCP Config Example

{
  "mcpServers": {
    "financial-calculator": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-financial-calculator/src/index.js"]
    }
  }
}

5. Tool Input Examples

  1. xnpv Input:

{
  "rate": 0.1,
  "cashflows": [
    { "amount": -10000, "date": "2024-01-01" },
    { "amount": 12000, "date": "2025-01-01" }
  ]
}
  1. xirr Input:

{
  "cashflows": [
    { "amount": -10000, "date": "2024-01-01" },
    { "amount": 12000, "date": "2025-01-01" }
  ],
  "guess": 0.1
}
  1. npv Input:

{
  "rate": 0.1,
  "cashflows": [-10000, 3000, 4200, 6800]
}
  1. irr Input:

{
  "cashflows": [-10000, 3000, 4200, 6800],
  "guess": 0.1
}
  1. mirr Input:

{
  "cashflows": [-10000, 3000, 4200, 6800],
  "financeRate": 0.08,
  "reinvestRate": 0.1
}
  1. pv Input:

{
  "rate": 0.01,
  "nper": 12,
  "pmt": -1000,
  "fv": 0,
  "type": 0
}
  1. fv Input:

{
  "rate": 0.01,
  "nper": 12,
  "pmt": -1000,
  "pv": 0,
  "type": 0
}
  1. pmt Input:

{
  "rate": 0.01,
  "nper": 12,
  "pv": 10000,
  "fv": 0,
  "type": 0
}
  1. nper Input:

{
  "rate": 0.01,
  "pmt": -1000,
  "pv": 10000,
  "fv": 0,
  "type": 0
}
  1. rate Input:

{
  "nper": 12,
  "pmt": -1000,
  "pv": 10000,
  "fv": 0,
  "type": 0,
  "guess": 0.01
}
  1. cagr Input:

{
  "beginningValue": 100,
  "endingValue": 150,
  "years": 3
}
  1. payback_period Input:

{
  "cashflows": [-10000, 3000, 4200, 6800]
}
  1. discounted_payback_period Input:

{
  "discountRate": 0.1,
  "cashflows": [-10000, 3000, 4200, 6800]
}

6. Parameter Constraints

  • Cashflow tools usually require at least 2 values.

  • xirr, irr, and mirr require both positive and negative cashflows.

  • Rate parameters must be greater than -1.

  • Irregular cashflow date must be strict YYYY-MM-DD.

  • type only supports 0 (end of period) or 1 (beginning of period).

7. Code Structure

  • src/index.js: MCP server bootstrap only

  • src/tools/: tool registration modules

  • src/lib/finance.js: financial algorithms

  • src/lib/result.js: unified result format

  • src/schemas.js: input validation schemas

8. Finance Concepts in Plain Language

  • NPV / XNPV: Convert future cashflows into today's value by discounting them with a rate. If NPV is positive, the investment is better than your required return.

  • IRR / XIRR: Find the rate that makes NPV equal to 0. This project uses numerical solving because there is usually no closed-form formula.

  • MIRR: A more stable alternative to IRR with two explicit assumptions: borrowing cost (financeRate) and reinvestment return (reinvestRate).

  • PV / FV: PV asks "what is a future amount worth today?" and FV asks "what will today's plan be worth in the future?".

  • PMT / NPER / RATE: Loan or savings planning trio: PMT = payment per period, NPER = number of periods, RATE = implied periodic interest rate.

  • CAGR: Smoothed annual growth rate from a start value to an end value over years.

  • Payback Period: How long until cumulative cashflows recover the initial outflow.

  • Discounted Payback Period: Same as payback period, but each future cashflow is discounted first.

9. Sign Convention (Important)

  • Outflow (money you pay) should be negative.

  • Inflow (money you receive) should be positive.

  • Mixed signs are required for IRR, XIRR, and MIRR.

10. Notes on Numerical Results

  • Floating-point math is approximate, so tiny differences are normal.

  • XNPV / XIRR use an Actual/365 day basis in this implementation.

Available Tools

17 tools
addB

Add two numbers.

Inputs: a (required), b (required).

cagrC

Calculate compound annual growth rate.

Inputs: years (required), endingValue (required), beginningValue (required).

discounted_payback_periodC

Calculate discounted payback period for periodic cashflows.

Inputs: cashflows (required), discountRate (required).

divideA

Divide a by b.

Inputs: a (required), b (required).

fvD

Calculate future value.

Inputs: pv (required), pmt (required), nper (required), rate (required), +1 more.

irrB

Calculate IRR for periodic cashflows.

Inputs: cashflows (required), guess.

mirrC

Calculate MIRR for periodic cashflows.

Inputs: cashflows (required), financeRate (required), reinvestRate (required).

multiplyA

Multiply two numbers.

Inputs: a (required), b (required).

nperC

Calculate number of periods.

Inputs: pv (required), pmt (required), rate (required), fv, +1 more.

npvB

Calculate NPV for periodic cashflows (index as period).

Inputs: rate (required), cashflows (required).

payback_periodC

Calculate payback period for periodic cashflows.

Inputs: cashflows (required).

pmtC

Calculate payment amount per period.

Inputs: pv (required), nper (required), rate (required), fv, +1 more.

pvC

Calculate present value.

Inputs: fv (required), pmt (required), nper (required), rate (required), +1 more.

rateC

Calculate rate per period (numerical solve).

Inputs: pv (required), pmt (required), nper (required), fv, +2 more.

subtractA

Subtract b from a.

Inputs: a (required), b (required).

xirrC

Calculate XIRR from irregular cashflows.

Inputs: cashflows (required), guess.

xnpvC

Calculate XNPV from irregular cashflows and a discount rate.

Inputs: rate (required), cashflows (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 17 tools

    Disambiguation4/5

    Each tool maps to a distinct financial formula, and pairs like irr/xirr, npv/xnpv, and rate/cagr are separated by the periodic-vs-irregular cashflow distinction stated in their descriptions. The add/subtract/multiply/divide group is trivially distinct but feels tangential to the financial-analysis core, and a couple of near-neighbors (irr vs xirr, cagr vs rate) still require reading descriptions to pick correctly.

    Naming Consistency4/5

    All names are lowercase snake_case using standard finance abbreviations (xirr, nper, mirr, discounted_payback_period), which reads predictably as a set. There is no verb_noun convention, but that is appropriate for a calculator where the tool name is the formula, so consistency holds with only minor length deviations.

    Tool Count4/5

    At 17 tools the surface is on the heavy side, but each corresponds to a specific, non-redundant financial function rather than a variant of the same action. The four basic arithmetic tools are the only entries that feel like padding for a 'financial calculator' scope.

    Completeness4/5

    The set covers time value of money (fv, pv, pmt, nper, rate), cashflow valuation (npv, xnpv, irr, xirr, mirr), and payback analysis, which is solid coverage for the stated purpose. Minor gaps remain around amortization schedules, effective/nominal rate conversion, and compounding helpers, but agents can compose these from existing tools.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      An MCP server and CLI providing business, financial, and tax calculations including math expressions, income tax estimates, loan amortization, depreciation, and more.
      10
      2
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A personal finance and business economics MCP server that provides math-backed answers to financial questions, including investment growth, loan amortization, debt payoff strategies, and tax estimation, all computed locally without API keys or network calls.
      11
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A quantitative finance MCP server providing 24 tools for option pricing, portfolio optimization, risk measurement, fixed income analysis, and utility functions, enabling AI clients to perform professional financial calculations.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      An MCP server that provides deterministic, high-precision business, finance, and operational calculations such as SaaS metrics, currency conversion, business days, and financial formulas, returning structured JSON results.
      11
      49 npm
      MIT