quant-research-mcp
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., "@quant-research-mcpWhat's the current price of AAPL?"
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.
quant-research-mcp
A small Model Context Protocol (MCP) server that exposes market-data and quant-research tools — get a stock price, pull price history, compute a moving average, and backtest an SMA-crossover strategy — to any MCP client (Claude Code, Claude Desktop, etc.).
What's in here
quant-mcp-server/
├── server.py # MCP server: defines the 4 tools, thin wrappers only
├── market_data.py # Data access: yfinance, with a deterministic offline fallback
├── quant.py # Pure calculation logic: SMA, crossover backtest (no MCP/network)
├── test_quant.py # Unit tests for quant.py (pytest)
├── requirements.txt
└── README.mdLogic is split into three layers on purpose: quant.py has zero dependency on MCP or the
network, so it's trivially unit-testable; market_data.py isolates the flaky, external part
(a live API call) behind one function; server.py is just the MCP glue. This is the same
separation you'd want in a production trading tool — you never want your strategy math coupled
to your data feed.
The 4 tools
Tool | What it does |
| Latest close price |
| Daily OHLCV history |
| Simple moving average, latest value + tail |
| Backtests a long/flat SMA-crossover strategy: total return, Sharpe, max drawdown, trade count, vs. buy-and-hold |
If Yahoo Finance is unreachable (no internet, rate-limited, bad ticker), every tool falls back
to a deterministic synthetic price series instead of crashing — and always tags the response
with "source": "synthetic-fallback" so it's never mistaken for real data. This matters more
than it sounds: an MCP tool that just throws a stack trace at the model produces a worse agent
experience than one that degrades gracefully and says so.
Related MCP server: Stock Market MCP Server
1. Set up the project
git clone <your-repo-url> quant-mcp-server # or just use this folder directly
cd quant-mcp-server
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtRun the tests (no network needed, all against quant.py directly):
pytest test_quant.py -vRun the server standalone, just to confirm it starts:
python server.pyIt'll sit there waiting for an MCP client to connect over stdio — that's expected, not a hang. Ctrl+C to stop.
2. Install Claude Code (if you haven't)
curl -fsSL https://claude.ai/install.sh | bash(macOS/Linux/WSL. For native Windows or other install methods — Homebrew, winget, apt/dnf — see the Claude Code docs.) Then authenticate:
claudeand follow the login prompt once.
3. Register this server with Claude Code
From inside the project folder:
claude mcp add quant-research --scope project -- python /absolute/path/to/quant-mcp-server/server.py--scope projectwrites the config to.mcp.jsonin this folder (shareable/commit-able, vs.--scope userwhich is global to your machine).Everything after
--is the exact command Claude Code runs to start your server — swap in your venv's Python if you want to guarantee the right interpreter, e.g..venv/bin/python server.py.
Verify it's registered:
claude mcp listThen start Claude Code in this directory:
claudeOn first use in a session it'll ask you to approve the project's MCP server — approve it, then just talk to it:
"What's the current price of AAPL?" "Backtest a 20/50 SMA crossover on MSFT over the last year and tell me if it beat buy-and-hold." "Compute the 50-day moving average for TSLA and tell me if the price is above or below it."
Claude Code will decide on its own which tool(s) to call based on the docstrings in
server.py — that's the whole point of MCP: you don't write any glue code connecting your
prompt to the tool, the client figures it out from the tool descriptions.
4. (Optional) Also connect it to Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json
on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"quant-research": {
"command": "python",
"args": ["/absolute/path/to/quant-mcp-server/server.py"]
}
}
}Restart Claude Desktop and the tools show up the same way.
Possible extensions
Ideas for taking this further:
Portfolio backtesting:
backtest_portfolio(tickers, weights, ...)that runs the crossover strategy across several tickers and combines the equity curves.Risk metrics: value-at-risk, beta vs. a benchmark index, volatility — extends
quant.py, stays fully unit-testable.A second real data source (e.g. Stooq or Alpha Vantage) as a fallback before synthetic data, so degradation goes "best → good → synthetic" instead of straight to synthetic.
Docker packaging, registered with Claude Code via
docker runinstead ofpython— closer to how this would actually be deployed.A
resourcesendpoint (MCP supports these alongside tools) exposing something like a cached watchlist.
Design notes
Built to explore two things together: using Claude Code as an agentic development workflow, and building an MCP server other agents can call. The layered structure (calculation logic / data access / MCP wrapper) and the graceful-fallback behavior were deliberate choices, not defaults — the goal was a small tool that fails informatively rather than silently, which matters more in a production data pipeline than the strategy logic itself does.
This server cannot be deployed
Maintenance
Related MCP Connectors
Live market data, financial analysis, and portfolio research tools across 10,000+ tickers.
Backtest strategies and analyze portfolios on any ticker: CAGR, drawdown, Sharpe, from real data.
The stock market, in SQL — scan, replay, or subscribe across ~12k US tickers and top 100 cryptos.
Real-time market data, screeners, technical analysis & backtesting for stocks, crypto and forex.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides stock market data and trading capabilities using the yfinance library37MIT
- FlicenseAqualityDmaintenanceProvides stock market data and analysis tools using the Finnhub API, including stock prices, financial metrics, news, and historical data.67-
- FlicenseNot gradedqualityDmaintenanceProvides real-time stock data, historical analysis, and stock comparisons using the Yahoo Finance API.-
- AlicenseNot gradedqualityDmaintenanceProvides stock market data and technical indicators (RSI, Bollinger Bands, SMA, EMA) via AlphaVantage API.Apache 2.0