Financial Risk 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., "@Financial Risk MCP Server calculate Basel III SA-CCR EAD for my interest rate swap 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.
High-Performance Financial Risk & Quantitative Analytics MCP Server
An enterprise-grade Model Context Protocol (MCP) server bridging institutional quantitative risk analytics to autonomous AI agents (Claude, Cursor, Devin, Copilot).
Designed and engineered by Shelendra Jain (Technical Architect & Hands-on Tech Lead, 19+ years experience in low-latency systems and investment banking trading platforms).
๐๏ธ Architectural Overview
Regulated financial institutions (Tier-1 banks, hedge funds, prime brokers) possess mission-critical quantitative engines written in C++ and distributed microservices. However, connecting these engines to modern Large Language Models (LLMs) requires strict adherence to security boundaries, deterministic arithmetic, and formal protocol standards.
This repository provides a production-hardened reference implementation of an MCP Server exposing quantitative risk functions over standard JSON-RPC 2.0:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Autonomous AI Agents / Front-Office UI โ
โ (Claude Desktop, Cursor, Devin, Copilot) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Standard JSON-RPC 2.0 (stdio / TCP)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Financial Risk MCP Server โ
โ โข Tools Registry โข Dynamic Resource Provider โ
โ โข Prompt Templates โข Protocol Handshake (v1.0) โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Python Analytics Core โ โ High-Performance C++ โ
โ โข BCBS 279 SA-CCR Engine โ โ โข Multithreaded Engine โ
โ โข Parametric VaR / CVaR โ โ โข Monte Carlo PFE Sim โ
โ โข Options Greeks (Delta, โ โ โข 6.8M Valuations/Sec โ
โ Gamma, Vega, Theta) โ โ โข Zero-Allocation Pools โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโRelated MCP server: PA MCP Server
โก Key Capabilities & Quantitative Formulations
1. Basel III / BCBS 279 SA-CCR Engine
Computes Exposure at Default (EAD) under the Standardized Approach for Counterparty Credit Risk: $$\text{EAD} = \alpha \times (\text{RC} + \text{PFE})$$ where $\alpha = 1.4$.
Replacement Cost (RC):
Unmargined: $\text{RC} = \max(V - C, 0)$
Margined (CSA): $\text{RC} = \max(V - C, \text{Threshold} + \text{MTA} - \text{NICA}, 0)$
Potential Future Exposure (PFE): $$\text{PFE} = \text{Multiplier} \times \text{AddOn}^{\text{aggregate}}$$ $$\text{Multiplier} = \min\left(1.0, 0.05 + 0.95 \cdot \exp\left(\frac{V - C}{2 \times 0.95 \times \text{AddOn}^{\text{aggregate}}}\right)\right)$$
Supervisory Duration: $$\text{SD}_i = \frac{\exp(-0.05 \cdot S_i) - \exp(-0.05 \cdot E_i)}{0.05}$$
2. Multithreaded Monte Carlo Peak Forward Exposure (PFE)
Simulates stochastic rate paths across tenors from 0.25 years to 30 years using mean-reverting Ornstein-Uhlenbeck / Hull-White state diffusion.
Aggregates distribution profiles to calculate Expected Exposure (EE), PFE 95%, PFE 97.5%, and PFE 99% quantiles.
Automatically identifies the Peak Forward Exposure point along the tenor curve.
3. Value-at-Risk (VaR) & Expected Shortfall (CVaR)
Calculates regulatory holding-period VaR (10-day 99% confidence interval) and Conditional VaR (Expected Shortfall) using variance-covariance analytical scaling: $$\text{VaR}\alpha = \text{PV} \cdot Z\alpha \cdot \sigma_{\text{daily}} \sqrt{T}$$
4. Derivative Sensitivities (Greeks)
Real-time analytical first- and second-order Greeks:
Delta ($\Delta$): First-order directional sensitivity.
Gamma ($\Gamma$): Second-order underlying convexity.
Vega ($\nu$): Volatility surface exposure.
Theta ($\Theta$): Calendar time decay.
Rho ($\rho$): Risk-free interest rate sensitivity.
๐ Benchmark Performance (C++20 Engine)
Executed on an Intel x86_64 host (2 worker threads, 100,000 paths across 11 tenors):
Metric | Measured Value |
Total Simulated Paths | 100,000 |
Tenor Discretization | 11 steps (0.25y โ 30.0y) |
Total Valuation Events | 1,100,000 |
Execution Time | 161.8 ms |
Simulation Throughput | 6,797,363 valuations / second |
๐ ๏ธ MCP Primitives Exposed
Tools
calculate_sacr_exposure: Basel III counterparty credit risk capital calculation.simulate_monte_carlo_pfe: Vectorized multi-path Monte Carlo PFE simulation across 30y tenors.compute_portfolio_var: Parametric and regulatory Value-at-Risk and Expected Shortfall.calculate_portfolio_greeks: Multi-asset portfolio Greeks aggregation (Delta, Gamma, Vega, Theta, Rho).
Resources
financial://portfolio/citi-benchmark-01: Standardized institutional benchmark portfolio with Rates, FX, and Equity options.financial://regulatory/bcbs279-factors: Regulatory reference lookup table for BCBS 279 supervisory parameters.
Prompts
audit_counterparty_risk: Guided LLM agent workflow for credit risk auditing, EAD verification, and margin adequacy analysis.stress_test_scenario: Guided agent workflow for applying macroeconomic rate shocks and volatility spikes.
๐ Quickstart Guide
1. Prerequisites
Python 3.10 or higher
GCC / G++ with C++17 support (optional for C++ benchmark)
pip install numpy
2. Verify Installation
git clone https://github.com/shelendra/financial-risk-mcp.git
cd financial-risk-mcp
# Run unit tests
make test
# Run C++ high-performance benchmark
make bench-cpp
# Run end-to-end sample client
make run-demo๐ Integration with AI Development Environments
A. Claude Desktop
Add to your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"financial-risk-engine": {
"command": "python3",
"args": ["-m", "fin_risk_mcp.server"],
"cwd": "/path/to/financial-risk-mcp",
"env": {
"PYTHONPATH": "src"
}
}
}
}B. Cursor IDE
Create or update .cursor/mcp.json in your workspace:
{
"mcpServers": {
"financial-risk-engine": {
"command": "python3",
"args": ["-m", "fin_risk_mcp.server"],
"cwd": "/path/to/financial-risk-mcp",
"env": {
"PYTHONPATH": "src"
}
}
}
}๐งช Testing Suite
The repository includes comprehensive unit tests verifying math accuracy against standard quantitative tables and testing full JSON-RPC protocol compliance:
$ make test
test_saccr_unmargined (test_engines.TestRiskEngines) ... ok
test_saccr_margined (test_engines.TestRiskEngines) ... ok
test_monte_carlo_pfe (test_engines.TestRiskEngines) ... ok
test_parametric_var (test_engines.TestRiskEngines) ... ok
test_greeks_calculation (test_engines.TestRiskEngines) ... ok
test_initialize (test_mcp_server.TestFinancialRiskMCPServer) ... ok
test_tools_list (test_mcp_server.TestFinancialRiskMCPServer) ... ok
test_call_calculate_sacr_exposure (test_mcp_server.TestFinancialRiskMCPServer) ... ok
test_call_simulate_monte_carlo_pfe (test_mcp_server.TestFinancialRiskMCPServer) ... ok
test_resources_read (test_mcp_server.TestFinancialRiskMCPServer) ... ok
test_prompts_get (test_mcp_server.TestFinancialRiskMCPServer) ... ok
----------------------------------------------------------------------
Ran 11 tests in 0.035s
OK๐จโ๐ป Author
Shelendra Jain
Senior Vice President โ Technical Architect & Tech Lead
Pune, India
Email: shelendra.jain2004@gmail.com
LinkedIn: linkedin.com/in/shelendra
๐ License
This project is open-sourced under the MIT License.
Available Tools
4 toolscalculate_portfolio_greeksC
Aggregates first- and second-order derivatives sensitivities: Delta, Gamma, Vega, Theta, and Rho across a book of positions.
Inputs: trades (required).
calculate_sacr_exposureB
Calculates Basel III / BCBS 279 Standardized Approach for Counterparty Credit Risk (SA-CCR) metrics: Replacement Cost (RC), Potential Future Exposure (PFE), Supervisory Add-on, Multiplier, and Exposure at Default (EAD = 1.4 * (RC + PFE)).
Inputs: trades (required), netting_set_id (required), counterparty_id (required), threshold, +3 more.
compute_portfolio_varA
Computes regulatory Value-at-Risk (VaR) and Expected Shortfall (CVaR) for market risk across specified holding periods and confidence intervals.
Inputs: portfolio_value (required), daily_volatility (required), horizon_days, confidence_level.
simulate_monte_carlo_pfeC
Executes high-performance Monte Carlo simulation (using native C++20 multithreaded core) to project Potential Future Exposure (PFE) profiles and Peak Forward Exposure across multi-year tenors (0.25y to 30y).
Inputs: trades (required), portfolio_id (required), volatility, mean_reversion, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 4 tools
Each tool targets a distinct risk metric: regulatory SA-CCR exposure, Monte Carlo PFE profiles, portfolio VaR/CVaR, and Greeks. The only mild overlap is between calculate_sacr_exposure and simulate_monte_carlo_pfe, since both address counterparty exposure, but the standardized-formula vs simulation distinction is clear enough to distinguish them.
All names use snake_case with a verb_noun structure (calculate_sacr_exposure, simulate_monte_carlo_pfe, compute_portfolio_var, calculate_portfolio_greeks), which is easily predictable. The verb choices vary (calculate/simulate/compute) but all are equally readable and follow the same pattern.
Four tools is a focused, well-scoped set that avoids redundancy for a risk analytics server. It is on the lean side, but each tool clearly earns its place.
The core measures are covered: exposure, PFE, VaR/CVaR, and Greeks. However, notable counterparty-risk operations are absent, including CVA/credit valuation adjustment, stress testing, and scenario or backtesting tools, leaving some obvious gaps in a full risk workflow.
Related MCP Connectors
Stock & options risk analytics for AI agents: pre-trade risk scan, IV, gamma walls, Monte Carlo.
Portfolio risk analytics โ VaR, Monte Carlo, optimization, options Greeks, stress testing.
Connect AI agents to financial institution origination, analytics, and compliance workflows.
Crypto portfolio risk analysis: VaR, scenarios, liquidity and correlation engines as MCP tools.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI agents to retrieve quantum-computed portfolio optimisation, VaR simulations, AI-enhanced sentiment and regime detection, and cross-asset risk signals through simple metric tools.47 npmMIT
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to run probabilistic portfolio analysis workflows, including input validation, instrument verification, simulation preparation, and approved interactive reporting.-
- AlicenseNot gradedqualityBmaintenanceEquips AI agents with institutional risk management and execution tools for Solana and Hyperliquid, enabling Kelly-criterion position sizing, VaR/CVaR analysis, Monte Carlo simulations, circuit breaker checks, and wallet/funding data queries through standardized MCP tools.MIT
- AlicenseNot gradedqualityBmaintenanceEnables quantitative portfolio tail-risk analysis, option Greeks, Monte Carlo stochastic simulations, fixed-income duration/convexity, and Nelson-Siegel yield-curve interpolation through MCP tools.7MIT