DEV Community

Jordan Rothstein for Raziel

Posted on AI-assisted

Stop letting your AI agent guess IRR: exact finance math with a free API and MCP server

Ask a chat model for the IRR of a few dated cash flows and you'll usually get a confident number. Ask it again and you may get a different one. That's not a bug in the model. IRR has no closed-form solution, so the model is pattern-matching its way to something plausible instead of running a solver.

For anything people make decisions on (an angel's returns, a SAFE converting in a priced round, a fund's TVPI), "plausible" isn't good enough. The fix is old-fashioned: give the agent a tool that does the math, and let the model do what it's good at, which is setting up the inputs and explaining the result.

We built that tool at Raziel and made it free: 25 finance calculators as a REST API and an MCP server, with no API key and no sign-up. This post shows how to use it from code and from an agent.

What's available

GET https://raziel.co/api/v1/calculators lists everything. Today that's 25 calculators, including:

Returns: irr, xirr, moic, cagr, tvpi_dpi, carried_interest
Startup equity: safe_conversion, convertible_note, dilution, option_pool, pro_rata, liquidation_preference, secondary_sale, startup_valuation
Tax and planning: qsbs, tax_deadlines, portfolio_allocation
Operating metrics: runway, burn_multiple, rule_of_40, ltv_cac, cac_payback, net_revenue_retention
Real estate: cap_rate, cash_on_cash

Each calculator has a JSON Schema for its inputs and a worked example at GET /api/v1/calculators/{name}, and there's a full OpenAPI 3.1 spec at https://raziel.co/api/openapi.json.

Example 1: XIRR for an angel investment

Say you put $50,000 into a startup on March 1, 2021, followed on with $25,000 on June 15, 2022, and the position is worth $180,000 today. Dates are irregular, so you need XIRR, not IRR.

bash
curl -s -X POST https://raziel.co/api/v1/calculators/xirr \
  -H 'content-type: application/json' \
  -d '{
    "cash_flows": [
      { "date": "2021-03-01", "amount_usd": -50000 },
      { "date": "2022-06-15", "amount_usd": -25000 },
      { "date": "2026-11-01", "amount_usd": 180000 }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Response:

json
{
  "ok": true,
  "calculator": "xirr",
  "result": {
    "xirr_pct": 18.06,
    "total_invested_usd": 75000,
    "total_returned_usd": 180000,
    "net_profit_usd": 105000,
    "moic": 2.4,
    "years": 5.67,
    "first_date": "2021-03-01",
    "last_date": "2026-11-01",
    "calculator_url": "https://raziel.co/tools/xirr-calculator"
  },
  "disclaimer": "For education only. Not tax, legal or investment advice.",
  "docs": "https://raziel.co/developers"
}

Enter fullscreen mode Exit fullscreen mode

Same convention as Excel's =XIRR(): negative amounts are money in, positive amounts are money out (or current value). You also get MOIC and the holding period for free, which is usually what the next question is about.

Example 2: a SAFE converting in a priced round

This is where models get it wrong most often, because the answer depends on whether the cap or the discount wins, and on the option pool top-up.

A $500,000 post-money SAFE with an $8M cap and a 20% discount. The company has 10M fully diluted shares (1M of them an unissued pool) and raises $5M at a $20M pre-money, with the pool topped up to 10% post-money:

bash
curl -s -X POST https://raziel.co/api/v1/calculators/safe_conversion \
  -H 'content-type: application/json' \
  -d '{
    "safe_type": "post",
    "investment_usd": 500000,
    "valuation_cap_usd": 8000000,
    "discount_pct": 20,
    "existing_shares": 10000000,
    "existing_pool_shares": 1000000,
    "priced_round_pre_money_usd": 20000000,
    "priced_round_raise_usd": 5000000,
    "target_pool_pct": 10
  }'
Enter fullscreen mode Exit fullscreen mode

The key fields in the result:

json
{
  "conversion_price_usd": 0.75,
  "round_price_usd": 1.810345,
  "converts_at": "cap",
  "safe_shares": 666666.67,
  "safe_ownership_pct": 4.83,
  "safe_multiple": 2.4138,
  "pool_top_up_shares": 380952.38,
  "cap_table_after_round_pct": {
    "existing_holders": 65.17,
    "option_pool": 10,
    "safe": 4.83,
    "new_investors": 20
  }
}
Enter fullscreen mode Exit fullscreen mode

The cap price ($0.75) beats the discount price ($1.45), so the SAFE converts at the cap and is worth about 2.4x its cost at the round price. That's the kind of answer you want your agent to quote, not estimate.

Using it from an agent (MCP)

The same calculators are exposed as an MCP server over Streamable HTTP at https://raziel.co/mcp. Once it's connected, the model sees each calculator as a tool with its schema and calls it when a question needs exact math.

Claude Code:

bash
claude mcp add --transport http raziel https://raziel.co/mcp

Enter fullscreen mode Exit fullscreen mode

Cursor, Claude Desktop and other MCP clients (mcp.json or equivalent):

json
{
  "mcpServers": {
    "raziel": { "url": "https://raziel.co/mcp" }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then ask something like: "I invested $25k in a SAFE with a $10M post-money cap and they just raised at $30M pre. What do I own after the round?" The agent fills in the safe_conversion inputs, calls the tool and explains the result. If an input is missing, a good agent asks you for it rather than guessing, because the schema marks it as required.

Using it from code

No SDK needed. Any HTTP client works:

javascript
const res = await fetch("https://raziel.co/api/v1/calculators/moic", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ invested_usd: 100000, value_returned_usd: 340000, years: 4 }),
});
const { ok, result, error } = await res.json();

Enter fullscreen mode Exit fullscreen mode

Invalid inputs come back with ok: false and a message naming the field, for example {"ok": false, "error": "\"invested_usd\" is required."}, so you can surface it to the user or let the agent retry. The API is rate limited per IP to keep it free for everyone. GET /api/v1/calculators/{name} returns each calculator's exact field names and an example body.

Why we built it

Raziel is a portfolio tracker for people who invest in private markets: startups, SAFEs, SPVs and fund commitments, with MOIC, IRR and TVPI calculated from real cash flows. The calculators are the same math the product uses. Making them a free public API means agents (and developers) stop shipping guessed numbers, and some of them find Raziel along the way. That's the trade.

Docs: raziel.co/developers · OpenAPI: raziel.co/api/openapi.json · Web versions of every calculator: raziel.co/tools

If there's a calculation you'd want added (we're looking at multi-SAFE stacks converting together next), leave a comment.

For education only, not tax, legal or investment advice.

Top comments (0)