QuantContext — Claude Code MCP server: stock screening and backtests
Turns a plain-English strategy into quant research on real market data: screen stocks, backtest the idea, break the returns into factors. Handy when you want numbers you can reproduce.
claude mcp add quantcontext -- uvx quantcontext-mcpWhat QuantContext does
The server hands your agent three tools that chain together. screen_stocks filters a universe by fundamentals, momentum, quality or technical signals and returns ranked names. backtest_strategy runs a strategy through history with a rebalance loop and reports CAGR, Sharpe, max drawdown, an equity curve and a trade log. factor_analysis splits the returns into Fama-French factors and gives you alpha with a t-statistic.
Every figure comes from market data rather than from the model, so the same request yields the same answer twice. No API keys are involved: prices and fundamentals come from Yahoo Finance, factors from the Kenneth French Data Library, universe lists from Wikipedia. The first call downloads and caches everything; later screens finish in under a second and backtests in a few seconds. To avoid the cold start, run quantcontext-warmup --url https://quantcontext.ai/api/data once after install.
The tools are importable straight from Python — from quantcontext.server import screen_stocks, backtest_strategy, factor_analysis. All of them are async and return JSON strings, which means an existing script can pick up backtesting without going through an agent. Strategies are built from the same screen types the screening tool uses.
What it helps with
- filter stocks by PE, ROE and debt load
- run a strategy over history with monthly rebalancing
- tell real alpha from plain factor exposure
- compare momentum strategies across universes
- add backtesting to an existing Python script
Example prompts for the agent
- Screen the S&P 500 for value names: PE under 15, ROE above 12%
- Backtest a momentum strategy on the Nasdaq 100, monthly rebalance, last 2 years
- Run factor analysis on that strategy — is the return alpha or just factor exposure?
How to install QuantContext
Platform CLI
claude mcp add quantcontext -- uvx quantcontext-mcpuvx runs the command named after the package; if the README names another one, use uvx --from quantcontext-mcp <command>
Platform CLI
codex mcp add quantcontext -- uvx quantcontext-mcpuvx runs the command named after the package; if the README names another one, use uvx --from quantcontext-mcp <command>
Config file
{
"mcpServers": {
"quantcontext": {
"command": "uvx",
"args": [
"quantcontext-mcp"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from quantcontext-mcp <command>
Config file
{
"servers": {
"quantcontext": {
"type": "stdio",
"command": "uvx",
"args": [
"quantcontext-mcp"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from quantcontext-mcp <command>
Platform CLI
gemini mcp add quantcontext uvx quantcontext-mcpuvx runs the command named after the package; if the README names another one, use uvx --from quantcontext-mcp <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about QuantContext
How do I install QuantContext in Claude Code?
Run claude mcp add quantcontext -- uvx quantcontext-mcp. The server then shows up to the agent as quantcontext.
What does QuantContext do?
It gives the agent three tools: stock screening against criteria you set, backtesting a strategy over historical data, and factor analysis of the returns. The numbers are computed from market data.
Do I need API keys?
No. Data comes from open sources: Yahoo Finance, the Kenneth French Data Library and Wikipedia. The first call downloads it into a local cache.