Deterministic stock screening, backtesting, and factor analysis for AI trading agents
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
QuantContext is an MCP server that turns plain-English strategy descriptions into executable quant research: screen stocks by any criteria, backtest over historical data, and run factor analysis to see where the returns come from. Every number is computed from real market data, not generated by an LLM. Results are fully reproducible.
Works with Claude, Codex, OpenCode, or any other MCP-compatible coding agent.
Claude Code:
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
No API keys. No configuration.
Three tools that compose into a full research workflow:
| Tool | What it does |
|---|---|
screen_stocks | Filter S&P 500, Nasdaq 100, or Russell 2000 by fundamentals, momentum, quality, technical signals, or a multi-factor blend. Returns ranked candidates. |
backtest_strategy | Test a strategy over history with a rebalance-loop engine. Returns CAGR, Sharpe, max drawdown, equity curve, and trade log. |
factor_analysis | Decompose strategy returns into Fama-French factors (market, size, value, momentum). Returns alpha with t-statistic, factor loadings, and R-squared. |
Stock screening:
Backtesting:
Full research workflow:
| Screen | Description | Key parameters |
|---|---|---|
fundamental_screen | Filter by PE, ROE, leverage, revenue growth | pe_lt, roe_gt, debt_equity_lt, revenue_growth_gt |
quality_screen | Profitability and balance sheet health | roe_gt, debt_equity_lt, profit_margin_gt |
momentum_screen | Rank by N-day price momentum | lookback_days, top_pct |
value_screen | Cheapest stocks by valuation | pe_lt, top_n |
factor_model | Multi-factor composite score | weights (value/momentum/quality/volatility), top_n |
technical_signal | RSI and SMA crossover signals | rsi_period, sma_short, sma_long |
mean_reversion | Stocks below z-score threshold | lookback_days, z_threshold |
The tools are also importable directly β no agent required. Useful if you have an existing script and want to plug in backtesting or factor analysis.
Strategies are expressed using the built-in screen types from the table above. All functions are async and return JSON strings.
All public data, no API keys required.
| Data | Source | Cache |
|---|---|---|
| Daily OHLCV prices | Yahoo Finance (yfinance) | ~/.cache/quantcontext/prices.parquet |
| Fundamentals (PE, ROE, margins, etc.) | Yahoo Finance | ~/.cache/quantcontext/financials/, 24h TTL |
| Fama-French factors (Mkt-RF, SMB, HML, Mom) | Kenneth French Data Library | ~/.cache/quantcontext/ff_factors.parquet |
| Universe lists (S&P 500, Nasdaq 100) | Wikipedia | ~/.cache/quantcontext/sp500_tickers.json |
The first tool call downloads and caches data (10-30 seconds). All subsequent calls use the local cache: screening under 1s, backtesting 3-8s.
To skip the cold start, run once after install:
MIT
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/quantcontext)<a href="https://allmcps.com/mcp/quantcontext"><img src="https://allmcps.com/api/badge/quantcontext?style=directory" alt="QuantContext on AllMCPs" /></a>