Skip to main content
The agentref CLI is a lightweight command-line tool that wraps the AgentRef REST API v1 and MCP server. It is designed for scripting, CI/CD pipelines, and quick account operations from the terminal.
The CLI reuses existing AgentRef surfaces — REST API v1 for account/program operations and MCP for marketplace access. It does not duplicate business logic; all domain logic stays on the server.

Running the CLI

From the AgentRef repository:
Or via npm:

Authentication

The CLI resolves credentials in this order:
  1. --api-key flag (highest priority)
  2. AGENTREF_API_KEY environment variable
  3. ~/.agentref/config.json file

Config File

Store persistent configuration at ~/.agentref/config.json:
~/.agentref/config.json
If no --base-url, AGENTREF_API_BASE_URL, saved config, or NEXT_PUBLIC_APP_URL is present, the local development CLI falls back to http://localhost:3000.
Create API keys in the AgentRef dashboard under Settings > API Keys. Keys are shown only once — store them securely.

Global Options

Every command accepts these flags:

JSON Output

When --json is passed, all commands return a consistent envelope:
This is useful for piping into jq or other automation tools.

Commands

whoami

Display the authenticated user identity.

merchant me

Show full merchant account details.

merchant programs list

List your affiliate programs.

merchant programs create

Create a new affiliate program.
Additional optional flags match the create_program API parameters (cookie duration, payout threshold, etc.).

affiliate me

Show the current affiliate workspace identity.

affiliate overview

Show aggregate affiliate performance across joined programs.

affiliate programs list

List programs joined by the current affiliate account.

affiliate programs get

Load one joined program context.

affiliate marketplace list

Browse the public marketplace catalog.
The --via mcp option routes the request through the MCP endpoint instead of REST, which can be useful for testing MCP connectivity.

Exit Codes

The CLI uses structured exit codes for scripting:

Scripting with Exit Codes

Examples

Quick status check

Create a program from a script

CI/CD integration

.github/workflows/setup-program.yml
For more complex automation workflows, consider using the Node.js SDK or Python SDK instead. The CLI is best for quick operations and shell scripting.