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

# Codex

> Connect Codex to the Onyx MCP server with OAuth or a personal access token.

## Add Onyx

```bash theme={null}
codex mcp add onyx --url https://onyx.example.com/mcp/
codex mcp login onyx
```

Sign in and select **Allow access**. In Codex, enter `/mcp` to check that Onyx is connected,
then send the [test prompt](https://docs.onyx.app/overview/onyx_anywhere/mcp_server.md#test-the-connection). The Codex CLI, desktop app,
and IDE extension share this configuration.

### Configure with TOML

Instead of `codex mcp add`, add this to `~/.codex/config.toml`, then run `codex mcp login onyx`:

```toml theme={null}
[mcp_servers.onyx]
url = "https://onyx.example.com/mcp/"
```

Keep only one `[mcp_servers.onyx]` table in the file.

## Personal access token

To use a token instead of OAuth,
export a [personal access token](https://docs.onyx.app/overview/onyx_anywhere/mcp_server.md#use-a-personal-access-token-instead)
as `ONYX_TOKEN` and use this table:

```toml theme={null}
[mcp_servers.onyx]
url = "https://onyx.example.com/mcp/"
bearer_token_env_var = "ONYX_TOKEN"
```

Start `codex` from the shell that exports `ONYX_TOKEN`. A desktop app started separately may not see it.

## Disconnect

```bash theme={null}
codex mcp logout onyx   # sign out
codex mcp remove onyx   # remove the server
```

This does not revoke access.
Revoke it in Onyx under [Connected apps](https://docs.onyx.app/overview/onyx_anywhere/mcp_server.md#manage-connected-apps).


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