MCP server exposing the Backtest360 engine API as tools for AI agents
Project description
backtest360-mcp
MCP server exposing the Backtest360 engine API as tools for AI agents.
Connect any MCP-capable AI client and drive real backtests conversationally: discover indicators, build and validate strategies, run backtests, and read the results — all against the deterministic Backtest360 engine. The server contains no AI and computes no numbers of its own; it is a thin, faithful adapter over the engine HTTP API. Your engine API key and its plan govern everything (permissions, rate limits, data access).
Status: pre-release (v0.1.x). Local stdio transport. Remote (HTTP) deployment is planned.
Install
pip install backtest360-mcp # or, from a clone: pip install -e .
Requires Python 3.10+ and a Backtest360 API key — create one at backtest360.com.
Configuration
Everything is environment-driven:
| Variable | Required | Default | Purpose |
|---|---|---|---|
BACKTEST360_API_KEY |
yes | — | Engine API key, sent as X-API-Key |
BACKTEST360_ENGINE_URL |
no | https://api.backtest360.com |
Engine base URL |
BACKTEST360_MCP_TIMEOUT |
no | 300 |
Per-request timeout (seconds) |
BACKTEST360_MCP_MAX_OUTPUT_BYTES |
no | 100000 |
Hard cap on a single tool result |
Connect an MCP client
Add the server to your MCP client's configuration (the common mcpServers shape):
{
"mcpServers": {
"backtest360": {
"command": "backtest360-mcp",
"env": {
"BACKTEST360_API_KEY": "b360_..."
}
}
}
}
Prefer not to put the key in a config file? Point command at a small wrapper script
that exports the key from your secrets manager and then runs backtest360-mcp. A
minimal example config is in examples/mcp.json.
Tools
| Tool | What it does |
|---|---|
engine_info |
Engine version, API contract, health |
get_catalog |
Reference catalogs: operators, execution modes, stop types, sizing methods, bar frequencies, metric sections |
list_indicators |
Indicator discovery; per-indicator parameter schemas |
get_strategy_schema |
JSON Schema for strategy documents |
validate_strategy |
Validate a strategy without running it — returns structured, locatable errors |
run_backtest |
Run a historical backtest |
get_latest_signal |
Evaluate the most recent bar only (no P&L) |
compare_backtests |
Run several strategies on the same data, side by side |
compute_stats |
Compute the metric set from an externally produced returns series |
search_tickers / list_tickers |
Asset discovery for server-side data fetch |
get_data_range |
Available history and bar-count estimate for a symbol |
The cheap static catalogs are also published as MCP resources
(backtest360://catalog/{name}, backtest360://schema/strategy) for clients that
support resource attachment.
Response shaping
A full backtest result is megabytes; an agent's context is not. run_backtest and
compare_backtests take response_detail:
summary(default) — headline metrics, warnings, counts, equity endpointsstats— every metric the plan allowsfull— plus series (downsampled, endpoints preserved) and trades (paginated)
include=["trades", "equity_curve", "monthly_returns", "yearly_returns"] adds specific
blocks at the lighter levels. Results exceeding the output cap are reduced further and
explicitly marked truncated_by_mcp — never silently cut. Shaping only ever selects and
thins what the engine returned; no value is computed or altered.
Error semantics
Designed for agents:
- Fixable by changing the request → returned as a normal result: failed validations
arrive as
{"valid": false, "errors": [...]}with machine codes and document locations; engine rejections arrive as{"accepted": false, "error": ...}with a hint. - Not fixable that way → a tool error with explicit guidance: rate limits carry the
Retry-Aftervalue; engine-busy says retry with backoff; a compute timeout says do not retry and reduce scope instead; permission problems name the missing capability. Engine request ids are included for support.
Development
pip install -e ".[dev]"
pytest # unit suite against a mock engine — no network
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 backtest360_mcp-0.1.1.tar.gz.
File metadata
- Download URL: backtest360_mcp-0.1.1.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17b9787fe42c8bdffa786a418c3001496ccb515dfab11a3ede9fab254d07abfa
|
|
| MD5 |
99b7959621ee0f486b0f8de16c309f0e
|
|
| BLAKE2b-256 |
05cbd30bc1ce5755c6c18f774203e86378570ed9c20e58c6687eefaa03e42749
|
Provenance
The following attestation bundles were made for backtest360_mcp-0.1.1.tar.gz:
Publisher:
release.yml on Backtest360/backtest360-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backtest360_mcp-0.1.1.tar.gz -
Subject digest:
17b9787fe42c8bdffa786a418c3001496ccb515dfab11a3ede9fab254d07abfa - Sigstore transparency entry: 1884740911
- Sigstore integration time:
-
Permalink:
Backtest360/backtest360-mcp@9c0fd5e2edf44b765a15bd380704e6898cf4b31c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Backtest360
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9c0fd5e2edf44b765a15bd380704e6898cf4b31c -
Trigger Event:
push
-
Statement type:
File details
Details for the file backtest360_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: backtest360_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 26.1 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 |
8f4fac86fecf17df76abb44476e21d79af9540b1699ccf2b9d11ec31608d5bed
|
|
| MD5 |
ca777a529571b48101c9a4ca748df435
|
|
| BLAKE2b-256 |
dd984553ec3d2c933397275c5443a4e90591d90c0d313aa40440c21684e59464
|
Provenance
The following attestation bundles were made for backtest360_mcp-0.1.1-py3-none-any.whl:
Publisher:
release.yml on Backtest360/backtest360-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backtest360_mcp-0.1.1-py3-none-any.whl -
Subject digest:
8f4fac86fecf17df76abb44476e21d79af9540b1699ccf2b9d11ec31608d5bed - Sigstore transparency entry: 1884741044
- Sigstore integration time:
-
Permalink:
Backtest360/backtest360-mcp@9c0fd5e2edf44b765a15bd380704e6898cf4b31c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Backtest360
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9c0fd5e2edf44b765a15bd380704e6898cf4b31c -
Trigger Event:
push
-
Statement type: