Keel — CLI and MCP server for AI-driven crypto strategy development
Project description
Keel Agent SDK
Keel is an agent-native research environment for Hyperliquid systematic
trading. The Python package provides one keel CLI and one stdio MCP command.
Both surfaces bind to the same outcome-tool registry.
This file is the package README and agent instruction entry point. Keep it short, current, and operational. Do not add command inventories unless they are checked against the outcome registry.
Install
pipx install keel-trade
claude mcp add keel -- keel mcp serve
uv tool install keel-trade also works. Agent hosts launch the MCP command as
a stdio child process:
keel mcp serve
First Contact
When an agent starts with Keel:
- Call
keel_status. - If
authenticatedis false, callkeel_auth_login. - Read
workflow_routesfromkeel_statusbefore choosing lower-level tools. - For strategy creation or substantial edits, load the
strategy-creationprompt before composing source. - Search components with
keel_components_search. - Fetch exact component schemas with
keel_components_detail_batch. - Compose or validate DSL with
keel_strategy_compose. - Run evidence with
keel_backtest_run. - If the run is still active, watch it with
keel_backtest_watch. - Summarize evidence with
keel_backtest_summarize. - Share only when the user explicitly asks, via
keel_share_create.
Do not invent Keel commands. If unsure, call keel_help, inspect tools/list,
or run keel --help.
Authentication
Preferred agent path:
keel_status -> keel_auth_login -> retry original tool
keel_auth_login opens the OAuth browser flow, captures the loopback redirect,
and stores credentials in ~/.keel/config.yaml. The CLI uses the same state:
keel auth login
Headless environments can use:
keel auth login --key <token>
Live-trading consent is requested explicitly:
keel_auth_login(scope="live")
or:
keel auth login --scope live
Recommended Strategy Workflow
Use prompts for workflow, resources for context, tools for actions, and URLs for human handoff.
strategy-creation prompt
keel_components_search(keyword="momentum")
keel_components_detail_batch(names=["ROC", "ForecastScaler", "..."])
keel_strategy_compose(source_file="strategy.py", dry_run=true)
keel_strategy_compose(source_file="strategy.py", name="momentum-baseline")
keel_backtest_run(strategy_id="str_...", start_date="2025-01-01")
keel_backtest_watch(backtest_id="bt_...")
keel_backtest_summarize(backtest_id="bt_...")
CLI equivalents:
keel components search momentum --format json
keel components describe-batch ROC ForecastScaler --format json
keel strategy compose --source-file strategy.py --dry-run --format json
keel strategy compose --source-file strategy.py --name momentum-baseline --format json
keel backtest run str_abc123 --start-date 2025-01-01 --format json
keel backtest watch bt_abc123 --format json
keel backtest summarize bt_abc123 --format json
For checked-out local strategy work:
keel project init
keel strategy checkout str_abc123
keel strategy status str_abc123
keel strategy push str_abc123 -m "describe the change"
keel backtest run str_abc123 --auto-push --start-date 2025-01-01
keel strategy log str_abc123
keel strategy restore str_abc123 --ref 3
Backtests run server-side strategy versions. If local edits are ahead of the
server, push first or use --auto-push intentionally.
end_date / --end-date is optional and defaults to today's UTC date.
Current MCP Tools
MCP tools are callable by canonical keel_* names. KEEL_TOOLSETS filters the
MCP surface only; the CLI command tree is generated independently.
For the exact generated schema/annotation/CLI mapping, see
packages/keel-trade/docs/tool-reference.md.
Always loaded:
keel_statuskeel_auth_loginkeel_doctorkeel_help
Read-only:
keel_accounts_listkeel_audit_list_lastkeel_components_searchkeel_components_compose_help(single known component schema/detail)keel_components_detail_batch(several component schemas before composing)keel_strategy_getkeel_strategy_searchkeel_strategy_diffkeel_strategy_logkeel_strategy_memory_readkeel_strategy_workspaces
Research and backtest:
keel_strategy_composekeel_strategy_checkoutkeel_strategy_deletekeel_strategy_discardkeel_strategy_forkkeel_strategy_memory_writekeel_strategy_pullkeel_strategy_pushkeel_strategy_restorekeel_strategy_statuskeel_backtest_runkeel_backtest_watchkeel_backtest_summarize
Sharing:
keel_share_create
Live read, loaded by default:
keel_live_monitor
Live write, loaded only when KEEL_TOOLSETS includes live-write:
keel_live_deploykeel_live_control
Default MCP toolsets are always,read-only,backtest,share,live-read. Opt into
live write tools only when the user is explicitly working on live deployment or
control:
export KEEL_TOOLSETS=read-only,backtest,share,live-read,live-write
KEEL_TOOLSETS=live remains a deprecated compatibility alias for
live-read,live-write; new configs should use the explicit split.
MCP Prompts
These prompts are bundled as MCP prompts under the keel-skill tag and are also
used as workflow guidance in other Keel agent contexts:
strategy-creationstrategy-fork-and-iteratebacktest-and-analyzeoverfit-checkdeploy-and-monitorportfolio-reviewcomponent-discoveryrecover-from-error
Use strategy-creation before a first keel_strategy_compose call in a session.
Use backtest-and-analyze before interpreting backtest results. Use
recover-from-error when a tool repeatedly fails.
MCP Resources
Use resources for read-only context that should not be recomputed through tool calls:
keel://components/catalogkeel://components/{name}/schemakeel://strategy/{strategy_id}/sourcekeel://strategy/{strategy_id}/lockfilekeel://backtest/{backtest_id}/resultskeel://backtest/latestkeel://strategy/{strategy_id}/backtest/latestkeel://dsl/reference/{topic}keel://knowledge/{section}keel://context/userkeel://context/projectkeel://context/strategy/{strategy_id}
Live Trading Safety
Live trading is opt-in and should be treated as a release gate, not a normal research action.
Required posture:
- Do not deploy unless the user explicitly asks.
- Load
deploy-and-monitor. - Check auth, scopes, accounts, and entitlements with
keel_statusandkeel_accounts_list. - Run
keel_live_deploywith preview enabled first. - Show the preview to the user and ask for explicit confirmation.
- Actual deploy requires the preview
confirmation_token, live OAuth scope, and local account arming. - Monitor immediately with
keel_live_monitor.
keel_live_monitor returns a freshness block. Read it before summarizing
live data: view="positions" is an on-demand Hyperliquid snapshot, while
portfolio/history views come from Keel backend records and can lag the live
dashboard stream.
CLI arming is local-machine authorization:
keel arm live set --account acct_...
Local arming is not a sizing or risk cap. It means this machine is allowed to perform live actions for that account until expiry.
Preview returns planning information plus a short-lived local
confirmation_token. Actual deploy must pass that token with the same
strategy, account, and schedule; host confirmation, live OAuth scope, and local
arming still apply.
CLI Contract
All outcome commands support:
--format json|table|tsv|human
Agents should prefer --format json. Human progress should not be parsed from
stdout; parse stable JSON fields such as hero_url, resource_uri,
share_url, summary_metrics, backtest_id, and strategy_id.
Agent mode is enabled by KEEL_AGENT_MODE=true, common agent environment
variables, or non-TTY stdout. KEEL_AGENT_MODE=false forces human defaults and
is the script/CI opt-out.
Destructive CLI commands require --yes in agent mode. Agents should add it
only after the user has confirmed the action. If omitted, the CLI returns a
structured cli_confirmation_required error explaining what to ask the user.
Current CLI Shape
Outcome-backed CLI commands use the same nouns as MCP tools:
keel status
keel doctor
keel help <topic>
keel components search <keyword>
keel components compose-help <name>
keel components describe-batch <name1> <name2>
keel strategy search
keel strategy get <strategy_id>
keel strategy compose
keel strategy checkout <strategy_id>
keel strategy status <strategy_id>
keel strategy push <strategy_id> -m "message"
keel strategy pull <strategy_id>
keel strategy log <strategy_id>
keel strategy restore <strategy_id> --ref <ref>
keel backtest run <strategy_id> --start-date YYYY-MM-DD [--end-date YYYY-MM-DD]
keel backtest watch <backtest_id>
keel backtest summarize <backtest_id>
keel share create <target_id> --yes
keel accounts list
keel live deploy <strategy_id> --account-id <account_id>
keel live deploy <strategy_id> --account-id <account_id> \
--no-preview --confirmation-token <token> --yes
keel live monitor <deployment_id>
keel live control <deployment_id> --action pause|resume|stop|trigger --yes
keel audit list-last
CLI-only operational commands include:
keel auth login
keel auth status
keel auth whoami
keel auth logout
keel mcp serve
keel project init
keel context show --layer user|project
keel arm live set --account <account_id>
keel arm status
keel arm disarm
What Not To Do
- Do not use the removed meta-tool pattern from older docs. Current MCP tools
are direct
keel_*tools. - Do not use old commands that are absent from
keel --helpand the current CLI shape above. - Do not claim backtest results without a
keel_backtest_runresult orkeel_backtest_summarizeevidence. - Do not create public share links unless the user asks.
- Do not live deploy, pause, resume, stop, or trigger without explicit user confirmation.
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 keel_trade-0.5.0.tar.gz.
File metadata
- Download URL: keel_trade-0.5.0.tar.gz
- Upload date:
- Size: 442.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d9aa8dee34cefcd9745b99597a46a5a2e7fefb5ea11f7fa651f540af6834505
|
|
| MD5 |
09771d79ca84d6614f4143f5b4c33789
|
|
| BLAKE2b-256 |
49647210cf9d91de80c3cc22e09843eaa973bc154466bf348798e2ce59a12faf
|
Provenance
The following attestation bundles were made for keel_trade-0.5.0.tar.gz:
Publisher:
sdk-release.yml on zachferland/Keel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keel_trade-0.5.0.tar.gz -
Subject digest:
5d9aa8dee34cefcd9745b99597a46a5a2e7fefb5ea11f7fa651f540af6834505 - Sigstore transparency entry: 1631416654
- Sigstore integration time:
-
Permalink:
zachferland/Keel@8e593f906cd7926808d27654d16b25d1f014088f -
Branch / Tag:
refs/tags/sdk-v0.5.0 - Owner: https://github.com/zachferland
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@8e593f906cd7926808d27654d16b25d1f014088f -
Trigger Event:
push
-
Statement type:
File details
Details for the file keel_trade-0.5.0-py3-none-any.whl.
File metadata
- Download URL: keel_trade-0.5.0-py3-none-any.whl
- Upload date:
- Size: 439.4 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 |
9493b8459f79cd98bfa8d6cb731cda4d90f57a8aaff6fcd9fd4bdfcf6401c5a6
|
|
| MD5 |
c5c7ebbf1ed8f8cd4e7b8a70a90c6125
|
|
| BLAKE2b-256 |
e77ddd401b86235e2c4af323f320cc8fdcbe8fa8cf254d1120a13064cda207b2
|
Provenance
The following attestation bundles were made for keel_trade-0.5.0-py3-none-any.whl:
Publisher:
sdk-release.yml on zachferland/Keel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keel_trade-0.5.0-py3-none-any.whl -
Subject digest:
9493b8459f79cd98bfa8d6cb731cda4d90f57a8aaff6fcd9fd4bdfcf6401c5a6 - Sigstore transparency entry: 1631416691
- Sigstore integration time:
-
Permalink:
zachferland/Keel@8e593f906cd7926808d27654d16b25d1f014088f -
Branch / Tag:
refs/tags/sdk-v0.5.0 - Owner: https://github.com/zachferland
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@8e593f906cd7926808d27654d16b25d1f014088f -
Trigger Event:
push
-
Statement type: