> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agent.golf/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Commands

> The commands, arguments, flags, environment variables, and exit codes of the agentgolf CLI that customers use.

The `agentgolf` commands that customers use, with their arguments, flags, and exit codes. Add `--help` to any command for the same detail, for example `agentgolf harness setup --help`. `agentgolf attribution --help` also lists diagnostic commands for Agent Golf support, which this page does not describe.

| Command | Purpose |
| - | - |
| [`agentgolf login`](#agentgolf-login) | Sign in and save the login. |
| [`agentgolf logout`](#agentgolf-logout) | Remove the saved login. |
| [`agentgolf harness setup`](#agentgolf-harness-setup) | Create a personal publishing key and write the harness settings. |
| [`agentgolf harness managed-settings`](#agentgolf-harness-managed-settings) | Print the managed settings of a harness for a team rollout. |
| [`agentgolf otel-headers`](#agentgolf-otel-headers) | Give Claude Code its publishing key from the system keychain. |
| [`agentgolf attribute`](#agentgolf-attribute) | Link one of your sessions to one GitHub pull request. |
| [`agentgolf attribution audit`](#agentgolf-attribution-audit) | Compare automatic links with manual links and pull-request authors. |
| [`agentgolf mcp`](#agentgolf-mcp) | Run a read-only MCP server for an AI tool on this machine. |

| Global flag | Result |
| - | - |
| `-h`, `--help` | Show the help of the command. |
| `-V`, `--version` | Show the version: `agentgolf <version>`. |

Workspace commands use the workspace that you selected when you logged in. `harness setup --organization` creates a key in the organization of that workspace. `logout`, `otel-headers`, and `harness managed-settings` with `--endpoint` do not use a workspace. Each command section lists only its own exit codes. For the meaning of each code, and the codes that every command can return, see [Exit codes](#exit-codes).

## `agentgolf login`

```bash theme={null}
agentgolf login
```

Signs in with device authorization and saves the login for the API address that the CLI uses. It has no arguments or flags. See [Log In](https://docs.agent.golf/cli/login.md).

Exit codes: `1` when you deny the sign-in or the credential store fails. `4` when the code expires.

## `agentgolf logout`

```bash theme={null}
agentgolf logout
```

Removes the saved login for the API address that the CLI uses. It has no arguments or flags.

Exit code `0` even when no login was saved. The CLI shows `Logged out.` in both cases.

## `agentgolf harness setup`

```bash theme={null}
agentgolf harness setup (<harness> | --all) [--endpoint <url>] [--allow-insecure-endpoint] [--organization] [--name <name>] [--replace] [--print]
```

Connects one harness on this machine to an uplink instance. With `--all`, it connects each harness that it finds on this machine. Give exactly one of `<harness>` and `--all`. The command:

1. Signs you in when you are not logged in.
2. With `--organization`, finds the organization of your workspace. It stops when the workspace has no organization, or when you cannot create a publishing key without a workspace.
3. Without `--endpoint`, reads the endpoint of your workspace's Cloud Uplink instance. It stops when Cloud Uplink is not on. With `--organization`, it also stops when your organization runs no Cloud Uplink instance.
4. Reads the harness settings file. With `--all`, it reads the file of each harness that it found before it creates a key. When a setting already has another value, the command stops, names the setting, and creates no key. With `--all`, it skips only that harness. See [All harnesses on the machine](#all-harnesses-on-the-machine). For `claude-code`, it also opens the system keychain.
5. Creates a personal publishing key for each harness that it sets up. This needs the **Connect Your Harness** permission. With `--organization`, the key has no workspace.
6. Writes the harness settings: the endpoint, the key in the `x-agentgolf-publishing-key` header, and every content setting on. The **Harness Setup** card on **Settings > Uplink > Publishing Keys** shows the same settings. For `claude-code`, the command saves the key in the system keychain and writes a helper command in place of the header. See [Claude Code and the system keychain](#claude-code-and-the-system-keychain).

| Argument | Settings that the command writes |
| - | - |
| `claude-code` | The `env` block and `otelHeadersHelper` of `$CLAUDE_CONFIG_DIR/settings.json`, or of `~/.claude/settings.json`. The publishing key goes to the system keychain, not to the file. See [Claude Code and the system keychain](#claude-code-and-the-system-keychain) and [Claude Code](https://docs.agent.golf/harnesses/claude-code.md). |
| `codex` | `otel.log_user_prompt`, `otel.metrics_exporter`, `otel.exporter`, and `otel.trace_exporter` of `$CODEX_HOME/config.toml`, or of `~/.codex/config.toml`. See [Codex](https://docs.agent.golf/harnesses/codex.md). |
| `omp` | No file. omp reads only environment variables, so the command prints the `export` lines. They hold your publishing key, so load them only in the shell that starts omp. See [omp](https://docs.agent.golf/harnesses/omp.md#keep-the-key-out-of-shared-shells). |
| `copilot` | The header file `agentgolf-otlp-headers.json`, and `telemetry.headersProvider` and `telemetry.captureContent` of `settings.json`, both in `$COPILOT_HOME`, or in `~/.copilot`. The command also prints the `export` lines that Copilot needs. They hold no key. Add them to the profile of the shell that starts Copilot. See [GitHub Copilot](https://docs.agent.golf/harnesses/copilot.md). |

| Flag | Result |
| - | - |
| `--all` | Set up each Claude Code, Codex, and GitHub Copilot harness on this machine. See [All harnesses on the machine](#all-harnesses-on-the-machine). You cannot use it with `<harness>`, `--name`, or `--print`. `agentgolf` 0.1.10 added it. |
| `--endpoint <url>` | Use the OTLP listener of a Self-Hosted Uplink instance, for example `http://127.0.0.1:4318`. Give the base URL without `/v1/<signal>`. The URL uses `http` or `https`, and has no user name, password, query, or fragment. Without this flag, the command uses Cloud Uplink. |
| `--allow-insecure-endpoint` | Accept an `http` endpoint on a host that is not loopback. The key then crosses the network in plain text. Without this flag, the command refuses such an endpoint and creates no key. Needs `--endpoint`. |
| `--organization` | Create a publishing key without a workspace in the organization of your workspace. See [Keys without a workspace](#keys-without-a-workspace). Needs `agentgolf` 0.1.9 or later. |
| `--name <name>` | The name of the key. The default is the device name and the harness, for example `Grace's laptop (Claude Code)`. |
| `--replace` | Change the settings that already have other values. |
| `--print` | Print the settings and write no file. The output includes the secret of the key. For `claude-code`, the output has the key in `OTEL_EXPORTER_OTLP_HEADERS`, and the command does not use the system keychain. |

* The command keeps the file's other settings, their order, and the TOML comments. When the file is a symbolic link with an existing target, the command updates the target. When the target does not exist, the command replaces the link with a file. The file gets mode `0600`, because it can hold the key.
* A file that a run of this command wrote already holds a key, so a second run for one harness needs `--replace`. After `--replace`, the earlier key stays valid. Revoke it in **Settings > Uplink > Publishing Keys**. For `claude-code`, the key in the system keychain counts in the same way. See [Claude Code and the system keychain](#claude-code-and-the-system-keychain).
* For `copilot`, an existing `telemetry.headersProvider` always counts as another value. The header file also gets mode `0600`.
* Copilot accepts comments and trailing commas in `settings.json`. The command reads only strict JSON, and refuses such a file. Remove them, or change a setting with `copilot config`: Copilot then writes the file again without them.
* A running harness reads its settings only when it starts. Restart the harness after the command.
* A Self-Hosted Uplink instance needs Uplink 0.1.22 or later to link sessions to the owner of the key.

### Claude Code and the system keychain

For `claude-code`, the command saves the publishing key in the system keychain: the macOS Keychain, or on Linux the Secret Service, for example GNOME Keyring or KWallet. The entry has the service `agentgolf` and the user `<environment>/claude-code/publishing-key`, for example `prod/claude-code/publishing-key` for `https://api.agent.golf`. Each environment has one entry, so all Claude Code settings files of one environment use the same key, for example the files of two `CLAUDE_CONFIG_DIR` profiles. Claude Code then gets the key from [`agentgolf otel-headers`](#agentgolf-otel-headers) through its [`otelHeadersHelper`](https://code.claude.com/docs/en/settings-reference#otelheadershelper) setting. `agentgolf` 0.1.11 added the system keychain. Codex and GitHub Copilot keep the key in their files, and omp gets it from the `export` lines.

* The command writes the `env` block without `OTEL_EXPORTER_OTLP_HEADERS`, and adds `"otelHeadersHelper": "agentgolf otel-headers"`. For an API other than production, the value is `agentgolf otel-headers --environment <env>`. The key never goes to `settings.json`.
* When `settings.json` has an `OTEL_EXPORTER_OTLP_HEADERS` with another header, the command keeps that header and removes only the `x-agentgolf-publishing-key` entry.
* Claude Code must find `agentgolf` on its `PATH`. The output of the command says this too. If Claude Code does not find it, replace the value with the full path of the binary, for example the output of `command -v agentgolf`. A value with the full path, for example `/opt/homebrew/bin/agentgolf otel-headers`, counts as the Agent Golf helper, and the command keeps it.
* Claude Code runs the helper when it starts and every 29 minutes. When the helper fails, Claude Code exports nothing, and `/status` shows the error. See [Dynamic headers](https://code.claude.com/docs/en/monitoring-usage#dynamic-headers).
* **A key that the system keychain already holds.** When a run would replace the stored key, for example the setup of another settings file of the same environment, the command stops and creates no key. The message says that another Claude Code settings file can use the stored key. With `--all`, the command skips Claude Code and names the `--replace` command. With `--replace`, the command creates a new key, and each Claude Code settings file of the environment then uses it. The earlier key stays valid. Revoke it in **Settings > Uplink > Publishing Keys**.
* **Move from an earlier release.** An earlier CLI wrote the key to `OTEL_EXPORTER_OTLP_HEADERS` in `settings.json`. Run the command again with the same endpoint, and without `--replace`, `--organization`, and `--name`. The command moves the key to the system keychain, rewrites the file, and creates no key. The output starts with `Moved the publishing key from <path> to the system keychain. No key was created.` `--all` moves the key in the same way.
  * When the system keychain already holds another key for the environment, the command stops as above.
  * In the other cases, the earlier header is a setting with another value, so the command needs `--replace`. With `--replace`, the command creates a new key, and the earlier key stays valid.
* **A second run.** When the file has the helper and the endpoint of the run, and the system keychain has the key, a second run without `--replace` stops and creates no key. `--all` shows `Already set up`. When the file has the helper but the system keychain has no key, the command creates a key without `--replace`.
* **A device without a system keychain**, for example a Linux server without a Secret Service. `agentgolf harness setup claude-code` stops with exit code `1` before it creates a key. `--all` skips Claude Code with one line, and sets up the other harnesses. The CLI never saves the key in a plain file by itself. To set up such a device, run `agentgolf harness setup claude-code --print`, and put the printed settings where you choose. They hold the key in `OTEL_EXPORTER_OTLP_HEADERS`.

### All harnesses on the machine

With `--all`, the command sets up each Claude Code, Codex, and GitHub Copilot harness that it finds on this machine. It signs you in once, and reads the endpoint once.

| Harness | The command finds it when |
| - | - |
| Claude Code | `$CLAUDE_CONFIG_DIR` or `~/.claude` exists, or `claude` is on `PATH`. |
| Codex | `$CODEX_HOME` or `~/.codex` exists, or `codex` is on `PATH`. |
| GitHub Copilot | `$COPILOT_HOME` or `~/.copilot` exists, or `copilot` is on `PATH`. |

* `--all` does not include omp, because omp has no settings file. Run `agentgolf harness setup omp` for it.
* The command creates one personal publishing key for each harness that it sets up. Each key has the default name, for example `Grace's laptop (Codex)`.
* When the file of a harness already holds the Agent Golf settings with a publishing key, the command creates no key for it and writes nothing. The output shows `Already set up: <Harness> (<path>). No key was created for it.` For Claude Code and Codex, this needs the same endpoint as the run. For Claude Code, the system keychain must also hold the key. Copilot settings hold no endpoint, so for Copilot it means only that the publishing-key file and the provider exist. After the line, the command prints the Copilot `export` lines. They always show the endpoint of the run.
* With `--organization`, each `Already set up` line also names the command `agentgolf harness setup <harness> --replace --organization`, because the file cannot show the scope of the earlier key. `--all` never changes the scope of an existing key by itself.
* When the file of a harness has another value for a setting, the command skips that harness: it creates no key for it and writes nothing. The output names the file, the values, and the command `agentgolf harness setup <harness> --replace`. That command also has `--endpoint`, `--allow-insecure-endpoint`, and `--organization` when your run had them. The command continues with the other harnesses.
* So a second run with the same flags changes nothing and exits with `0`.
* The output shows the summary of each harness that the command set up, then one line for each harness that is already set up or that it skipped. For Copilot, the summary also has the `export` lines.
* When the setup of a harness fails, the command stops with the error. Before the error, it writes to stderr the summary of each harness that it already set up, and the line of each harness that it skipped. Each harness that it set up keeps its key and settings, and a new run without `--replace` can show it as already set up. A skipped harness is not set up.
* When the command finds no harness, it stops with exit code `3` and creates no key. Give the harness name in place of `--all`.

### Keys without a workspace

With `--organization`, the command creates a personal publishing key without a workspace in the organization of your workspace. One such key works for all workspaces of the organization. Its sessions belong to the organization, and each workspace sees them through the organization session permissions.

* The key works only on the uplink instances of the organization: the Cloud Uplink instance of the organization, and the Self-Hosted Uplink instances of the organization (**Organization Settings > Uplink > Self-Hosted**). It does not work on an uplink instance of a workspace.
* Without `--endpoint`, your organization must run its Cloud Uplink instance. With `--endpoint`, give the endpoint of a Self-Hosted Uplink instance of the organization. The command cannot check that the instance belongs to the organization.
* You need the **Connect Your Harness** permission in a workspace of the organization.
* Without `--name`, the name of the key ends with `organization`, for example `Grace's laptop (Claude Code, organization)`.
* Revoke the key in **Organization Settings > Uplink > Publishing Keys**.

Examples:

```bash theme={null}
# Cloud Uplink, each harness on this machine
agentgolf harness setup --all

# Cloud Uplink, one harness
agentgolf harness setup claude-code

# A Self-Hosted Uplink instance on this machine
agentgolf harness setup codex --endpoint http://127.0.0.1:4318

# A Self-Hosted Uplink instance that serves TLS
agentgolf harness setup omp --endpoint https://uplink.internal:4318

# The Cloud Uplink instance of your organization, with one key for all its workspaces
agentgolf harness setup claude-code --organization

# A Self-Hosted Uplink instance of your organization
agentgolf harness setup codex --endpoint https://uplink.internal:4318 --organization
```

Exit codes:

* `1`: a setting already has another value and you did not give `--replace`, or the settings file cannot be read, parsed, or written. For `claude-code`, also when the system keychain cannot be opened, or already holds a key that the run would replace without `--replace`. With `--all`, a settings conflict or one of these Claude Code keychain cases skips that harness. A file read or parse error stops the run before it creates a key. A write error stops further setup.
* `2`: you give both or none of `<harness>` and `--all`, or you give `--all` with `--name` or `--print`. Also when the `--endpoint` URL is not valid, or it is an `http` URL on a host that is not loopback without `--allow-insecure-endpoint`.
* `3`: your Agent Golf deployment does not offer Cloud Uplink. With `--organization`, also when your workspace has no organization. With `--all`, also when the command finds no harness.
* `5`: Cloud Uplink is off for your workspace, or you do not have **Connect Your Harness**. With `--organization`, also when your organization runs no Cloud Uplink instance, or your Agent Golf deployment does not offer keys without a workspace.

## `agentgolf harness managed-settings`

```bash theme={null}
agentgolf harness managed-settings <claude-code|codex|copilot> [--endpoint <url>] [--allow-insecure-endpoint] [--otel-headers-helper]
```

Prints the managed settings document of one harness, for an admin who rolls out the settings to a team. `agentgolf` 0.1.10 added this command. The document holds the endpoint and the content settings. It holds no publishing key, and the command creates no key. Each developer then runs `agentgolf harness setup --all` to add their personal publishing key. When you gave `--endpoint`, each developer gives the same URL: `agentgolf harness setup --all --endpoint <url>`. See [Roll out to a team](https://docs.agent.golf/harnesses/overview.md#roll-out-to-a-team).

* The command writes only the document to stdout, so you can redirect it to a file. It writes one note to stderr that names where to install the file.
* Without `--endpoint`, the command signs you in when you are not logged in, and reads the endpoint of your workspace's Cloud Uplink instance. Cloud Uplink must be on.
* With `--endpoint`, the command does not sign in and does not call the API. It checks the URL with the same rules as `agentgolf harness setup`.
* The command does not accept `omp`, because omp has no settings file.
* With `--otel-headers-helper`, the Claude Code document also names the helper `agentgolf otel-headers`, with `--environment <env>` for an API other than production. When you merge the `env` block into `managed-settings.json`, merge `otelHeadersHelper` too. A managed `otelHeadersHelper` wins over the value of each user. See [Settings precedence](https://code.claude.com/docs/en/settings#settings-precedence). Each developer still runs `agentgolf harness setup claude-code`, which saves their personal publishing key in the system keychain, and needs `agentgolf` on the `PATH` of Claude Code. The command does not accept the flag for `codex` or `copilot`.
* Install the managed helper only after each developer ran `agentgolf harness setup claude-code` with a release that saves the key in the system keychain, 0.1.11 or later. A helper that fails stops all exports of the device, also on a device that still has the static header of an earlier release.

| Argument | Document | Install it as |
| - | - | - |
| `claude-code` | An `env` block with each variable that `harness setup` writes, except `OTEL_EXPORTER_OTLP_HEADERS`. | `/etc/claude-code/managed-settings.d/agentgolf.json` on Linux, or `/Library/Application Support/ClaudeCode/managed-settings.d/agentgolf.json` on macOS. Or merge the `env` block into `managed-settings.json`. See [Claude Code](https://docs.agent.golf/harnesses/claude-code.md#team-rollout). |
| `codex` | The `[otel]` tables that `harness setup` writes, without `headers`. | `/etc/codex/config.toml`, or the MDM value `config_toml_base64`. Never `requirements.toml`. See [Codex](https://docs.agent.golf/harnesses/codex.md#team-rollout). |
| `copilot` | A `telemetry` object with `enabled`, `endpoint`, `protocol`, `captureContent`, and `serviceName`, without `headers` and `headersProvider`. | `/etc/github-copilot/managed-settings.json` on Linux, `/Library/Application Support/GitHubCopilot/managed-settings.json` on macOS, or the `telemetry` object of the server-managed settings. See [GitHub Copilot](https://docs.agent.golf/harnesses/copilot.md#team-rollout). |

| Flag | Result |
| - | - |
| `--endpoint <url>` | Use the OTLP listener of a Self-Hosted Uplink instance. The same value as for [`agentgolf harness setup`](#agentgolf-harness-setup). |
| `--allow-insecure-endpoint` | Accept an `http` endpoint on a host that is not loopback. Each harness then sends its user's key in plain text. Needs `--endpoint`. |
| `--otel-headers-helper` | For `claude-code` only: add `otelHeadersHelper` to the document. `agentgolf` 0.1.11 added it. |

Exit codes: `2` when the harness is not `claude-code`, `codex`, or `copilot`, you give `--otel-headers-helper` with `codex` or `copilot`, the `--endpoint` URL is not valid, or it is an `http` URL on a host that is not loopback without `--allow-insecure-endpoint`. Without `--endpoint`, also `3` when your Agent Golf deployment does not offer Cloud Uplink, and `5` when Cloud Uplink is off for your workspace.

## `agentgolf otel-headers`

```bash theme={null}
agentgolf otel-headers [--environment <prod|dev|custom>]
```

Prints the OTLP header with your Claude Code publishing key, for the Claude Code [`otelHeadersHelper`](https://code.claude.com/docs/en/settings-reference#otelheadershelper) setting. `agentgolf harness setup claude-code` writes this setting, and saves the key in the system keychain. Claude Code runs the command when it starts and every 29 minutes. `agentgolf` 0.1.11 added this command. See [Claude Code and the system keychain](#claude-code-and-the-system-keychain).

| Flag | Result |
| - | - |
| `--environment <prod\|dev\|custom>` | The environment of the key. `prod` is `https://api.agent.golf`, and is the default. `dev` is the Agent Golf development API. Each other API address shares `custom`. `agentgolf harness setup claude-code` writes the value from `AGENTGOLF_API_BASE_URL` at setup time. |

* The command reads only the system keychain. It does not read `AGENTGOLF_API_BASE_URL`, does not sign in, and does not call the network.
* On success, stdout has one line: `{"x-agentgolf-publishing-key":"<key>"}`.
* No message on stderr holds the key.

Exit codes: `3` when the system keychain has no key for the environment. Stdout is then empty, and stderr names `agentgolf harness setup claude-code`. For an environment other than `prod`, the message adds that `AGENTGOLF_API_BASE_URL` must name the API of that environment. `1` when the system keychain cannot be read.

## `agentgolf attribute`

```bash theme={null}
agentgolf attribute <session-id> <pull-request-url>
```

Links one of your own sessions to one GitHub pull request, when automatic attribution did not find the link. It has the same result as a manual link in the dashboard. You need the **Attribute Own Sessions** permission. For when to use a manual link, see [Link a session by hand](https://docs.agent.golf/dashboard/attribution.md#link-a-session-by-hand).

| Argument | Value |
| - | - |
| `<session-id>` | The conversation UUID of the session, or the session ID that the harness gave it. |
| `<pull-request-url>` | The full GitHub pull-request URL, for example `https://github.com/acme/widgets/pull/42`. |

On success, the command shows `Associated <conversation-id> with <owner>/<repository>#<number>.` When the link exists already, Agent Golf keeps it and the command succeeds.

Exit codes: `2` when the URL is not a GitHub pull-request URL. `3` when you have no session with this ID, or your workspace has no such pull request. `5` when you do not have **Attribute Own Sessions**.

## `agentgolf attribution`

`agentgolf attribution audit` reads the pull requests of your workspace and their linked sessions.

### `agentgolf attribution audit`

```bash theme={null}
agentgolf attribution audit --since <time> --before <time>
```

Compares the automatic links of each pull request with its manual links and with the author of the pull request. The command reads each pull request that changed from `--since` up to, but not including, `--before`. You need the **View Pull Requests and Repositories** permission.

| Flag | Value |
| - | - |
| `--since <time>` | The start of the window, in UTC, as `YYYYMMDDHHmmss`. |
| `--before <time>` | The end of the window, in UTC, as `YYYYMMDDHHmmss`. |

For example, the pull requests that changed in October 2026:

```bash theme={null}
agentgolf attribution audit --since 20261001000000 --before 20261101000000
```

Exit codes: `1` when the `--before` value is not valid, or it is not later than `--since`. `2` when a flag is missing, or the `--since` value is not valid. `5` when you do not have **View Pull Requests and Repositories**.

## `agentgolf mcp`

```bash theme={null}
agentgolf mcp
```

Runs a read-only Model Context Protocol (MCP) server over standard input and output, for an AI tool on this machine. The AI tool starts the command. The server reads the workspace of your CLI login, with your permissions. It has no arguments or flags, and it needs CLI 0.1.5 or later.

The command serves the AI tools on this machine. It has the tools of the remote Agent Golf MCP server, and also `read_local_session`, which reads local Claude Code, Codex, and GitHub Copilot CLI transcripts. For each tool and the permission that it needs, see [MCP Tools](https://docs.agent.golf/mcp/tools.md). To connect an AI tool without the CLI, for example claude.ai or ChatGPT, use the remote server. See [Connect an AI Tool with MCP](https://docs.agent.golf/mcp/overview.md).

To add the server to an AI tool:

1. Log in with `agentgolf login`.

2. Add the server to the MCP settings of the AI tool. For example, Claude Desktop and Cursor use this form:

   ```json theme={null}
   {
     "mcpServers": {
       "agentgolf": { "command": "agentgolf", "args": ["mcp"] }
     }
   }
   ```

3. Restart the AI tool. It lists the tools of the server.

* A desktop app may not have the `PATH` of your shell. When the AI tool cannot start `agentgolf`, give the full path of the binary, for example the output of `command -v agentgolf`.
* The server starts without a login. A tool that reads Agent Golf then returns an error that names `agentgolf login`. After you log in, the next call works without a restart.
* The token of your login never appears in a tool result.
* `read_local_session` reads only files on this machine. It needs no login and sends nothing to Agent Golf. Its excerpts enter the context of your AI tool. See [`read_local_session`](https://docs.agent.golf/mcp/tools#read_local_session).
* Some tools and transcript formats need a later CLI release. See [Local transcripts](https://docs.agent.golf/mcp/overview.md#local-transcripts) for the versions. Run `agentgolf --version` to see your version.

Exit codes: `0` when the AI tool closes the connection. `1` when the MCP connection does not start, or fails.

## Environment variables

| Variable | Default | Purpose |
| - | - | - |
| `AGENTGOLF_API_BASE_URL` | `https://api.agent.golf` | The address of the Agent Golf API. The URL uses `https`, or `http` for a loopback host, and has no credentials, query, or fragment. CLI 0.1.2 and earlier have another default, so set `https://api.agent.golf` for them. |
| `AGENTGOLF_ACCESS_TOKEN` | Empty | An access token. When it is set, the CLI sends it and does not use or renew the saved login, so the variable stops working when the token expires. See [Sign-in and token lifetimes](https://docs.agent.golf/account/identity.md#sign-in-and-token-lifetimes). |
| `AGENTGOLF_ALLOW_INSECURE_API` | Empty | `true` or `1` accepts an `http` API address on a host that is not loopback, and turns off the check of the TLS certificate. Do not set it for `https://api.agent.golf`. |

`harness setup` also reads `CLAUDE_CONFIG_DIR`, `CODEX_HOME`, `COPILOT_HOME`, and `HOME` to find the settings file. With `--all`, it also reads `PATH` to find each harness. The login uses `XDG_CONFIG_HOME` on Linux. See [Where the CLI keeps the login](https://docs.agent.golf/cli/login.md#where-the-cli-keeps-the-login).

## Output

* The CLI writes the result to stdout. It writes the sign-in instructions, notes, and errors to stderr. `agentgolf mcp` writes only MCP messages to stdout, and `agentgolf otel-headers` writes only the header JSON.
* Each error has the form `error: <message>`.
* Each request to the API stops after 10 seconds.

## Exit codes

| Exit code | Meaning |
| - | - |
| `0` | Success. |
| `1` | A configuration, local, or unexpected API failure, for example an expired login. |
| `2` | An argument or flag is missing or not valid. |
| `3` | The resource does not exist. |
| `4` | The API is not available for a short time. Try again later. |
| `5` | You have no access to the resource. |

Each command can also stop with `1` when your login is not valid or the CLI cannot reach the API, and with `4` when the API answers that it is not available for a short time.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.