# Connect Codex

> Add your site to Codex in the ChatGPT desktop app, the Codex CLI or the Codex IDE extension with one config file entry or one pasted message.

Codex is OpenAI's coding agent. It runs in the ChatGPT desktop app, in the Codex CLI in a terminal and as the Codex IDE extension in your editor. All three share one settings file, so you set up your site once.

## Before you start

Create a connection for Codex. Open **PowerWP AI › Connections**, choose **Create connection**, pick **Codex**, name it and choose what it may do. Choose **Create key and show steps**: the window shows the steps below with your address and key already in them. The key is shown once. Here it appears as `<your key>`.

## Option 1: let Codex connect itself

Copy the message under **Let Codex connect itself** in the setup window and paste it into a chat in Codex. It adds the entry below to `~/.codex/config.toml` for you and tells you the next step. The message contains your key, so paste it only into your own account. Codex may ask you to allow the change.

## Option 2: edit the settings file

The file is `config.toml` in the `.codex` folder of your user folder:

| System | Path |
|---|---|
| macOS and Linux | `~/.codex/config.toml` |
| Windows | `C:\Users\<you>\.codex\config.toml` |

Create the file if it isn't there. Add this table at the end:

```toml
[mcp_servers.your-store]
url = "https://your-store.com/wp-json/wpai/v1/mcp"
http_headers = { "X-WPAI-Token" = "<your key>" }
```

:::steps
1. Open `config.toml` in the `.codex` folder.
2. Add the table at the end of the file and save it. Keep any tables that are already there.
3. Restart the ChatGPT desktop app or the IDE extension, or start `codex` again.
4. Type `/mcp`. Your site is listed.
:::

The file holds your key in plain text, so keep it private and don't copy it into a shared project.

## Check it works

```
Give me an overview of my site.
```

Codex calls `site_overview` and answers with your WordPress version, theme and plugins.

## Troubleshooting

- **ChatGPT on the web does not use your site through this file.** The web version doesn't read it: it connects by [signing in](/docs/connect/chatgpt/). This file is for the Codex of the ChatGPT desktop app, the Codex CLI and the IDE extension.
- **`/mcp` does not list your site.** Restart the app, the extension or the CLI. Most apps read their MCP settings only when they start.
- **401 "Authentication required".** The key was copied incompletely. Keys cannot be shown twice: revoke the connection and create a new one.
- **403 or 429.** 403 means your IP address is not on the connection's allow-list, or a firewall blocks `/wp-json/wpai/v1/`. 429 means too many requests or failed attempts: wait a few minutes.

## Related

:::cards
- [ChatGPT](/docs/connect/chatgpt/) — Sign in from ChatGPT on the web or in its apps.
- [Choose how to connect](/docs/connect/) — All supported apps.
- [Troubleshooting](/docs/help/troubleshooting/) — More fixes for connection problems.
:::

Source: https://powerwp.ai/docs/connect/codex/
