risk-analytics-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@risk-analytics-mcp-server Compute 99% VaR for a 60/30/10 equity/bond/gold portfolio."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
risk-analytics-mcp-server
An MCP server that gives AI agents quantitative risk tools.
Any MCP client (Claude Code, Claude Desktop, or your own agent) gets seven tools backed by two real engines — market-risk-engine and credit-risk-model:
Tool | What it does |
| Portfolio VaR & Expected Shortfall four ways — historical, parametric-normal, Cornish-Fisher, Monte Carlo — so the agent can compare methods, not just get a number. |
| GARCH(1,1) fit by maximum likelihood (no |
| Walk-forward VaR backtest with Kupiec POF, Christoffersen independence / conditional-coverage tests, and the Basel traffic-light zone. |
| Preset crisis-shock library (GFC equity crash, 2020 pandemic, +200bp rates, flight to quality, USD squeeze) + the portfolio's own worst historical windows. |
| Peaks-over-threshold GPD tail fit; EVT VaR/ES for the 99.5%+ region where empirical quantiles run out of data. |
| 12-month PD, scorecard points and letter rating from a WoE logistic scorecard (PDO points scaling). |
| The scorecard's held-out AUROC/Gini/KS and per-feature Information Values. |
Every market tool works with no data at all — omit the returns and it
runs on a seeded 4-asset synthetic demo book (EQUITY/BOND/GOLD/FX, ~5
trading years), so an agent can explore the tools fully offline. Pass your
own daily returns (fractions, 0.01 = 1%) to analyze a real portfolio.
VaR/ES are reported as positive daily loss fractions.
The credit scorecard is trained once per process on the engine's seeded synthetic 12k-loan book and cached; the methodology (monotonic WoE binning, logistic regression, points scaling, ratings) is the production pattern, the score itself is a demo.
Install & connect
pip install git+https://github.com/chenxi-bot21/risk-analytics-mcp-server.gitClaude Code:
claude mcp add risk -- risk-mcpClaude Desktop / any MCP client (stdio transport):
{
"mcpServers": {
"risk": { "command": "risk-mcp" }
}
}Or without installing, via uv:
{
"mcpServers": {
"risk": {
"command": "uvx",
"args": ["--from", "git+https://github.com/chenxi-bot21/risk-analytics-mcp-server.git", "risk-mcp"]
}
}
}Related MCP server: Black-Litterman Portfolio Optimization MCP Server
Example prompts once connected
"What's the 99% VaR of a portfolio that's 60% equity, 30% bonds, 10% gold? Compare methods — do the tails look fat?"
"Backtest a 99% historical VaR on these returns and tell me which Basel zone it lands in." (paste returns)
"Score this applicant: 24 years old, $25k income, $30k loan at 26%, DTI 42, utilization 130%, 4 delinquencies…"
Architecture
src/risk_mcp/
├── market.py # JSON-friendly wrappers around marketrisk (pure functions)
├── credit.py # cached synthetic-trained WoE scorecard + scoring
└── server.py # FastMCP registration shim — no logic of its ownThe wrappers are plain functions with plain-type signatures, so the whole surface is unit-tested (19 tests) without a running server; one test drives a tool through the actual MCP protocol layer.
python -m unittest discover -s tests -t .License
MIT.
Available Tools
7 toolsbacktest_varA
Walk-forward VaR backtest (no look-ahead): Kupiec proportion-of-failures,
Christoffersen independence/conditional-coverage tests, and the Basel
traffic-light zone. method is 'historical' or 'parametric'. Needs more
than window+30 observations; omit returns to use the demo portfolio.
Inputs: alpha, method, window, returns.
compute_var_esA
Portfolio VaR and Expected Shortfall by four methods (historical,
parametric-normal, Cornish-Fisher, Monte Carlo) at confidence alpha.
asset_returns maps asset name -> equal-length list of daily returns;
weights defaults to equal. Omit both to use the demo book. Divergence
between historical and normal VaR is the fat-tail signal.
Inputs: alpha, weights, asset_returns.
credit_model_summaryA
Metadata for the credit scorecard: held-out AUROC/Gini/KS, per-feature Information Values, and the valid categorical inputs.
Inputs: no named parameters.
evt_tail_riskA
Extreme-value tail analysis: fit a Generalized Pareto to losses beyond
the threshold_q quantile (peaks-over-threshold) and report EVT VaR/ES at
alpha (use for 99.5%+ where empirical quantiles run out of data).
Inputs: alpha, returns, threshold_q.
garch_volatilityA
Fit GARCH(1,1) by maximum likelihood to a daily return series (>= 250
obs) and forecast volatility forecast_horizon days ahead (mean-reverting
to long-run vol). Omit returns to use the demo portfolio.
Inputs: returns, forecast_horizon.
score_credit_applicationA
Score a retail loan application on a WoE logistic PD scorecard: 12-month probability of default, scorecard points (higher = safer) and a letter rating. Demo model trained on a synthetic book — methodology is production-style, the score is not a production score.
Inputs: age (required), dti (required), loan_term (required), loan_amount (required), +9 more.
stress_testC
Stress the portfolio two ways: a preset crisis-shock library (GFC-style
equity crash, 2020 pandemic, +200bp rates, flight to quality, USD squeeze)
and the portfolio's own worst horizon-day historical windows.
Inputs: top, horizon, weights, asset_returns.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct area of risk analytics: VaR computation, backtesting, credit scoring, EVT, GARCH, stress testing, and credit model metadata. No two tools overlap in purpose.
All names use lowercase with underscores, but some follow a verb_noun pattern (e.g., backtest_var, compute_var_es) while others are noun phrases (e.g., credit_model_summary, garch_volatility). This minor inconsistency does not hinder readability.
Seven tools cover the core risk analytics workflow without being excessive. Each tool earns its place, covering computation, backtesting, credit risk, and stress testing.
The set covers key risk functions: VaR/ES estimation, backtesting, volatility modeling, tail risk, credit scoring, and stress testing. Missing features like data ingestion or portfolio optimization are minor gaps.
Maintenance
Related MCP Connectors
Stock & options risk analytics for AI agents: pre-trade risk scan, IV, gamma walls, Monte Carlo.
Guardrails for trading agents. Built-in risk management, 100+ tools for strategy R&D, 12+ venues.
Build, backtest, and deploy quantitative trading strategies from your AI agent.
Portfolio risk from supplied data or a synthetic example: VaR, ES, stress, credit, FRTB.
Related MCP Servers
- AlicenseCqualityDmaintenanceProvides AI agents with institutional-grade quantitative finance tools including real-time market data, paper trading via Alpaca, risk analysis with Monte Carlo simulations, backtesting, and multi-source news sentiment analysis for portfolio management and trading strategy development.315MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to perform Black-Litterman portfolio optimization with investor views, backtesting, and asset analysis, generating dashboards for visualization.MIT
- FlicenseNot gradedqualityCmaintenanceEnables LLM agents to run iterative volatility analytics, from pre-flight statistical gates through GARCH-family model fitting, VaR/ES risk metrics, and Basel backtesting, with a feedback loop guiding each step.-
- FlicenseAqualityCmaintenanceProvides an LLM agent with extreme value statistics tools for tail risk analysis, including peaks-over-threshold GPD fitting, VaR and Expected Shortfall estimation, return levels, threshold-stability diagnostics, and out-of-sample VaR backtesting.6-