MCP server for Claude Desktop: natural-language market research and strategy backtesting with the AlgoChains library.
Project description
AlgoChains Library MCP
Ask market-research and trading-strategy questions in plain English, and let Claude pull data with AlgoChains, backtest strategies, and return interactive charts inline — built for Claude Desktop via the Model Context Protocol.
No coding required: describe the strategy, get a full backtest dashboard back in the chat.
Install (easiest — one click)
- Get your API key at https://algochains.ai.
- Download the extension: algochains-library-mcp.mcpb.
- Double-click the downloaded file (or in Claude Desktop: Settings → Extensions → Install extension… and pick it). Claude Desktop shows an install dialog — paste your API key into the AlgoChains API Key field and confirm.
- Fully quit Claude Desktop (Cmd+Q on macOS / quit from the system tray on Windows — closing the window is not enough) and reopen it.
The first launch downloads the Python environment (a few hundred MB) — it can take several minutes and Claude Desktop may report the server disconnected once; it recovers on the next launch. The AlgoChains tools then appear under the tools icon in the chat box.
Alternative: paste this to Claude Code
If you prefer not to use the extension (or want the server under your own config), copy the
entire block below, replace YOUR_API_KEY_HERE with your key, and paste it to a Claude
that can run commands on your computer (Claude Code, or Claude Desktop with file/terminal
access).
Please install the AlgoChains MCP server into my Claude Desktop. Follow these steps
exactly and carefully:
My AlgoChains API key is: YOUR_API_KEY_HERE
0. If the key above still literally says "YOUR_API_KEY_HERE", STOP and tell me to
replace it with my real API key from https://algochains.ai before continuing.
1. Check whether the `uv` tool is installed (run `uv --version`). If it is missing,
install it:
- macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
- Windows: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Then verify `uv --version` works (open a fresh shell or use its full install path if
needed — note the absolute path to the uvx executable if it is not on PATH).
2. Pre-download the server so Claude Desktop's first launch is fast: run
`uvx --python 3.12 algochains-library-mcp --version`
and wait for it to finish (the first run downloads a few hundred MB — this can take
several minutes; that is normal). It must print a version number.
3. Open my Claude Desktop config file, creating it (and its folder) if it does not exist:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: %APPDATA%\Claude\claude_desktop_config.json
4. Merge the following server entry into the "mcpServers" object WITHOUT removing or
modifying any servers already there. If the file is empty or missing, create it with
exactly this content. If an "algochains" entry already exists, update it in place.
Preserve valid JSON (no trailing commas, no comments):
{
"mcpServers": {
"algochains": {
"command": "uvx",
"args": ["--python", "3.12", "algochains-library-mcp"],
"env": {
"ALGOCHAINS_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}
Use my real API key from the top of this message as the ALGOCHAINS_API_KEY value.
If step 1 showed that uvx is not on the system PATH, use the absolute path to the
uvx executable as "command" instead of "uvx".
5. Validate that the final file parses as JSON, show me the resulting "algochains"
entry (mask the middle of the API key), and confirm no other entries were changed.
6. Tell me to FULLY quit Claude Desktop (Cmd+Q on macOS / quit from the system tray on
Windows — closing the window is not enough) and reopen it. The AlgoChains tools will
then appear under the tools icon in the chat box.
Do not do anything beyond these steps.
Manual install
- Install uv.
- Pre-download the server (first run takes a few minutes):
uvx --python 3.12 algochains-library-mcp --version - Edit your Claude Desktop config —
macOS
~/Library/Application Support/Claude/claude_desktop_config.json, Windows%APPDATA%\Claude\claude_desktop_config.json— and merge in:
{
"mcpServers": {
"algochains": {
"command": "uvx",
"args": ["--python", "3.12", "algochains-library-mcp"],
"env": {
"ALGOCHAINS_API_KEY": "your_key_here"
}
}
}
}
- Fully quit (Cmd+Q / tray-quit) and reopen Claude Desktop.
Troubleshooting
- "spawn uvx ENOENT" / server won't start: Desktop apps don't see your shell PATH — put the
absolute path to
uvx(usually~/.local/bin/uvx, Windows%USERPROFILE%\.local\bin\uvx.exe) in"command". - First launch times out: run
uvx --python 3.12 algochains-library-mcp --versionin a terminal once (downloads the environment), then restart Desktop. - "ALGOCHAINS_API_KEY is not set": check the
envblock in the config entry, then fully restart Desktop. - Python errors on install: the server needs Python 3.10–3.12 — that is why
--python 3.12is in the args; uv downloads that interpreter automatically if missing. Keep it. - Updating: paste "please update the algochains MCP server" to Claude — it runs
uvx --python 3.12 algochains-library-mcp@latest --version, then fully restart Desktop.
Example asks
Research:
"For crypto, pick a highly-traded coin and show trading hours in 30-min bins over the last 3 months. Highlight the busiest hours and shade market opens for London (blue), China (red), Brazil (green), with NYSE as the base case."
Build & backtest:
"Build an opening-range-breakout on SPY — range = first 10 min of the NY session, relaxed 3× ATR trailing stop, force-exit at 12:00 ET, over the past 3 months."
What it does
| Kind | Name | What it does |
|---|---|---|
| resource | algochains://agents-guide |
The library's AGENTS.md — API, symbols, resolutions, examples (plus the server's determinism rules). |
| tool | research_query |
Historical OHLCV for one symbol or a list — a quick look (wraps algochains.research_query). |
| tool | run_python |
Run Python in a temp dir; any matplotlib figure is returned inline (themed). |
| tool | build_report |
Run analysis cells in a temp dir; charts inline + report as markdown text. |
| tool | build_algorithm |
Write a bt.Strategy and backtest it in the background; keeps the CSVs in a per-name temp dir (no plotting). |
| tool | make_backtest_dashboard |
Render the run (waits if it's still running): fast matplotlib PNG inline + a React+Recharts interactive artifact. |
| tool | send_signal |
Propagate a live trade signal (requires SIGNAL_SECRET; off by default). |
Claude reads the resource to ground itself in the library, then uses the tools to answer.
Backtesting is two steps, mirroring research → build_report:
build_algorithm(name, ...)launches the backtest in the background (Backtrader is slow — long or multi-symbol runs take minutes) and returns quickly withstate:"done"or"running".make_backtest_dashboard(name)waits for the run if needed, then renders a matplotlib PNG inline plusartifact_jsx— a React+Recharts component Claude drops into an artifact for an interactive dashboard (candlestick equity, drawdown, rolling Sharpe, per-trade P&L, round trips).
What's written to disk
- Research code and backtests run in throwaway temp dirs; a backtest's raw CSVs sit in a per-name temp dir that is auto-deleted ~12h after the run.
- Each completed backtest also saves two small files for you to
~/Documents/AlgoChains/comparisons/<run-name>/: the exact strategy script that ran and itsround_trips.csv— so you can compare runs later (override the location withALGOCHAINS_LIBRARY_MCP_COMPARISONS_DIR).
run_python,build_report, andbuild_algorithmexecute model-written Python locally on your machine — that's how Desktop (no code execution of its own) does the analysis. Only connect this server in an environment you trust.
Notes
- Symbol formats: Forex
EUR-USD, StocksAAPL, CryptoBTC-USD. - Multiple symbols:
research_queryandbuild_algorithmaccept a list of symbols as well as a single string. Multi-symbol backtests use the('symbols', [])param andself.datas[i](see the agents-guide "Multi-asset" section); the equity curve is the true combined portfolio value. - Resolutions:
1m,5m,15m,30m,1h,4h,1d. Databases:Forex,Stocks,Crypto. - Charts use a shared matplotlib/mplfinance theme; the interactive dashboard is React+Recharts (Plotly and other CDN-loaded libraries fail in Desktop's artifact sandbox — Recharts is bundled).
Development
git clone <repo> && cd mcp_algochains
uv venv && uv pip install -e .
mkdir -p ~/.algochains && echo "ALGOCHAINS_API_KEY=your_key_here" > ~/.algochains/.env
python -m algochains_library_mcp # raw stdio
mcp dev src/algochains_library_mcp/server.py # MCP Inspector
The server reads its API key from the process environment first (Claude Desktop's env block),
falling back to ~/.algochains/.env. A project-local .env is no longer read — early
testers should move their key. Build and publish with uv build / uv publish.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file algochains_library_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: algochains_library_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
284f997f3f6b3003fe0aa7f457299a5385c8e78686f3eb6fb907175926ebc131
|
|
| MD5 |
71f0d2f27da730560452239adfb62807
|
|
| BLAKE2b-256 |
30c309e1919a5593ab0de25936852e73b0b09c38353816d0f5165e09f69a91dc
|