Codex CLI · Setup

Backtest from Codex CLI

OpenAI's Codex CLI supports MCP via its mcp_servers config block. Point it at Bagtester and the agent gets a 14-tool backtesting surface — submit, optimize, walk-forward, compare, manage subscription.

Status (May 2026): Bagtester is verified working end-to-end with Claude Code and Cursor. Codex CLI compatibility is high-confidence by spec (HTTP MCP transport), but we haven't yet completed an internal dogfood test. If you hit a rough edge, please ping us.

Setup

1

Get an API key

Sign up at bagtester.com/sign-up. Create a key in the dashboard — it starts with bag_.

2

Edit your Codex config

Open ~/.codex/config.toml and add a new MCP server block:

toml
[mcp_servers.bagtester]
type = "http"
url = "https://bagtester.com/api/mcp"

[mcp_servers.bagtester.headers]
Authorization = "Bearer bag_YOUR_KEY_HERE"

If you prefer per-project config, drop the same block into your repo's.codex/config.toml.

3

Verify the connection

Start a Codex session and ask:

prompt
list bagtester tools

The agent should enumerate all 14 tools.

4

Run a backtest

prompt
backtest an RSI mean-reversion strategy on ETHUSDT for 2024-2025

Codex writes the strategy, calls submit_strategy, and reads the structured result back. You see metrics + sparkline + share URL right in the terminal.

Tips for Codex specifically

Try it

Free tier: 500 credits/month. Add the block above to ~/.codex/config.toml and ask Codex to run a backtest.