Enables AI agents to perform deterministic stock screening, historical backtesting, and Fama-French factor analysis using real market data.
Also known as zomma-dev/quantcontext-mcp-server, quantcontext-mcp-server, quantcontext-mcp
- Stars
- 10
- Tools
- 3
- Downloads, 30 days
- 268
- Latest version
- 0.1.2
- Last commit
- Oct 21, 2026
- License
- MIT
What is QuantContext MCP?
QuantContext enables AI agents to perform deterministic stock screening, historical backtesting, and Fama-French factor analysis using real market data. It exposes 3 tools, such as screen_stocks, backtest_strategy, factor_analysis.
Summary generated from the project's README
About QuantContext MCP server
Performing quantitative research and stock screening through natural language is what QuantContext enables for developers using Claude, Codex, or OpenCode. It allows users to transform plain-English strategy descriptions into executable research workflows using real market data instead of generated numbers. The server operates locally without requiring any API keys or complex configuration, pulling data from sources like Yahoo Finance and the Kenneth French Data Library.
Users can access three primary tools to build a complete research pipeline. The screen_stocks tool filters universes like the S&P 500 or Nasdaq 100 using fundamental, momentum, or technical signals. The backtest_strategy tool evaluates these selections over historical periods to calculate metrics such as CAGR, Sharpe ratio, and maximum drawdown. Finally, the factor_analysis tool decomposes returns into Fama-French factors to determine if a strategy produces true alpha or simply reflects market exposure. This setup is ideal for traders and researchers who need reproducible, deterministic results directly within their coding agent environment.
What you can do with it
- 1Filter stocks by specific metricsAsk the agent to find S&P 500 companies with low price-to-earnings ratios and high return on equity.
- 2Validate trading strategies historicallyTest how a momentum-based strategy on the Nasdaq 100 would have performed over the last two years with monthly rebalancing.
- 3Analyze return driversDetermine if a strategy's performance is due to genuine alpha or exposure to specific Fama-French factors.
Written from the project's README. Every use case is checked against a quote from it.
How to install QuantContext MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall QuantContext MCP in Claude Code
$ claude mcp add quantcontext-mcp-server -- uvx quantcontext-mcpInstall QuantContext MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"quantcontext-mcp-server": {
"command": "uvx",
"args": [
"quantcontext-mcp"
]
}
}
}Install QuantContext MCP in VS Code
.vscode/mcp.json
{
"servers": {
"quantcontext-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": [
"quantcontext-mcp"
]
}
}
}Install QuantContext MCP in VS Code CLI
$ code --add-mcp '{"name":"quantcontext-mcp-server","type":"stdio","command":"uvx","args":["quantcontext-mcp"]}'Install QuantContext MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"quantcontext-mcp-server": {
"command": "uvx",
"args": [
"quantcontext-mcp"
]
}
}
}Install QuantContext MCP in Codex
$ codex mcp add quantcontext-mcp-server -- uvx quantcontext-mcpInstall QuantContext MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.quantcontext-mcp-server] command = "uvx" args = ["quantcontext-mcp"]
Install QuantContext MCP in Gemini CLI
$ gemini mcp add -s user quantcontext-mcp-server uvx -- quantcontext-mcpInstall QuantContext MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"quantcontext-mcp-server": {
"command": "uvx",
"args": [
"quantcontext-mcp"
]
}
}
}QuantContext MCP tools 3
Detected from the READMEscreen_stocksbacktest_strategyfactor_analysis
| screen_stocks | — | |
| backtest_strategy | — | |
| factor_analysis | — |
Automated checks
Ran Nov 13, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachablePass
- Open source license (OSI)Pass
- Commit or release in the last yearPass
- Package name not close to a popular packagePass
- Remote endpoint uses HTTPSNot checked
- Destructive tools are labelledPass
- No hidden instructions to the modelPass
- No critical advisory in the package or its dependenciesPass
README
View on GitHubQuantContext
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-mcp
Claude Code:
claude mcp add quantcontext -- quantcontext
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"quantcontext": {
"command": "quantcontext"
}
}
}
No API keys. No configuration.
Tools
Three tools that compose into a full research workflow:
screen_stocks -> backtest_strategy -> factor_analysis
| 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. |
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 days
Rank S&P 500 stocks by a blend of value, momentum, and quality, equal weight each factor
Find S&P 500 stocks with RSI under 40 and price above the 200-day moving average
Backtesting:
Backtest a top-20% momentum strategy on Nasdaq 100, monthly rebalance, last 2 years
How 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 breaker
Full 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 |
|---|---|---|
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 |
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 (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:
quantcontext-warmup --url https://quantcontext.ai/api/data
Links
License
MIT
QuantContext MCP questions
How do I add QuantContext MCP to Claude Code?
Run claude mcp add quantcontext-mcp-server -- uvx quantcontext-mcp in your terminal. Add --scope user to make it available in every project.
How do I add QuantContext MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
What tools does QuantContext MCP provide?
It exposes 3 tools, including screen_stocks, backtest_strategy, factor_analysis.
Does this server require any API keys?
No, the server requires no API keys or configuration to work.
Can I use these tools in my own Python scripts?
Yes, the tools are importable directly for use in existing Python scripts without needing an AI agent.
How long does it take to get data?
The first tool call downloads and caches data, which takes 10-30 seconds, but subsequent calls use the local cache for much faster results.