MCP server
Bagtester MCP — backtesting for AI coding agents
Bagtester is an MCP (Model Context Protocol) server for backtesting Python trading strategies. Your agent writes a strategy, calls our MCP, and gets a 107-metric structured result back — no IDE switch, no data wrangling, no infrastructure setup. Works with Claude Code, Cursor, Codex, Windsurf, and any MCP-compatible client.
Add Bagtester to your agent
Claude Code
Setup →claude mcp add bagtester \ --transport http \ https://bagtester.com/api/mcp \ --header "Authorization: Bearer bag_YOUR_KEY"
Cursor
Setup →{
"mcpServers": {
"bagtester": {
"url": "https://bagtester.com/api/mcp",
"headers": {
"Authorization": "Bearer bag_YOUR_KEY"
}
}
}
}Codex CLI
Setup →{
"mcp_servers": {
"bagtester": {
"url": "https://bagtester.com/api/mcp",
"transport": "http",
"headers": {
"Authorization": "Bearer bag_YOUR_KEY"
}
}
}
}Windsurf setup is identical to Cursor. See all agents for per-client tips.
The 31 Bagtester MCP tools
Every tool the Bagtester MCP server exposes via JSON-RPC tools/list. Full schemas, examples, and tier gating in the MCP API reference.
| Tool | What it does | Tier |
|---|---|---|
| submit_strategy | Run a single backtest. The dominant tool. | all |
| get_backtest_results | Fetch a previously-submitted job by ID. | all |
| list_my_jobs | Your recent backtests, most recent first. | all |
| list_strategy_templates | Vetted templates incl. fast vectorized variants. Read before writing strategy code. | public |
| list_available_data | Asset catalog with tier metadata. | public |
| get_data_sample | Last N OHLCV rows. Verify schema before submitting. | public |
| optimize_strategy | Parameter sweep ranked by your metric. | Quant |
| walk_forward | Rolling in-sample / out-of-sample test. | Quant |
| improve_strategy | Re-run with one structured improvement. | all |
| search_backtests | Filter historical backtests. | all |
| list_experiments | List your experiment groups. | all |
| get_experiment | One experiment with all child runs + heatmap. | all |
| compare_backtests | N-way side-by-side (2-10 jobs). | all |
| create_experiment | Manually group jobs into an experiment. | all |
| manage_subscription | Plan + credits + Stripe portal + review status — without leaving the agent. | all |
| purchase_topup | Buy a credit top-up on the user's saved card (off-session, capped). | paid |
| set_agent_cap | Change the monthly agent-purchase cap. Raises require browser confirmation. | all |
| report_issue | File a support ticket on the user's behalf. Manual triage with agent-to-agent automation rolling out. | all |
| get_support_ticket | Poll a ticket's status + resolution. Forward back to user in-chat. | all |
| submit_review | Submit a public review (one per user). Auto-publishes to reviews.bagtester.com; user receives 1000 credits. | all |
| admin_list_tickets | ADMIN ONLY. List support tickets across all users with filters (status, priority, category, since). For cron-driven triage agents. | admin |
| admin_get_ticket | ADMIN ONLY. Fetch full ticket payload including code/stack-trace with the user's consent quote. | admin |
| admin_update_ticket | ADMIN ONLY. Write resolution + status + assignee. resolved_at auto-set on resolved/closed. resolution_by defaults to admin email; pass explicitly for automated agents. | admin |
Standardized result schema
107 metrics across 8 categories, 12 quality flags. Same shape for minute, hybrid, and tick modes — your agent can compare runs apples-to-apples.
Sandboxed Python
Strategies run on Cloud Run with numpy, pandas, polars, scipy, scikit-learn, statsmodels, ta-lib, pandas-ta pre-installed. No network egress, no pip install.
Subscription in the agent
manage_subscription returns a Stripe customer-portal URL. Cancel, upgrade, or change payment method without leaving the agent — unique to Bagtester.
Common MCP questions
What is the Bagtester MCP server?+
An HTTP JSON-RPC endpoint at https://bagtester.com/api/mcp that exposes 23 backtesting tools to AI coding agents. Your agent calls submit_strategy with a Python Strategy subclass and Bagtester runs it sandboxed on real market data, returning a 107-metric structured result. Additional tools handle subscription management, agent-to-agent support tickets, review submission, and admin-only ticket triage.
Which MCP clients does Bagtester work with?+
Any MCP-compatible client. Verified: Claude Code, Cursor, Windsurf. Codex CLI native MCP config is spec-correct (end-to-end verification pending). The capability ad at GET /api/mcp lets any client discover the tool list.
Is there an MCP server registry I can find Bagtester in?+
Listings are rolling out: Anthropic Connectors Directory, modelcontextprotocol/servers, awesome-mcp-servers, mcp.app, PulseMCP. In the meantime, add it directly: `claude mcp add bagtester --transport http https://bagtester.com/api/mcp --header "Authorization: Bearer bag_YOUR_KEY"`.
How is Bagtester's MCP authentication handled?+
Bearer token in the Authorization header. Tokens start with bag_ and are generated from your dashboard. Each token belongs to one user account; per-user concurrency and credit caps apply.
What does the Bagtester MCP return?+
Schema v2.0: 107 metrics across 8 categories (returns, risk, risk-adjusted, trades, exposure, benchmark, distributions, plus summary), 12 quality flags with severity, sparkline previews, PNG chart URLs, public share URL, and agent-friendly next_steps suggestions.
Try Bagtester MCP
Free tier ships 500 credits/month. Add the MCP server to your agent in 60 seconds.