Coding agents like Cursor and Claude Code are exceptionally good at writing portfolio math in Python, yet running a script locally still leaves you solving data ingestion, ETF corporate-action adjustments, history backfills, reproducible run storage, scheduled daily refreshes, and broker CSV formatting on your own.
Connecting Cursor or Claude Code to ENSEMBLE gives your coding agent a complete cloud execution and persistence backend while you keep full control over Python code, Git history, and code review.
Setup in under two minutes
Cursor (OAuth one-click or mcp.json)
Use the one-click Add to Cursor flow on the MCP setup page to authenticate via OAuth, or configure ~/.cursor/mcp.json directly with an API key from Connections:
{
"mcpServers": {
"ensemble": {
"url": "https://api.ensemble.markets/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Claude Code (Terminal agent)
Register the remote Streamable HTTP server in one command, then run /mcp inside Claude Code to authenticate with OAuth:
claude mcp add --transport http ensemble https://api.ensemble.markets/mcp
The IDE-to-ENSEMBLE quant loop
A clean developer workflow combines local code discipline with ENSEMBLE's hosted runtime:
- Inspect runtime limits and data coverage first. Have Cursor or Claude Code call
get_runtimeandlist_assets/get_assetso your script uses supported Python libraries, respects runtime caps, and verifies each ETF's observed start date before coding. - Author locally with declared
inputs_schema. Write your strategy or reusable optimizer in your repo, declaring primary parameters (such asuniverse,lookback_days,rebal_frequency,drift_band) cleanly in JSON Schema so both agents and the web UI render typed controls. - Run free
validate_onlychecks. Before spending build credit, invokecreate_model(orupdate_model) withvalidate_only=trueto catch syntax errors, unsupported imports, or schema mismatches at zero cost. - Build, sweep, and compare runs. Execute the baseline build, then launch isolated parameter sweeps (
intent=test) and inspectcompare_runsover matched windows. - Extract reusable math into an optimizer. Once a solver (such as constrained minimum-variance, hierarchical risk parity, or equal risk contribution) works well, store it via
create_optimizerso every downstream model shares one reviewed method.
Combining MCP with the ensemble CLI
In Cursor's integrated terminal or Claude Code's bash tool, pairing MCP with the ensemble CLI unlocks fast scripted audits:
# Verify account limits and active backfills before a parameter sweep
ensemble account -o json
ensemble backfills list -o json
# Pull historical allocations and metrics for a local diagnostic plot
ensemble runs get RUN_ID --include metrics,returns,allocation -o json > run_snapshot.json
Because reads are free and JSON output pipes cleanly to jq or local Python notebooks, you get the best of both worlds: local inspection tools backed by durable, scheduled cloud models. See Python notebooks vs. ENSEMBLE for where local scripts still make sense alongside ENSEMBLE.
Start building with your agent
Use the workflow below to define a reusable optimizer or custom strategy model from Cursor or Claude Code while checking existing methods and available credit first.
Use ENSEMBLE to confirm my connected account. Help me define a reusable allocation optimizer, inspect its source and inputs, and explain how to use the same method across my models. Check existing methods and available credit before creating or running anything.
Frequently asked questions
- How do I connect ENSEMBLE to Cursor?
- Use the one-click Add to Cursor deeplink on /mcp (OAuth dynamic client registration with no manual headers), or add the remote HTTP endpoint https://api.ensemble.markets/mcp with a Bearer API key in ~/.cursor/mcp.json for headless setups.
- How do I connect ENSEMBLE to Claude Code in the terminal?
- Run `claude mcp add --transport http ensemble https://api.ensemble.markets/mcp` and then run `/mcp` inside Claude Code to sign in with OAuth. You can alternatively pass `--header "Authorization: Bearer YOUR_API_KEY"`.
- Can I keep strategy code in Git and still run it in ENSEMBLE?
- Yes. You can author and version your Python allocation scripts and custom optimizers in a local Git repository, validate them against ENSEMBLE's runtime contract via `validate_only`, submit builds through MCP or the CLI, and keep every retained run ID linked to its script hash.
- Why build a reusable optimizer instead of copy-pasting math into every model?
- Storing an allocation method (such as Ledoit-Wolf shrinkage ERC or a custom constrained risk-budget solver) as a reusable ENSEMBLE optimizer lets multiple models share one reviewed implementation and inspect version dependencies cleanly.
Related
- AI agentsRead a saved run via the REST API and CLI.
Fetch metrics, target allocations, look-through trees, and side-by-side run comparisons from ENSEMBLE using the /v1 REST API or ensemble CLI.
- AI agentsPortfolio research with ChatGPT and Codex.
Connect ENSEMBLE to ChatGPT through the directory or Codex CLI via OAuth MCP to screen ETFs, build allocation models, and inspect retained runs.
- ComparePython notebooks vs. ENSEMBLE for portfolio research.
Compare Jupyter and pandas backtesting scripts with ENSEMBLE across data hygiene, ETF backfills, run persistence, scheduled refreshes, and broker exports.
- AI agentsAutomate model refreshes with the API and webhooks.
Combine scheduled ENSEMBLE refreshes, Business HMAC-signed webhooks, and REST allocation exports to automate model review and reporting pipelines.