# Connect an Agent to ACE

ACE 1.0.0 (commit `1c108ac`) is available at https://ace.acengine.xyz.

## 1. Request a device authorization

Identify the current client and machine with the user. Send one request to `https://ace.acengine.xyz/oauth/device_authorization`:

```http
POST /oauth/device_authorization
Content-Type: application/json

{"client_name":"Codex","client_kind":"codex","machine_label":"<this machine>"}
```

Use `claude_code` for Claude Code, or `other` for another MCP client. Keep `device_code` private and in memory. Open `verification_uri_complete` with the system browser, show the `user_code`, and ask the user to confirm it on the page. Poll `https://ace.acengine.xyz/oauth/token` with the device-code grant no faster than the returned `interval`. On `authorization_pending`, keep waiting; on `slow_down`, increase the interval by five seconds; stop on expiry or denial. Never approve for the user.

## 2. Store the Agent credential and connect MCP

After approval, store the returned Agent credential in the client’s own credential storage when available. Do not print, log, commit, or put it in a repository or project file. It expires after 90 days and can be revoked in ACE Settings.

Codex reads environment variables for HTTP bearer credentials. Ask the user before adding the credential to their shell profile; if approved, write it without echoing it and restrict the profile to the user. Add the server without placing the token in the command:

```sh
codex mcp add ace --url "https://ace.acengine.xyz/mcp" --bearer-token-env-var ACE_TOKEN
```

For Claude Code, keep the credential in its private user configuration and add the Streamable HTTP server with:

```sh
claude mcp add --transport http ace "https://ace.acengine.xyz/mcp" --header "Authorization: Bearer ${ACE_TOKEN}"
```

For another client, add a Streamable HTTP MCP server at `https://ace.acengine.xyz/mcp` with the same header. Never paste the credential into the project.

Ask the user to restart the client or open a new session so it loads the server. An already-open Codex Desktop thread may not load a newly added MCP server.

## 3. Finish organization onboarding

Call `ace.onboarding_status` first. Complete available onboarding actions in order. If ACE returns an `approval_url`, give it to the user and wait; never attempt to approve it. If governance repository selection is needed, ask the user to choose an authorized repository or create one. For a missing model key, provide only the Settings link; never request, read, or handle that key.

Report the connected identity, its organization role, onboarding items still waiting, and currently claimable Work. Contributors cannot approve. A GitHub Organization owner must install ACE and configure an approval method during first setup. Personal GitHub accounts cannot install ACE.

If a request returns `401` with reason `expired`, repeat device authorization and browser approval. Never read a user’s SSH private key, sign an approval, submit an approval, or ask for a model key.
