# Codex
> Setting up, authenticating, and running MCP servers in Codex with Ivar.
Source: https://ivar.run/docs/guide/mcp/providers/codex

import { Callout } from 'fumadocs-ui/components/callout';

Codex connects to MCP servers declared in `ivar.json` through the `[mcp_servers.<name>]` tables of `.codex/config.toml` at the hall root. Codex runs its own OAuth login for every server.

## Configuration & naming

`ivar` transforms canonical server names from `ivar.json` (`figma`, `linear`) into hall-qualified identifiers (`<hall>-<server>`) in `.codex/config.toml`.

- **Provider config path:** `.codex/config.toml` (hall root)
- **Canonical vs. qualified names:** Declared as `figma` and `linear` in `ivar.json`; mapped to `acme-figma` and `acme-linear` in `.codex/config.toml` (for a hall named `acme`).
- **Configuration schema:** A remote server is a `url` alone; Codex infers the streamable-HTTP transport. A local server is `command`, `args` and an `env` table. There is no `type` key.
- **Ownership:** `ivar` owns only the tables it marks with a `# managed by ivar (hall: <hall>)` comment. Your own servers and keys survive every sync. A server of yours under a name `ivar` would write is refused, never overwritten.

### Generated `.codex/config.toml`

```toml title=".codex/config.toml"
# managed by ivar (hall: acme)
[mcp_servers.acme-linear]
url = "https://mcp.linear.app/mcp"

# managed by ivar (hall: acme)
[mcp_servers.acme-figma]
url = "https://mcp.figma.com/mcp"
```

<Callout title="Trust the hall first">
  Codex loads a project's `.codex/config.toml` only when it trusts the project, so none of these servers load until you run `codex` in the hall once and trust the folder. See [the Codex provider](/docs/providers/codex).
</Callout>

## Authentication

```text
  > Log Figma and Linear in for Codex.
  ● Bash(ivar mcp auth figma --provider codex)
  ● Bash(ivar mcp auth linear --provider codex)
  ● Codex runs the login for both. Approve each one in the browser, then I'll check them.
  ● Bash(ivar mcp status --provider codex --live)
```

`ivar mcp auth <server> --provider codex` runs `codex mcp login <hall>-<server>`, and Codex runs the OAuth handshake itself, with dynamic client registration. `ivar` never runs its own login flow for Codex, whichever server it is:

**Run it by hand:**

```sh
# Through `ivar` (canonical name)
ivar mcp auth linear --provider codex

# Direct Codex command (hall-qualified name)
codex mcp login acme-linear
```



Codex keeps the tokens in its own store, the OS keyring or `$CODEX_HOME/.credentials.json`, in a layout `ivar` does not write.

### Authenticate all providers

To authenticate all configured providers for a server at once:

**Run it by hand:**

```sh
ivar mcp auth linear --all-providers
```



### Status inspection

`ivar mcp status` cannot read Codex's tokens from a file. With `--live`, it asks Codex through `codex mcp list --json`, which reports an `auth_status` per server:

**Run it by hand:**

```bash
ivar mcp status linear --provider codex --live
```



## OAuth ownership & credentials

| Aspect | Remote servers |
| --- | --- |
| **OAuth ownership** | Codex (`codex mcp login`) |
| **Preregistration by Ivar** | None |
| **Credential storage** | Codex's own store (OS keyring or `$CODEX_HOME/.credentials.json`) |
| **Status probe** | `codex mcp list --json` (`ivar mcp status --live`) |

## Related

- [Linear integration guide](/docs/guide/mcp/integrations/linear)
- [Figma integration guide](/docs/guide/mcp/integrations/figma)
- [MCP OAuth overview](/docs/guide/mcp/oauth)
- [MCP reference & schema](/docs/reference/mcp)
