Model Context Protocol (MCP) server for the manifoldbt backtesting engine
Project description
manifoldbt-mcp
Releasing to PyPI is fully automated via GitHub Actions + PyPI Trusted Publishing — just tag
vX.Y.Zand push.
Model Context Protocol (MCP) server for manifoldbt — the Rust-powered backtesting engine for quantitative research.
Expose the full manifoldbt backtesting engine to any MCP-compatible client (Claude Desktop, Claude Code, Cursor, Devin, VS Code, Windsurf, …). Let an LLM author strategies, run backtests, sweep parameters, and generate tearsheets — without the user writing a line of Python.
This package is not affiliated with the manifoldbt authors; it is a thin
adapter that imports the published manifoldbt wheel and wraps its Python
API behind an MCP server. All heavy lifting is done by the underlying Rust
engine.
Install
pip install manifoldbt-mcp
This pulls in manifoldbt and the reference mcp Python SDK as
dependencies. Python 3.10+ is required.
Optional extras:
pip install "manifoldbt-mcp[plot]" # matplotlib, for plot_tearsheet
pip install "manifoldbt-mcp[dev]" # pytest, ruff, matplotlib
Run
manifoldbt-mcp # stdio transport (default)
manifoldbt-mcp --http --port 8765 # streamable-HTTP transport
manifoldbt-mcp --http --host 0.0.0.0 # remote deployment
Client configuration
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json
(or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"manifoldbt": {
"command": "manifoldbt-mcp"
}
}
}
Claude Code
claude mcp add manifoldbt -- manifoldbt-mcp
Cursor / Windsurf
{
"mcpServers": {
"manifoldbt": {
"command": "manifoldbt-mcp"
}
}
}
VS Code (Continue, Cline, …)
Any MCP-over-stdio client will work — just point it at the manifoldbt-mcp
binary that pip installed on your PATH.
Remote (HTTP)
manifoldbt-mcp --http --host 0.0.0.0 --port 8765
Then connect your MCP client to http://<host>:8765/mcp.
What is exposed
20 tools
| Tool | Purpose |
|---|---|
get_version |
Return manifoldbt version + license tier (Community / Pro). |
activate_license |
Activate a Pro license key for the running process. |
list_indicators_tool |
Enumerate all 45+ indicators with their Python signatures. |
list_examples, get_example |
Browse / fetch bundled example strategies. |
list_symbols, resolve_symbol |
Inspect a DataStore, resolve tickers. |
ingest_data |
Pull bars from Binance / Hyperliquid (Databento / Massive on Pro). |
build_strategy |
Compile a Python DSL snippet → StrategyDef JSON + params. |
validate_strategy |
Validate a StrategyDef JSON through the Rust compiler. |
run_backtest |
Run a single backtest and return metrics + summary. |
run_batch |
Run many strategies in parallel on a shared data load. |
run_sweep |
Cartesian parameter sweep, ranked by any metric. |
run_sweep_2d |
2-D parameter heatmap. |
run_walk_forward |
Walk-forward optimisation (Pro). |
run_stability |
Parameter stability analysis. |
run_monte_carlo |
Trade-permutation Monte Carlo on a fresh backtest. |
run_stochastic |
SDE path simulation (GBM, Heston, Merton, GARCH-JD, or custom). |
run_portfolio |
Multi-strategy portfolio with risk rules & rebalancing. |
plot_tearsheet |
Render a full tearsheet PNG from a backtest. |
3 resources + 1 template
| URI | Content |
|---|---|
manifoldbt://reference/api |
Quick API tour. |
manifoldbt://reference/indicators |
Full indicator reference (Markdown). |
manifoldbt://reference/strategy-authoring |
The strategy authoring guide shipped with manifoldbt. |
manifoldbt://examples/{filename} |
Source of a bundled example (e.g. 01_trend_following.py). |
2 prompts
write_strategy(description, universe="BTC-USDT:perp")— scaffold a new strategy from a natural-language description.analyze_result(metrics_json)— turn arun_backtestmetrics payload into a research note.
Ergonomics
Every tool is JSON-friendly so LLM clients don't have to think about types:
- Dates — ISO strings:
"2022-01-01"or"2022-01-01 09:30:00". - Intervals — shorthand:
"1h","5m","15s","1d". - Fees — preset names:
"binance_perps","binance_spot","zero"; or a dict with individual overrides. - Slippage —
{"kind": "fixed_bps", "bps": 2},{"kind": "volume_impact", "impact_coeff": 0.1, "exponent": 1.5}, etc.
Writing a strategy from a client
Strategies are authored as Python DSL snippets executed in a namespace
that pre-imports every manifoldbt symbol — so the LLM never has to write
import statements:
fast = ema(close, 12)
slow = ema(close, 26)
strategy = (
Strategy.create("ema_cross")
.signal("fast", fast)
.signal("slow", slow)
.size(when(fast > slow, lit(0.5), lit(0.0)))
.stop_loss(pct=3.0)
)
Or, if the client prefers, send the already-serialised StrategyDef JSON
through strategy_json on any tool.
Example run_backtest payload
{
"strategy_code": "fast = ema(close, 12)\nslow = ema(close, 26)\nstrategy = Strategy.create('ema_cross').signal('fast', fast).signal('slow', slow).size(when(fast > slow, lit(0.5), lit(0.0))).stop_loss(pct=3.0)",
"config": {
"universe": {"binance": ["BTC-USDT:perp"]},
"start": "2022-01-01",
"end": "2024-01-01",
"bar_interval": "1h",
"initial_capital": 10000,
"fees": "binance_perps",
"slippage": {"kind": "fixed_bps", "bps": 2},
"warmup_bars": 60
},
"store": {
"data_root": "data",
"metadata_db": "metadata/metadata.sqlite"
}
}
Typical LLM session
list_indicators_tool→ discover available indicators.- Use the
write_strategyprompt → draft a strategy. build_strategy(strategy_code=…)→ validated StrategyDef + declared parameters.run_backtest(…)→ metrics + summary.run_sweep(…)ranked by Sharpe → find the best variant.plot_tearsheet(…)→ PNG tearsheet on disk.- Use the
analyze_resultprompt → research note.
Security
- The server runs with the permissions of the launching process.
strategy_codeis executed in-process by the Python interpreter — there is no sandbox. The DSL namespace is convenient (pre-imported manifoldbt symbols), but nothing prevents arbitrary Python from running. Only use this server with trusted clients, or run it isolated (dedicated venv, container, restricted user).- No inbound network unless you explicitly enable
--http.
Development
git clone https://github.com/ClementG91/manifoldbt-mcp
cd manifoldbt-mcp
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check .
Related
- Upstream engine: https://github.com/Jimmy7892/manifoldbt
- Model Context Protocol: https://modelcontextprotocol.io
- Reference Python SDK: https://github.com/modelcontextprotocol/python-sdk
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 manifoldbt_mcp-0.1.0.tar.gz.
File metadata
- Download URL: manifoldbt_mcp-0.1.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
358138854fbcab849064a1a80277561a60f8467736f73d5f16e19de892501778
|
|
| MD5 |
69eb44becbc7f4d3a7d92ac743b44443
|
|
| BLAKE2b-256 |
48c62404e1ef2ff3dccf3d224180a527686f33163cb1ff2061384b42c9d69347
|
Provenance
The following attestation bundles were made for manifoldbt_mcp-0.1.0.tar.gz:
Publisher:
release.yml on ClementG91/manifoldbt-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
manifoldbt_mcp-0.1.0.tar.gz -
Subject digest:
358138854fbcab849064a1a80277561a60f8467736f73d5f16e19de892501778 - Sigstore transparency entry: 1705448530
- Sigstore integration time:
-
Permalink:
ClementG91/manifoldbt-mcp@e12ff565304dc8b9d29a743f07dda9c398151c74 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ClementG91
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e12ff565304dc8b9d29a743f07dda9c398151c74 -
Trigger Event:
push
-
Statement type:
File details
Details for the file manifoldbt_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: manifoldbt_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddd3177a3d9b5f94cc4ebd7b693e38edce0e586410349fba0237b94b1738c0c8
|
|
| MD5 |
5ebc8ee7c14c0c039bd0bc4ee88eb8f2
|
|
| BLAKE2b-256 |
49ff798256d41135a7d84b962209b1d9414ee68b00c44c4113b5a48dff8fba66
|
Provenance
The following attestation bundles were made for manifoldbt_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on ClementG91/manifoldbt-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
manifoldbt_mcp-0.1.0-py3-none-any.whl -
Subject digest:
ddd3177a3d9b5f94cc4ebd7b693e38edce0e586410349fba0237b94b1738c0c8 - Sigstore transparency entry: 1705448538
- Sigstore integration time:
-
Permalink:
ClementG91/manifoldbt-mcp@e12ff565304dc8b9d29a743f07dda9c398151c74 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ClementG91
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e12ff565304dc8b9d29a743f07dda9c398151c74 -
Trigger Event:
push
-
Statement type: