QuantContext
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., "@QuantContextScreen S&P 500 for value stocks with PE under 15 and ROE above 12%"
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.
QuantContext
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.
Install
pip install quantcontext-mcpClaude Code:
claude mcp add quantcontext -- quantcontextClaude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"quantcontext": {
"command": "quantcontext"
}
}
}No API keys. No configuration.
Related MCP server: openfinclaw
Tools
Three tools that compose into a full research workflow:
screen_stocks -> backtest_strategy -> factor_analysisTool | What it does |
| Filter S&P 500, Nasdaq 100, or Russell 2000 by fundamentals, momentum, quality, technical signals, or a multi-factor blend. Returns ranked candidates. |
| Test a strategy over history with a rebalance-loop engine. Returns CAGR, Sharpe, max drawdown, equity curve, and trade log. |
| Decompose strategy returns into Fama-French factors (market, size, value, momentum). Returns alpha with t-statistic, factor loadings, and R-squared. |
Sample Prompts
Stock screening:
Screen S&P 500 for value stocks: PE under 15, ROE above 12%Find the top 20% momentum stocks in the Nasdaq 100 over the last 200 daysRank S&P 500 stocks by a blend of value, momentum, and quality, equal weight each factorFind S&P 500 stocks with RSI under 40 and price above the 200-day moving averageBacktesting:
Backtest a top-20% momentum strategy on Nasdaq 100, monthly rebalance, last 2 yearsHow would a value screen (PE under 15, ROE above 12%) have performed on S&P 500 over the last 3 years?Test a momentum strategy with a 15% stop loss and 20% max portfolio drawdown circuit breakerFull research workflow:
Screen S&P 500 for cheap, high-quality stocks. Backtest monthly over 3 years,
then run factor analysis. Is the return real alpha or just factor exposure?Screen Types
Screen | Description | Key parameters |
| Filter by PE, ROE, leverage, revenue growth |
|
| Profitability and balance sheet health |
|
| Rank by N-day price momentum |
|
| Cheapest stocks by valuation |
|
| Multi-factor composite score |
|
| RSI and SMA crossover signals |
|
| Stocks below z-score threshold |
|
Use from Python
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.
from quantcontext.server import screen_stocks, backtest_strategy, factor_analysis
import asyncio, json
# Screen
result = json.loads(asyncio.run(screen_stocks(
universe="sp500",
screen_type="fundamental_screen",
config={"pe_lt": 15, "roe_gt": 12},
)))
# Backtest
bt = json.loads(asyncio.run(backtest_strategy(
stages=[{"order": 1, "type": "screen", "skill": "fundamental_screen", "config": {"pe_lt": 15, "roe_gt": 12}}],
universe="sp500",
rebalance="monthly",
start_date="2022-01-01",
)))
print(bt["metrics"])
# Factor analysis — pipe the equity curve straight in
fa = json.loads(asyncio.run(factor_analysis(
equity_curve=bt["full_equity_curve"]
)))
print(fa["alpha_annualized"], fa["alpha_tstat"])Strategies are expressed using the built-in screen types from the table above. All functions are async and return JSON strings.
Data
All public data, no API keys required.
Data | Source | Cache |
Daily OHLCV prices | Yahoo Finance ( |
|
Fundamentals (PE, ROE, margins, etc.) | Yahoo Finance |
|
Fama-French factors (Mkt-RF, SMB, HML, Mom) | Kenneth French Data Library |
|
Universe lists (S&P 500, Nasdaq 100) | Wikipedia |
|
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:
quantcontext-warmup --url https://quantcontext.ai/api/dataLinks
License
MIT
Available Tools
3 toolsbacktest_strategyARead-onlyIdempotent
Run a historical backtest on a stock screening strategy. Uses a rebalance-loop engine that re-runs the screening pipeline on each rebalance date, sizes positions, enforces risk limits, and tracks daily P&L.
Returns equity curve, trade log, and performance metrics including CAGR, Sharpe ratio, maximum drawdown, Calmar ratio, win rate, and turnover.
The backtest is fully deterministic — same inputs always produce identical results.
After backtesting, use factor_analysis on the equity_curve to decompose returns into Fama-French factors (market, size, value, momentum) and estimate true alpha.
Inputs: stages (required), universe, rebalance, sizing, +5 more. Returns: result
factor_analysisARead-onlyIdempotent
Decompose strategy or portfolio returns into Fama-French factors using OLS regression.
Breaks down returns into exposures to four systematic factors:
Mkt-RF (market risk premium): how much return comes from overall market movement
SMB (small minus big): size factor exposure
HML (high minus low): value factor exposure
Mom (momentum): momentum factor exposure
Also estimates alpha (excess return not explained by factors) with t-statistic for statistical significance. A |t-stat| > 2 suggests statistically significant alpha.
Returns alpha (daily and annualized), factor loadings with t-statistics, R-squared (how much of return variance is explained by factors), and residual volatility.
Use this after backtest_strategy to understand WHERE your returns come from — is it genuine alpha or just factor exposure?
Inputs: equity_curve (required). Returns: result
screen_stocksARead-onlyIdempotent
Screen a stock universe with quantitative filters. Returns ranked candidates with scores and metrics.
Use this tool when you need to find stocks matching specific criteria — value stocks, momentum leaders, quality companies, or multi-factor ranked candidates. Supports 7 screen types across 3 universes (S&P 500, Russell 2000, Nasdaq 100).
After screening, use backtest_strategy to test the screen as a trading strategy, or factor_analysis to understand the factor exposures of the selected stocks.
Inputs: universe, screen_type, config, date. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
TDQS
Scored across 3 tools
Each tool has a distinct purpose: screen_stocks finds candidates, backtest_strategy tests strategies, factor_analysis decomposes returns. No overlap in functionality.
All tool names follow a consistent verb_noun pattern in snake_case: backtest_strategy, factor_analysis, screen_stocks.
Three tools is minimal but well-scoped for the quantitative finance pipeline. Covers screening, backtesting, and analysis without excess.
The tools form a coherent workflow (screen → backtest → factor analysis). Minor gaps exist, such as no data retrieval or custom factor tools, but the core pipeline is complete.
Maintenance
Related MCP Connectors
Build, backtest, and deploy quantitative trading strategies from your AI agent.
Analytical engine for US-listed equities: screens, rankings, and event studies in plain English.
Backtest plain-English trading strategies on real market data: graded results, honesty flags.
Quant intelligence over MCP: backtest, signals, screens, scores & portfolios for US & TSX stocks.
Related MCP Servers
- AlicenseAqualityBmaintenanceInstitutional-grade quantitative stock analysis and research signals for AI agents via the Model Context Protocol (MCP).101MIT
- FlicenseNot gradedqualityDmaintenanceEnables quant research, strategy development, backtesting, and paper trading through natural language prompts, integrated with 20+ AI agents.134-
- AlicenseNot gradedqualityBmaintenanceEnables natural language quantitative analysis for US and Indian equities, including trade plans, portfolio optimization, backtests, and price alerts using real market data.4MIT
- FlicenseNot gradedqualityAmaintenanceEnables users to ask natural-language questions and receive structured, source-backed answers across public filings, earnings transcripts, company financials, stock and crypto market data, news, and prediction markets research.-