Skip to main content
Glama
alexmartinsgomes

mcp-monte-carlo

mcp-monte-carlo

Give any AI agent the power to run a serious Monte Carlo forecast for a stock or ETF — in one tool call.

This is an MCP (Model Context Protocol) server. Connect it once to Hermes, Claude Desktop, Cursor, or any MCP-capable agent, and the agent can download market history, fit a volatility model, simulate thousands of future price paths, and return percentiles, drawdowns, and risk probabilities — without you writing a single line of simulation code.

You:  "What does a bad year look like for SPY over the next 12 months?"
Agent → forecast_asset_monte_carlo("SPY")
      → EGARCH + skewed-t Monte Carlo (5,000 paths by default)
You ← JSON: price/return percentiles, vol, max drawdowns, loss probabilities

Why this matters

Large language models are excellent at reasoning and explanation. They are not engines for sampling fat-tailed returns under time-varying volatility. Left alone, an agent might invent plausible-looking percentiles or hand-wave “historical vol $\times\sqrt{T}$”.

This server closes that gap:

Without this MCP

With this MCP

Agent guesses ranges or quotes stale numbers

Agent calls a reproducible statistical pipeline

No consistent treatment of crashes / fat tails

Skewed-t innovations model skewness and fat tails

Constant-vol assumptions ignore clustering

EGARCH captures shock-driven, asymmetric volatility

Hard to compare 7-day vs 10-year risk

Same model, same paths, many horizons in one JSON

The agent stays in charge of interpretation and conversation. The MCP owns estimation and simulation.


Related MCP server: HowRisky MCP Server

What it does (pipeline)

Yahoo Finance (max history)
        │  adjusted daily Close
        ▼
  Log returns
        │
        ▼
  Fit EGARCH(1,1) + leverage  +  skewed-t shocks
        │  constant mean drift (historical mean)
        ▼
  Simulate N paths  (default 5,000) out to 10 years
        │
        ▼
  Summarize each horizon → percentiles, vol, MDD, probabilities

1. Data

Uses yfinance to pull the maximum available daily history. The Close field is already adjusted for splits and dividends, so returns are suitable for long-horizon compounding.

2. Returns and drift

Prices are converted to log returns:

r_t=\ln\left(\frac{P_t}{P_{t-1}}\right)

The mean model is constant: each simulated day has drift equal to the fitted historical average $\mu$. That is a simple, transparent assumption — not a crystal ball for future expected return.

3. Volatility: EGARCH with leverage

Equity volatility is neither constant nor symmetric:

  • Volatility clustering — turbulent days tend to follow turbulent days.

  • Leverage effect — large down moves tend to raise future vol more than equally large up moves.

This server fits EGARCH(1,1) with leverage ($p=1$, $o=1$, $q=1$) via the arch package. Conditionally, log-variance evolves roughly as:

\ln(\sigma_t^2)=\omega+\alpha\bigl(\lvert z_{t-1}\rvert-\mathbb{E}[\lvert z\rvert]\bigr)+\gamma z_{t-1}+\beta\ln(\sigma_{t-1}^2)

For equities, the leverage coefficient $\gamma$ is typically negative: a negative shock $z$ increases tomorrow’s volatility.

4. Shocks: skewed Student-t

Gaussian shocks understate crash risk. Standardized innovations are drawn from a skewed t distribution, so simulated paths can show:

  • fat tails (extreme moves more often than a normal),

  • skewness (asymmetric left/right risk).

5. Monte Carlo paths

Given the fitted parameters, the server simulates $N$ forward trajectories (n_paths; vectorized NumPy loop for stability out to multi-year horizons). Each path is a full price series; horizons are slices of those same paths so short- and long-term stats are coherent.

6. Horizons (trading days)

Label

Trading days

Rough calendar

7d

5

~1 week

30d

21

~1 month

3m

63

~3 months

6m

126

~6 months

1y

252

~1 year

3y

756

~3 years

5y

1260

~5 years

10y

2520

~10 years


Tools

forecast_asset_monte_carlo(ticker, n_paths=5000)

When to use: The user wants forward scenarios, risk ranges, or path statistics for a ticker (e.g. SPY, AAPL).

For each horizon, the JSON includes:

  • Price percentiles1, 5, 10, 25, 50, 75, 90, 95, 99

  • Return percentiles (%) — same grid, vs today’s price

  • Annualized volatility (%) — cross-sectional vol of path outcomes at that horizon

  • Max-drawdown percentiles (%) — peak-to-trough loss along each path up to that horizon

  • Probabilities — end below start, ±20% moves, max drawdown over 20%

n_paths defaults to 5000 (minimum 100). More paths → smoother percentile estimates, slower run.

inspect_asset_model(ticker)

When to use: Validate data quality or model sanity before (or instead of) a full forecast — enough history? sensible parameters? how fat are residual tails?

Returns history span, last price, fitted EGARCH + skew-t parameters, AIC/BIC, last conditional volatility (daily and annualized), and residual skewness / excess kurtosis.

Does not simulate paths. Prefer forecast_asset_monte_carlo for percentiles and drawdowns.


Requirements

  • macOS, Linux, or Windows

  • uv (recommended)

  • Python ≥ 3.12 (declared in pyproject.toml)

  • Network access (Yahoo Finance download)


Quick start (local)

cd /path/to/mcp-monte-carlo
uv sync

Smoke-test without MCP:

uv run python -c "
from server import run_inspect, run
import json
print(json.dumps(run_inspect('SPY'), indent=2))
print(json.dumps(run('SPY', 200)['horizons']['1y'], indent=2))
"

Run the MCP server on stdio:

uv run mcp-monte-carlo
# or, from a published clone / path:
uvx --from /path/to/mcp-monte-carlo mcp-monte-carlo

Connect an AI agent

Hermes Agent (~/.hermes/config.yaml)

Prefer uv run against a synced project (faster and more reliable than a cold uvx):

mcp_servers:
  mcp-monte-carlo:
    command: /opt/homebrew/bin/uv   # which uv  → paste absolute path
    args:
      - run
      - --directory
      - /ABSOLUTE/PATH/TO/mcp-monte-carlo
      - mcp-monte-carlo
    connect_timeout: 120
    timeout: 300

Then: hermes mcp test mcp-monte-carlo or /reload-mcp in a chat.

Cursor / Claude Desktop

{
  "mcpServers": {
    "mcp-monte-carlo": {
      "command": "uvx",
      "args": [
        "--from",
        "/ABSOLUTE/PATH/TO/mcp-monte-carlo",
        "mcp-monte-carlo"
      ]
    }
  }
}

Once published on GitHub, others can point --from at the repo URL or clone locally and use the same pattern.


Example agent prompts

  • “Inspect the EGARCH model for QQQ, then forecast with 2,000 paths.”

  • “For AAPL, what is the 5th percentile price in 1 year, and the probability of a >20% max drawdown?”

  • “Compare 1-year median and 95th percentile max drawdown for SPY vs TLT.”


Project layout

mcp-monte-carlo/
├── server.py          # MCP tools + EGARCH/skew-t Monte Carlo (single module)
├── pyproject.toml     # package metadata, deps, console entry point
├── uv.lock            # locked dependency versions
├── README.md
└── .gitignore

One Python file keeps the project easy to read, audit, and ship.


Model caveats (read this)

This is a research / educational risk tool, not investment advice and not a guarantee of future prices.

  • Past drift $\mu$ is not a forecast of expected return; long-horizon medians inherit that assumption.

  • EGARCH(1,1)+leverage and skewed-t are strong defaults for many liquid equities/ETFs — not universally “optimal” for every ticker.

  • Yahoo data quality and corporate actions can affect results; always check inspect_asset_model on unfamiliar symbols.

  • Extremely long horizons (5y–10y) compound model risk; treat tails as illustrative, not certainties.


License / authorship

Created by Alexandre Martins. Use and adapt freely for personal agents and learning; if you redistribute, keep attribution and these caveats visible.

Available Tools

2 tools
forecast_asset_monte_carloA

Run a forward Monte Carlo forecast of an asset's future price distribution.

Use this when the user wants scenario ranges, risk, or path statistics for a
ticker (e.g. SPY, AAPL): price/return percentiles, annualized volatility,
max-drawdown percentiles, and loss/gain probabilities at 7d, 30d, 3m, 6m,
1y, 3y, 5y, and 10y trading-day horizons.

Downloads max adjusted daily closes, fits EGARCH(1,1) with leverage
(o=1) and skewed-t innovations (historical mean drift), then simulates
``n_paths`` paths.

Prefer ``inspect_asset_model`` first only when you need fit/data diagnostics
without simulating paths.

Args:
    ticker: Yahoo Finance ticker symbol (e.g. SPY, AAPL).
    n_paths: Number of Monte Carlo paths (default 5000, minimum 100).
ParametersJSON Schema
NameRequiredDescriptionDefault
tickerYes
n_pathsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden, and it delivers thoroughly. It discloses the data source ('Downloads max adjusted daily closes'), the exact model ('EGARCH(1,1) with leverage (o=1) and skewed-t innovations'), and the simulation step ('simulates n_paths paths'). This gives the agent a clear behavioral model of what happens when invoked.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded, with each sentence serving a purpose: purpose, when-to-use, model details, sibling routing, and parameter explanation. No filler or repetition of structured schema fields.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given an output schema exists, return-value details need not be in the description. For a two-parameter tool, the description fully covers selection criteria, invocation parameters, model behavior, and alternative routing. There is no missing information an agent would need to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. The Args section adds meaningful detail: ticker examples ('SPY, AAPL') and n_paths constraints ('default 5000, minimum 100'). The default is redundant with the schema, but the minimum and ticker examples are new and useful.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb-object statement: 'Run a forward Monte Carlo forecast of an asset's future price distribution.' It further enumerates concrete outputs (percentiles, volatility, drawdown, loss/gain probabilities) and explicitly contrasts with the sibling inspect_asset_model by noting diagnostics vs. simulation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives direct when-to-use guidance: 'Use this when the user wants scenario ranges, risk, or path statistics.' It also names the alternative with an explicit condition: 'Prefer inspect_asset_model first only when you need fit/data diagnostics without simulating paths.' This leaves no ambiguity about tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

inspect_asset_modelA

Inspect the EGARCH + skewed-t model fit for a ticker WITHOUT simulating paths.

Call this when you need to validate data quality or model sanity before (or
instead of) a full Monte Carlo forecast — for example: Is there enough
history? What is today's conditional volatility? Do residuals look heavily
skewed/fat-tailed? What are the fitted EGARCH and skew-t parameters?

Do NOT use this for forward price scenarios, percentiles, drawdowns, or
probabilities — use ``forecast_asset_monte_carlo`` for those.

Returns JSON with history span, last price, fitted parameters, AIC/BIC,
last conditional volatility (daily and annualized), and residual
skewness/excess kurtosis.

Args:
    ticker: Yahoo Finance ticker symbol (e.g. SPY, AAPL).
ParametersJSON Schema
NameRequiredDescriptionDefault
tickerYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the responsibility of explaining behavior. It clearly discloses that no path simulation occurs, describes the diagnostic nature of the tool, and enumerates the returned JSON contents. It does not explicitly state it is read-only or mention failure/edge-case behavior, but 'Inspect' and 'WITHOUT simulating paths' strongly imply a non-destructive diagnostic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded: purpose and key limitation first, usage guidance second, exclusions and alternative third, return value summary fourth, and parameters last. Every sentence adds useful information; the example questions support correct invocation without being redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter diagnostic tool with an output schema present, the description covers all necessary invocation context: what the tool does, what it does not do, when to use it, what it returns, and the parameter format. Nothing an agent needs to decide between this and the sibling tool is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema provides only a title for 'ticker', so the description fully compensates by defining it as a 'Yahoo Finance ticker symbol' with concrete examples ('SPY, AAPL'). This resolves exactly what format the parameter should take, covering the entire gap left by the 0% schema description coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Inspect') and a precise resource ('EGARCH + skewed-t model fit for a ticker'), and immediately differentiates itself from the Monte Carlo sibling by saying 'WITHOUT simulating paths.' This makes the tool's purpose unmistakable and distinguishes it from forecast_asset_monte_carlo.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly says when to use this tool ('validate data quality or model sanity before (or instead of) a full Monte Carlo forecast'), gives concrete example questions, and states clearly what NOT to use it for, naming the alternative tool for those cases. This is exemplary usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.7/5.0
Disambiguation5/5

The two tools have fully distinct purposes: one generates forward Monte Carlo forecasts, while the other inspects model fit without simulating. Each description explicitly states when to use it and when not to, so there is no realistic ambiguity.

Naming Consistency5/5

Both tool names follow a consistent verb-first snake_case pattern: forecast_asset... and inspect_asset.... The shared '_asset_' segment reinforces that they operate on the same domain, and there is no mix of naming conventions.

Tool Count3/5

Two tools is on the low edge of what feels like a reasonable server surface. Each tool serves a necessary role in the workflow, but the server is minimal and could feel thin to agents expecting additional financial utilities.

Completeness4/5

For the stated purpose, the core workflow is covered: fit/inspect the model and run forecasts. There is no obvious dead end for the main Monte Carlo use cases, though a direct historical data or backtesting tool would make the surface more complete.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    Provides 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.
    31
    5
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables institutional-grade Monte Carlo risk analysis for portfolios, startups, real estate, and betting strategies using fat-tail distributions and proprietary algorithms. Provides comprehensive risk metrics including CVaR, VaR, ruin probability, and survival probability across multiple asset classes.
    1
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to perform Black-Litterman portfolio optimization with investor views, backtesting, and asset analysis, generating dashboards for visualization.
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Provides AI agents with quantitative risk tools such as VaR, expected shortfall, GARCH volatility, backtesting, stress testing, tail risk analysis, and credit scoring using synthetic or user-supplied data.
    7
    1
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alexmartinsgomes/mcp-monte-carlo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server