canli-mcp / Value at risk

How do I calculate a portfolio's value at risk with AI?

canli-mcp's portfolio_var works out value at risk from your positions and return history, on your own machine with no key. For $60,000 of stocks and $40,000 of bonds over 20 days of sample returns, one-day historical value at risk at 95% confidence was $1,513. These returns are made up, and 20 days is too few for a real answer.

Price: $0 to run. Updated 2026-11-02. Free and MIT-licensed, with no account and no API key. Or run claude mcp add canli -- npx -y canli-mcp in Claude Code.

Ask it

I hold $60,000 of stocks and $40,000 of bonds, with these daily returns. What is my one-day value at risk?

The agent finds the tool through canli-mcp's find_tool and runs it through run_tool. This is the call:

{
  "name": "portfolio_var",
  "arguments": {
    "positions": [
      60000,
      40000
    ],
    "returns": [
      [
        0.012,
        0.006
      ],
      [
        -0.008,
        -0.002
      ],
      [
        0.004,
        0.001
      ],
      [
        0.021,
        0.009
      ],
      [
        -0.015,
        -0.007
      ],
      [
        0.007,
        0.004
      ],
      [
        -0.003,
        -0.001
      ],
      [
        0.011,
        0.005
      ],
      [
        -0.022,
        -0.011
      ],
      [
        0.009,
        0.003
      ],
      [
        0.005,
        0.002
      ],
      [
        -0.012,
        -0.005
      ],
      [
        0.016,
        0.007
      ],
      [
        -0.006,
        -0.003
      ],
      [
        0.002,
        0.001
      ],
      [
        0.013,
        0.006
      ],
      [
        -0.019,
        -0.009
      ],
      [
        0.008,
        0.004
      ],
      [
        0.003,
        0.002
      ],
      [
        -0.004,
        -0.001
      ]
    ],
    "confidence": 0.95,
    "names": [
      "Stocks",
      "Bonds"
    ]
  }
}

What came back

Recorded from canli-mcp 0.16.1 on 2026-11-02, with no API key set. The model read 512 characters.

The result portfolio_var sent back
{
  "ref": "r4",
  "historical_var": 1513,
  "historical_es": 1760,
  "parametric_var": 1443.13,
  "parametric_es": 1832.1,
  "es_contribution": {
    "Stocks": 1320,
    "Bonds": 440
  },
  "parametric_var_contribution": {
    "Stocks": 1174.63,
    "Bonds": 356.5
  },
  "sum_of_standalone_var": 1533.26,
  "diversification_benefit": 2.13062,
  "tail_scenarios": 1,
  "method": "Historical: empirical quantile of portfolio P&L (linear interpolation); contributions are each position's average P&L in the tail. Parametri…"
}

Prices, filings and statistics are as the sources published them on that day; run the call again for today's. Nothing here is investment advice.

The tools behind the answer

From canli-mcp's tool index
ToolPackWhat it does
portfolio_varquantCompute a positions portfolio's historical and parametric (normal) value at risk and expected shortfall from asset return history, with each position's contribution and the diversification benefit.

Add canli-mcp

Claude Code
claude mcp add canli -- npx -y canli-mcp
Cursor, Claude Desktop or any MCP client
{ "mcpServers": { "canli": { "command": "npx", "args": ["-y", "canli-mcp"] } } }
claude.ai, ChatGPT or any client that takes a URL
https://canlicapital.com/mcp/canli

Everything canli-mcp does · How it compares with other finance MCP servers

Related questions