candlefeed-mcp
An MCP server that gives Claude Code, Claude Desktop, Cursor or any MCP client the CandleFeed order book files as tools: find a published day, download it with SHA-256 checks, rebuild the Binance USD-M book, and ask for the book, spread or depth at any moment. It also wraps four REST datasets (candles, funding, open interest, liquidations). It runs locally over stdio, and order book files are rebuilt on your machine, not on ours.
The data is historical. Order book days are published the morning after each UTC day ends, and every known gap is listed in the public gap log.
Tools
| Tool | What it does | Key needed |
|---|---|---|
l2_coverage |
Published book and trade days per symbol, with unpublished days and the reason | no |
l2_gaps |
The public gap log: every stretch no capture node recorded, with times, size and reason | no |
l2_download_day |
Downloads one UTC day (book or trades) into the cache, size and SHA-256 checked; cached files are skipped |
yes |
l2_book_at |
Top N bids and asks at a moment, best bid/ask, mid, spread in bps, and the snapshot it was anchored on | no (local) |
l2_spread_summary |
Spread statistics for a day or window, sampled every 100ms to 5min, plus the biggest 1-minute mid move | no (local) |
l2_depth_summary |
Resting size within each bps band of the mid at a moment, in the base asset and USDT, optionally averaged over a window | no (local) |
candles |
OHLCV, intervals 1m to 1d | yes |
funding_rates |
Funding settlements per exchange | yes |
open_interest |
Open interest in contracts and USD | yes (Builder) |
liquidations |
Bucketed or tick liquidations | yes (Builder) |
Depth outside the anchor snapshot's known price window is partial. Report completeness per band and exclude incomplete samples from full-depth statistics. l2_depth_summary flags each band and averages complete samples only.
The SHA-256 checks prove the files are consistent with what CandleFeed published for that day. They aren't a signature: hashes delivered by the same service as the files can't detect that service itself being compromised or malicious.
The rebuild follows the published rule (the same code as candlefeed.l2book): anchor on a snapshot that isn't in_gap, apply the event that contains its lastUpdateId whole, and report nothing between a chain break and the next snapshot. A moment with no trustworthy book comes back as an error that says why.
What it costs to use
The 1st of every month is a free sample day on every plan, Free included, for every order book symbol. Sample downloads count against 10 GiB of new files per account per month; downloading the same file again that month is free. Every other day needs the Pro plan ($149/mo). A BTCUSDT book day is about 0.35 GB, so ask for days on purpose. REST tools follow the usual plan limits: Free gets BTC, ETH, SOL, XRP and DOGE on Binance for the last 30 days. Plans: https://candlefeed.ai/pricing?ref=mcp
CandleFeed data, including samples, is licensed for internal use under Terms §5.3. Published charts, statistics, and research must not include Raw Data or Substantially Raw Derivatives. The raw files and row-level data aren't to be shared.
Install
Needs Python 3.10+ (CPython) on Linux or macOS. Downloads rely on directory-relative, no-follow file operations to stay inside the cache, and refuse to run where those don't exist (Windows).
pip install candlefeed-mcp # pulls in candlefeed[l2] 0.3.0 or later
which candlefeed-mcp # use this absolute path below if your client can't find the command
Neither candlefeed-mcp nor client 0.3.0 is on PyPI yet. Until they are, install from a source tree: pip install "./clients/python[l2]" ./integrations/mcp.
Get a key at https://candlefeed.ai/signup?ref=mcp (free, no card). The server reads it from CANDLEFEED_API_KEY in its own environment and never takes it as a tool argument. It never prints it either: every result and error is scrubbed of the key and of download-link signatures.
Claude Code
claude mcp add candlefeed --env CANDLEFEED_API_KEY=cf_live_... -- candlefeed-mcp
Or in .mcp.json at the project root:
{
"mcpServers": {
"candlefeed": {
"command": "candlefeed-mcp",
"env": { "CANDLEFEED_API_KEY": "cf_live_..." }
}
}
}
A full BTC day download can take a minute or more. If a call times out, raise MCP_TOOL_TIMEOUT (milliseconds) before starting claude, and run the download again: files that finished are kept and skipped.
Claude Desktop
Settings, Developer, Edit Config, then add to claude_desktop_config.json:
{
"mcpServers": {
"candlefeed": {
"command": "/absolute/path/to/candlefeed-mcp",
"env": { "CANDLEFEED_API_KEY": "cf_live_..." }
}
}
}
Restart Claude Desktop. It doesn't inherit your shell's PATH, so use the absolute path from which candlefeed-mcp.
Cursor
~/.cursor/mcp.json (every project) or .cursor/mcp.json (one project):
{
"mcpServers": {
"candlefeed": {
"command": "candlefeed-mcp",
"env": { "CANDLEFEED_API_KEY": "cf_live_..." }
}
}
}
Settings
| Variable | Default | Meaning |
|---|---|---|
CANDLEFEED_API_KEY |
none | Your key. Needed for downloads and REST tools |
CANDLEFEED_CACHE_DIR |
~/.cache/candlefeed-mcp |
Where files go. On Linux and macOS (CPython), downloads write only inside it: each folder is opened without following symlinks and every write is relative to that folder's handle, temporary files are created exclusively, and file names and dates must be the ones requested. On a Python without those operations (Windows) downloads refuse to run. Before rebuilding a day the tools check that its folder contains no symlinks; that's a check at load time, not a guarantee against another process changing the cache while the server runs |
CANDLEFEED_BASE_URL |
https://candlefeed.ai/api/v1 |
API base; must be https |
CANDLEFEED_L2_STORAGE_HOST |
candlefeed-l2-canonical.sgp1.digitaloceanspaces.com |
The only host files are downloaded from (https, port 443) |
CANDLEFEED_MCP_MAX_DAY_BYTES |
2 GiB | Most new bytes one l2_download_day call will fetch |
CANDLEFEED_CACHE_MAX_BYTES |
20 GiB | Cache quota; a download that wouldn't fit is refused before it starts |
CANDLEFEED_MCP_DOWNLOAD_DEADLINE |
1800 | Seconds for one download. Checked before every request and after each chunk of a response body (8 KiB requested; compressed responses can yield larger decoded chunks). Not a hard limit: a server sending bytes slowly enough can stretch one chunk's read past it |
CANDLEFEED_MCP_ROW_CACHE_BYTES |
2 GiB | Decoded diff rows kept in memory for the loaded day. It limits that cache only, not the server's total memory; the event index, snapshots and read buffers come on top |
Downloaded days sit under <cache>/book/binance/<SYMBOL>/<YYYY-MM-DD>/, the same layout CandleFeed().download_l2 writes, so you can open them with candlefeed.l2book.L2Book.load(<cache>, "BTCUSDT", "2026-09-01") in your own code.
Try it
Download the free BTCUSDT order book sample for 2026-09-01, find the biggest 1-minute move of the day, and show me the spread and the depth within 10 and 50 bps for ten minutes either side of it.
The agent calls l2_download_day, l2_spread_summary (which reports the biggest 1-minute move) and l2_depth_summary with window_minutes=10. examples/l2_agent_demo.py in the repo does the same in plain Python, with a chart.
Development
pip install -e "./clients/python[l2,dev]" -e "./integrations/mcp[dev]"
pytest integrations/mcp/tests
Tests mock every HTTP call and build synthetic order book days with a known true book.
Metadata
Release files for candlefeed-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| candlefeed_mcp-0.1.0.tar.gz | 24.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| candlefeed_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.0 kB
Release files / candlefeed_mcp-0.1.0.tar.gz
| Download URL | candlefeed_mcp-0.1.0.tar.gz |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
259b0ebb2664ff7af13065a9d960e887f6956488c7b0e81f73c5bd472a1978ad
|
|
BLAKE2b-256 checksum How to use checksums |
001bb8c7489747bffd12a2ae89abfafbb04425ddbf2ec505a265b9fe12ef05ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / candlefeed_mcp-0.1.0-py3-none-any.whl
| Download URL | candlefeed_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f305447f77034847b9f00188ffe8b0357fc4ea7d577f032669ad923c460fffa4
|
|
BLAKE2b-256 checksum How to use checksums |
733b2466d434a8468be7c630e4a9b023b886eda3cdd44c890c635d2dce2333ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|