Backtrader MCP¶
Backtrader MCP is an independent, local-first MCP server for building and running reproducible Backtrader strategies. It turns confined CSV files into immutable datasets, typed strategy intent into private drafts, and reviewed drafts into bounded subprocess runs with durable status and reports.
The product is deliberately offline and backtest-only: no brokers, no stores, no credentials, no live orders, no arbitrary Python execution, no network transports.
Highlights¶
- Immutable data: content-addressed CSV datasets with a data-quality gate
(OHLC consistency), six typed adapters, resample/replay bar operations,
streamed derivation (
identity/dropna/returns/sma) whose feature columns feedprecomputed_mlstrategies. - Reviewable strategy intent: seven archetypes × two output profiles, AST validation without server-side imports, allowlisted analyzers (sqn/calmar/vwr/timereturn), and an optional frozen seed.
- Human-gated authorization: HMAC hash-bound tokens with one-time nonces, a trusted local approval CLI for both changes and runs, and full audit trails with the approver's OS identity.
- Durable execution: CAS-guarded job state machine, a server-owned
watchdog, structured
error_kindclassification, cancellation, timeout, crash recovery,parameter_sweepgrids, and normalized 11-metric reports with a policy-driven comparison profile. - Observable and operable:
list_jobs/get_run_logs/list_target_tree, structured tool errors withSuggestion:guidance, a read-onlydoctordiagnostic, and retention cleanup for every stored object class.
Quick start¶
python -m venv .runtime
. .runtime/bin/activate
python -m pip install -c constraints/requirements-v2.txt .
python -m backtrader_mcp --help
Then configure the four root variables and register the server with your MCP host — see Installation and Host setup.
Related projects¶
The CloudQuant Backtrader ecosystem:
cloudQuant/backtrader— the pinned Backtrader runtime fork this product executes.cloudQuant/backtrader-mcp— this MCP server.cloudQuant/backtrader-skills— companion skills for Backtrader workflows.cloudQuant/backtrader_web— companion web product.cloudQuant/backtrader-agent— companion agent product.cloudQuant/fincore— FinCore, companion financial infrastructure.