Agent Setup
How to give AI agents access to Keel via MCP, CLI, and bundled skills.
Agent Setup
Keel exposes a local, typed MCP server and an equivalent CLI surface for
strategy research. This page is for external agents such as Claude Code,
Cursor, Windsurf, Codex, and other stdio MCP clients. The Keel web app's
managed chat may use internal tool names; do not copy those internal names
into MCP instructions. For local agents, the active tools/list response and
the keel_* tool schemas are authoritative.
Quick start
pipx install keel-trade
claude mcp add keel -- keel mcp serveOpen your agent and say:
"Connect to Keel."
The agent calls keel_auth_login, your browser opens to
app.usekeel.io/oauth/connect, you complete OAuth 2.1 + PKCE consent, and
tokens are cached in ~/.keel/config.yaml. The same login covers MCP calls and
direct keel CLI usage.
Headless terminal alternative:
keel auth login --key <token>Create the token at app.usekeel.io/settings?tab=api-keys.
MCP server
Register this command with any stdio MCP client:
keel mcp serveClaude Code:
claude mcp add keel -- keel mcp serveCursor:
{
"mcpServers": {
"keel": {
"command": "keel",
"args": ["mcp", "serve"]
}
}
}Windsurf:
{
"mcpServers": {
"keel": {
"command": "keel",
"args": ["mcp", "serve"]
}
}
}Codex:
codex mcp add keel -- keel mcp serveLocal read-only tools such as component search, compose help, status, and knowledge lookup work without auth. API-backed tools such as backtest, accounts, sharing, and live deployment require a login.
The agent host launches keel mcp serve as a child process and talks to it
over stdin/stdout. Users do not need to run a daemon, open a port, or start a
separate local service. This keeps tool calls connected to the user's local
files, project workspace, and cached CLI auth context.
MCP tools
tools/list returns the active set under KEEL_TOOLSETS. The default SDK
surface loads always,read-only,backtest,share,live-read, which exposes the
normal research workflow plus read-only live monitoring and omits live-trading
mutation tools.
| Domain | MCP tools |
|---|---|
| Status and auth | keel_status, keel_auth_login, keel_doctor, keel_help |
| Components | keel_components_search, keel_components_detail_batch, keel_components_compose_help |
| Strategy lifecycle | keel_strategy_compose, keel_strategy_get, keel_strategy_search, keel_strategy_fork, keel_strategy_diff, keel_strategy_delete, keel_strategy_checkout, keel_strategy_pull, keel_strategy_push, keel_strategy_discard, keel_strategy_restore, keel_strategy_log, keel_strategy_workspaces, keel_strategy_status, keel_strategy_memory_read, keel_strategy_memory_write |
| Backtest and audit | keel_backtest_run, keel_backtest_watch, keel_backtest_summarize, keel_audit_list_last |
| Accounts, sharing, and live read | keel_accounts_list, keel_share_create, keel_live_monitor |
| Live write, opt-in | keel_live_deploy, keel_live_control |
For exact tool schemas, required args, safety annotations, and CLI equivalents, use the generated MCP Tool Reference.
For components, use keel_components_search to find candidates,
keel_components_detail_batch to compare several schemas before composing,
and keel_components_compose_help only for one known component's schema/detail.
To expose live write tools to MCP clients, start the server with:
KEEL_TOOLSETS=always,read-only,backtest,share,live-read,live-write keel mcp serveActual live deployment still requires all safety gates:
- OAuth live scope:
keel auth login --scope live - Local machine arming:
keel arm live set --account <account_id> - Explicit deploy intent:
keel_live_deploy(preview=False, ...)orkeel live deploy <strategy_id> --account-id <account_id> --no-preview
Always preview first with keel_live_deploy(preview=True, ...).
MCP resources
Agents can also read these resources:
| URI | Content |
|---|---|
keel://components/catalog | Component registry snapshot |
keel://components/{name}/schema | Component parameter and slot schema |
keel://strategy/{strategy_id}/source | Strategy source |
keel://strategy/{strategy_id}/lockfile | Strategy lockfile |
keel://backtest/{backtest_id}/results | Backtest result payload |
keel://backtest/latest | Latest org backtest pointer and results when available |
keel://strategy/{strategy_id}/backtest/latest | Latest backtest pointer for one strategy |
keel://dsl/reference/{topic} | DSL reference docs |
keel://knowledge/{section} | Bundled knowledge docs |
keel://context/user | User-level context for agents |
keel://context/project | Project-level context for agents |
keel://context/strategy/{strategy_id} | Strategy-specific context |
Workflow prompts
Good prompts map to specific Keel tool calls:
-
"Connect to Keel and show my status." The agent calls
keel_auth_login, thenkeel_status. -
"Find momentum and funding components that can be composed together." The agent calls
keel_components_searchandkeel_components_detail_batch. -
"Compose a funding-carry strategy, validate it, and save it as my baseline." The agent calls
keel_strategy_composefirst withdry_run=True, then again withdry_run=Falsewhen the source is valid. -
"Backtest my baseline from 2025-06-01 through 2026-02-01 and summarize it." The agent calls
keel_backtest_run; if the run is still active, it callskeel_backtest_watch(backtest_id=<run_id>); if it needs more terminal detail, it callskeel_backtest_summarize(backtest_id=<run_id>). -
"Preview a live deployment for this strategy on account acct_123." The agent calls
keel_live_deploy(preview=True, ...). It should not callpreview=Falseunless the user explicitly asks to deploy live.
Bundled skills
Keel ships behavioral skills for agent hosts that support them:
| Skill | Use it for |
|---|---|
strategy-creation | Thesis to component search to composed strategy |
strategy-fork-and-iterate | Forking, comparing, and pushing strategy edits |
backtest-and-analyze | Running backtests and interpreting metrics |
overfit-check | Stress-checking a promising result |
deploy-and-monitor | Live preview, explicit deployment, and monitoring |
portfolio-review | Portfolio and deployment-level review |
component-discovery | Component catalog exploration |
recover-from-error | Auth, validation, entitlement, and runtime recovery |
When a skill mentions tools, use the current keel_* MCP schemas from
tools/list for exact argument names. Some bundled research knowledge is also
used by Keel's web chat; if a shared note names an internal chat tool, prefer
the MCP tool listed in the skill frontmatter.
CLI for shell-based agents
Agents can also call the CLI. In agent contexts the CLI auto-selects JSON where possible, and every outcome command has an underscore-equivalent MCP tool:
keel status --format json
keel components search momentum --format json
keel components describe-batch ROC FundingRate --format json
keel strategy compose --source-file strategy.py --dry-run --format json
keel strategy compose --source-file strategy.py --name carry-baseline --format json
keel backtest run str_abc123 --start-date 2025-06-01 --format json
keel backtest watch btr_xyz789 --format json--end-date is optional for keel backtest run and defaults to today's UTC
date. Pass it when you need a fixed historical window.
For a project-level agent instruction file, keep it small and current:
## Keel Strategy Development
Use Keel for strategy research.
1. Check status: `keel status --format json`
2. Search components: `keel components search momentum --format json`
3. Inspect schemas: `keel components describe-batch ROC FundingRate --format json`
4. Validate source: `keel strategy compose --source-file strategy.py --dry-run --format json`
5. Save source: `keel strategy compose --source-file strategy.py --name <name> --format json`
6. Backtest: `keel backtest run <strategy_id> --start-date YYYY-MM-DD [--end-date YYYY-MM-DD] --format json`
7. Watch if needed: `keel backtest watch <backtest_id> --format json`
If a command is not shown by `keel --help`, do not call it. For current
workflows, prefer compose, watch, summarize, monitor, and control commands shown
above.Auth and safety
Use keel_status or keel status first when an agent session starts. If a
remote tool returns an auth error, call keel_auth_login or run
keel auth login.
Live trading is deliberately harder than research:
KEEL_TOOLSETSonly controls MCP exposure; the CLI always has the command group available.keel live deploydefaults to preview mode.- Actual deployment requires
--no-preview, OAuth live scope, and local arming. - Control actions use one tool:
keel_live_control(deployment_id=<id>, action="pause"|"resume"|"stop"|"trigger"). keel_live_monitorreturnsfreshnessmetadata. Positions are on-demand Hyperliquid snapshots; portfolio/history views are backend records and can lag the web dashboard live stream.
Troubleshooting
keel doctor
keel auth status
keel status --format json
keel components search <partial_name> --format json
keel help dsl_syntaxCommon recovery paths:
- Not authenticated: call
keel_auth_loginor runkeel auth login. - Missing live write tools in MCP: restart with
KEEL_TOOLSETS=always,read-only,backtest,share,live-read,live-write. - Live deploy rejected: verify
keel auth login --scope live, thenkeel arm live set --account <account_id>. - Strategy source rejected: rerun
keel_strategy_composeorkeel strategy composein dry-run mode and follow the structured error.