Reference
CLI reference
Every command, option, and default for the replicate-agent
command-line interface — plus the standalone MCP server executable and the environment
variables both of them read.
The CLI is the operational surface of the framework: it serves agents over MCP, runs
agents and workflows ad hoc, launches distributed workers, and inspects the local audit
log. The package installs two executables. replicate-agent is the full Click-based
CLI documented on this page; replicate-mcp-server is a minimal alias that starts the
stdio MCP server directly, which is convenient as a one-line command in Claude Desktop
or Cursor configuration. Run replicate-agent --version to print the installed version.
| Executable | Entry point | Purpose |
|---|---|---|
replicate-agent |
replicate_mcp.cli.main:app |
Full CLI: serve, doctor, init, status, and the agents, workflows, workers, audit sub-groups. |
replicate-mcp-server |
replicate_mcp.server:serve |
Starts the MCP server on stdio with no arguments — equivalent to replicate-agent serve with the default transport. |
replicate-agent serve
Launches the MCP server with one of three transports: stdio (the default, for
Claude Desktop and Cursor), sse (HTTP Server-Sent Events for cloud-hosted MCP), or
streamable-http (bidirectional HTTP, preferred for MCP 1.x clients). If
REPLICATE_API_TOKEN is missing, the server still starts but warns that tool calls
will fail. See Serve agents over MCP for client wiring.
| Option | Default | Description |
|---|---|---|
--transport | stdio | MCP transport protocol: stdio, sse, or streamable-http. |
--host | 0.0.0.0 | Bind host (HTTP transports only). |
--port | 8080 | TCP port (HTTP transports only). |
--mount-path | none | URL prefix for the SSE transport. |
--log-level | info | Uvicorn log level. |
--workflows-file | none | Path to a YAML workflow definition file loaded at startup (must exist). |
replicate-agent serve --transport sse --workflows-file workflows.yaml
replicate-agent doctor
Runs seven diagnostic checks and prints a pass/fail report: API token presence and
format, Python version (3.10+), importability of the nine core dependencies, Replicate
API connectivity (a 5-second GET /v1/models probe), writability of
~/.replicate, audit log status, and persisted router state. The API check is skipped
(not failed) when no token is set, and a missing audit log or router state counts as a
pass — both are normal on first run. doctor always exits 0; it is a diagnostic
reporter, not a gatekeeper, so read the output rather than relying on the exit code.
replicate-agent doctor
replicate-agent init
Creates a default MCP configuration at ~/.replicate/mcp.yaml (transport
stdio, log level INFO, max_concurrency: 8) if it does not already exist,
then reports whether an API token is detected. Re-running it never overwrites an
existing file.
replicate-agent init
# ✓ Created /home/you/.replicate/mcp.yaml
# ✓ API token detected: r8_x...xxxx
replicate-agent status
Prints the installed version, the masked API token (or a warning if unset), and the number of agents in the server registry. Useful as a quick liveness check after exporting the token.
replicate-agent status
replicate-agent agents
Manage and invoke individual agents. agents list takes no options and prints a
table of registered agents with their model path, streaming support, tags, and estimated
cost. agents run invokes one agent and streams output; its positional
AGENT_ID can be a short name or a full Replicate model path.
agents run option | Default | Description |
|---|---|---|
--input | none | JSON payload string, or a path to a JSON file. |
--model | none | Override the registered Replicate model path with any model. |
--stream / --no-stream | --stream | Enable or disable streaming output. |
--json | off | Print raw JSON chunks for piping instead of formatted panels. |
--timeout | 120.0 | Maximum seconds to wait for a response; exits 1 on timeout. |
--dry-run | off | Validate input and estimate cost/latency from the router's EMA data without calling the API. |
replicate-agent agents run llama3_chat --input '{"prompt": "Hello!"}'
replicate-agent agents run my_agent --model meta/llama-3-70b --json
replicate-agent agents run llama3_chat --dry-run --input '{"prompt": "test"}'
replicate-agent workflows
Manage multi-step workflows registered through the SDK. workflows list shows
each registered workflow's name, step count, agent chain, and description.
workflows run NAME executes a registered workflow step by step, feeding each
step's output into the next (with input_map remapping applied), and exits 1 if the
workflow is not registered or the token is missing. Workflows come from
register_workflow() in your code or a --workflows-file passed to serve.
workflows run option | Default | Description |
|---|---|---|
--input | none | JSON payload string, or a path to a JSON file. |
--json | off | Output the raw per-step chunk lists as JSON. |
--timeout | 300.0 | Maximum seconds per step (not per workflow). |
--checkpoint-dir | none | Directory where a checkpoint file is written atomically after each step. |
--resume-from | none | 0-based step index to resume from; earlier steps are skipped. |
replicate-agent workflows run research --input '{"query": "MCP protocol"}'
replicate-agent workflows run research --checkpoint-dir ./ckpt --resume-from 2
replicate-agent workers
Manage distributed worker nodes. workers start launches an HTTP worker that
exposes POST /execute, GET /health, and GET /metrics; it refuses to start
without REPLICATE_API_TOKEN. workers ping URL health-checks a remote worker
(for example http://host:7999) and prints its active-task and total-processed
counters, exiting 1 if unreachable. Coordinators connect with
RemoteWorkerNode plus HttpWorkerTransport — see
Scale out with worker nodes.
workers start option | Default | Description |
|---|---|---|
--host | 0.0.0.0 | Bind host. |
--port | 7999 | TCP port. |
--node-id | auto | Human-readable node identifier shown in results and health responses. |
--concurrency | 8 | Maximum parallel tasks on this worker. |
--log-level | info | Uvicorn log level. |
# On the worker machine
export REPLICATE_API_TOKEN=r8_...
replicate-agent workers start --port 7999 --node-id gpu-node-1
# From the coordinator
replicate-agent workers ping http://gpu-node-1:7999
replicate-agent audit
Inspect the local invocation audit log and cost dashboard. Records accumulate automatically once agents are invoked; every subcommand prints a friendly notice when the log does not exist yet.
| Subcommand | Options | Description |
|---|---|---|
audit tail |
--n (default 20), --agent |
Show the most recent invocation records — timestamp, agent, model, latency, cost, status, session — optionally filtered to one agent. |
audit costs |
--period today|week|month|all (default today) |
Spend breakdown by model with call counts, success rate, and a totals row. |
audit stats |
optional AGENT_NAME, --period (default all) |
Per-agent latency percentiles (p50/p95/p99), averages, and success rates. |
audit clear |
interactive confirmation | Delete the audit log file. Prompts before deleting; this cannot be undone. |
replicate-agent audit costs --period today
Environment variables
The CLI itself only needs the Replicate token; the other variables configure optional subsystems that the CLI starts for you.
| Variable | Used by | Description |
|---|---|---|
REPLICATE_API_TOKEN |
All model calls | Read by SecretManager and AgentExecutor. Required for agents run, workflows run, and workers start; serve starts with a warning if it is missing. |
OTEL_EXPORTER_OTLP_ENDPOINT |
Observability | OTLP collector endpoint for traces and metrics; defaults to http://localhost:4317 when unset. Requires the [otel] extra. |
LATITUDE_API_KEY |
Latitude integration | API key for LatitudeConfig; required to enable prompt management, tracing, and evaluations via the [latitude] extra. |
LATITUDE_PROJECT_SLUG |
Latitude integration | Default Latitude project slug (preferred). The legacy numeric LATITUDE_PROJECT_ID is also honoured. |
Next steps
- Serve agents over MCP — wire
serveinto Claude Desktop, Cursor, or a cloud host. - Python API reference — the classes and defaults behind every command on this page.
- Troubleshooting — what to do when
doctoris red or calls start failing.