How to Connect Codex to WordPress to Build and Run Your Site
Updated 14.10.2026

How to Connect Codex to WordPress to Build and Run Your Site

Codex is OpenAI’s coding agent. With Fabrement it does more than write code on your computer: it builds and runs your WordPress site. It creates custom Gutenberg blocks, turns Figma frames into WordPress pages, sets up SEO and translates the site with WPML, and keeps managing all of it after launch, without opening wp-admin. To get there, you connect Codex to the site over MCP.

Codex runs in three places: the Codex app in the ChatGPT desktop app, the Codex CLI in a terminal, and the Codex extension for VS Code or Cursor. All three read the same settings, so you connect your site once. Codex on the web cannot connect to your own MCP server.

This guide shows the four ways to add your site to Codex, first with OAuth and then with an application password. All eight are in the video, each tested with a real change on a live site.

All eight ways in 9 minutes: the Codex app, the terminal, config.toml and AI instructions, each with OAuth and with an application password.

Key takeaways

  • Four ways in, two ways to sign in. Add your site in the Codex app, in a terminal, in config.toml, or let Codex set it up from instructions you paste. Each works with OAuth or with an application password.
  • Connect once, use it everywhere. The Codex app, the CLI and the IDE extension share one settings file, ~/.codex/config.toml.
  • Your password stays on your site. With OAuth you approve access on your own WordPress site, and Codex receives a token that only works through the Fabrement MCP server.
  • Local sites work. Codex connects from your computer, so it reaches a local site with a trusted HTTPS certificate over OAuth, and any local site with an application password.
  • Not on the web. Codex on the web cannot connect to your own MCP server. Use the app, the CLI or the extension.

Hand this to your AI first: fabrement.com/AGENTS.md. One link, and your agent knows what Fabrement can do on your site and how to connect to it.

Which way should you use?

What you doBest for
Codex app RecommendedAdd the server in Settings, then sign inMost people: nothing to type
TerminalRun two commands: one adds the site, one signs inPeople who already use the Codex CLI
config.tomlPaste a short block into the Codex settings fileDevelopers who keep their Codex settings by hand
Let Codex set it upPaste instructions into a Codex chatAnyone who would rather not touch settings at all

Use OAuth whenever you can: there is no password to copy, and you approve access on your own site. Use an application password when OAuth is not an option.

Before you start

  • WordPress 6.9 or newer, PHP 8.0 or newer, and an administrator account.
  • Fabrement installed and the site signed in to the Fabrement service: block code is checked and stored there, so nothing can be saved until the site is signed in.
  • Codex in the ChatGPT desktop app, the Codex CLI, or the Codex extension for VS Code or Cursor, signed in to your account.
  • For OAuth, a site on HTTPS with a trusted certificate. For a local site on plain http://, use an application password.

Every connection detail below comes from Fabrement → MCP Connection in wp-admin, on the Codex card. Copy it from there rather than typing it: the server name and address are specific to your site.

1. Connect in the Codex app

Step 1: Copy the server name and URL

In Fabrement → MCP Connection, pick Codex and stay on the Recommended tab. It shows the Server name and the MCP server URL for your site, each with a copy button.

Fabrement MCP Connection screen with the Codex card selected: open the Codex app, then add the server with its name and MCP server URL

Step 2: Add the server in Codex

In Codex, open Settings → Plugins, click Add and choose Add MCP server. Paste the server name into Name, switch Type to Streamable HTTP, paste the MCP server URL into URL and click Save. Leave the token and header fields empty: OAuth needs none of them. In the IDE extension, MCP servers are under the gear icon.

Codex app Settings, Plugins, MCPs tab: Connect to a custom MCP with the server name, Streamable HTTP type and the site MCP server URL

Step 3: Sign in and approve access on your site

The server now shows on the MCPs tab under Servers. If it shows Authenticate, press it. Your WordPress site opens an authorization page that says exactly what Codex gets: full access through the Fabrement MCP server, with your administrator permissions. The token cannot sign in to wp-admin or call other REST API routes or other MCP servers, and your WordPress password is not shared. Press Allow access.

WordPress authorization page Connect to Fabrement for Codex, listing the access it grants, with the Allow access button

Step 4: Check the connection

Start a new chat and ask: Check if you have an MCP connection to your-site.com. Codex reads the site’s settings to prove the connection works, and changes nothing on the site.

Codex confirms an active MCP connection to the WordPress site, reads its settings and reports that nothing was changed
Free plugin

Fabrement: the workplace for your AI agent

A free plugin for WordPress 6.9 or newer. Once your AI is connected, your agent can do all of this on your site.

2. Connect in a terminal

In Fabrement → MCP Connection, pick Codex, open the Advanced tab and expand Codex (OAuth). It offers three ways to add the site without the app form. Whichever you pick, the app, the CLI and the IDE extension all use it.

Fabrement MCP Connection, Codex card, Advanced tab: the two terminal commands, the config.toml snippet and the AI instructions for OAuth

Under In a terminal, run both commands one by one. The first adds the site to Codex, the second opens your browser on the same approval page as in step 3 above. They have this shape, with your own name and address filled in:

codex mcp add fabrement-your-site --url "https://your-site.com/wp-json/fabrement/v1/mcp"
codex mcp login fabrement-your-site

Keep the terminal open until sign-in finishes: the approval returns to a temporary address on your own computer, which the CLI is listening on.

Codex CLI in a terminal: codex mcp add with the site MCP URL, then OAuth support detected and the sign-in flow starting

3. Connect with the config.toml file

Codex keeps its settings in config.toml, in the .codex folder in your home folder: ~/.codex/config.toml on macOS and Linux, C:\Users\you\.codex\config.toml on Windows. Add the block from ~/.codex/config.toml on the Advanced tab next to the servers already there; do not replace the file. It has this shape:

[mcp_servers.fabrement-your-site]
url = "https://your-site.com/wp-json/fabrement/v1/mcp"

Then sign in with codex mcp login fabrement-your-site, or press Authenticate next to the server in the Codex app. This block holds no password, so the file stays safe to keep as it is.

4. Let Codex set it up

Under Let Codex set it up, copy the AI instructions and paste them into a new Codex chat. Codex adds the server itself: it keeps your other MCP servers, asks before replacing one with the same name, and only checks the connection, so it changes nothing on the site.

Codex may ask for permission to edit its settings file and to reach the network to test the connection. Approve both, sign in when it asks, then start a new chat to use the site.

5. Without OAuth: an application password

Use an application password when OAuth is not an option: the site has no HTTPS (for example a local http:// site), OAuth is turned off, or Codex runs where no browser can open to approve access, such as a server. In Fabrement → MCP Connection, pick Codex, open the Advanced tab, then Application password, and generate one. The same four ways then appear, with the password already filled in.

In the Codex app

Add a Streamable HTTP server with the name and URL, as in section 1. Then add a Headers row: paste Authorization into the key field and the Header value into the value field. Leave Bearer token env var empty.

Fabrement application password setup for the Codex app: server name, URL, the Authorization header key and the hidden header value

In a terminal

The screen gives one set of commands for Windows PowerShell and one for Linux and macOS. They store the password in an environment variable and add the site to Codex. Start Codex from that same terminal afterwards: terminals and apps that were already running do not see the new variable, and on Linux and macOS it lasts only for that terminal session. For the desktop app, or a setup that lasts, use the Codex app or config.toml instead.

In config.toml

The block for config.toml now carries the password in an Authorization header. The app, the CLI and the IDE extension all read it. Because the file now holds the password, do not commit it to Git and do not share it.

Let Codex set it up

The AI instructions now include the password and tell Codex not to use OAuth. Paste them only into your own Codex, never into a shared chat.

The password is shown on this screen only, and it works until you revoke it. Treat it like an administrator password: keep it out of screenshots, recordings, chats and shared documents, and disconnect it in the Connection access card when the work is done.

Connected. What to build first

Once Codex answers with your site’s details, give it real work. Three requests to start with, in plain language:

When it does not work

What you seeWhat it is
Codex on the web cannot find the siteCodex on the web cannot connect to your own MCP server. Use the Codex app, the CLI or the IDE extension.
The server is added, but Codex sees no toolsThe chat started before you connected, or the server is switched off. Check its switch on the MCPs tab, then start a new chat.
The sign-in page did not openRun codex mcp login with your server name, or press Authenticate next to the server in the app.
Sign-in starts, then failsThe terminal was closed before the approval came back. Run the login command again and keep the terminal open until it finishes.
401, or «incorrect password»With an application password: the Bearer token field is filled in, the header key is not exactly Authorization, the value was cut off when copied, or the password was revoked. Generate a fresh one.
Works in one terminal, not in anotherThe password was set as an environment variable in the first terminal only. Start Codex from that terminal, or move the connection to config.toml.
The server name is already takenAnother site or an older connection uses the same name. Pick a different name, or replace that connection on purpose.

Revoking access

OAuth access and application passwords both stay active until you revoke them. The Connection access card on Fabrement → MCP Connection lists every connection to the site, whichever client set it up, with when it was created and last used. Press Disconnect next to one to revoke it, then remove the server in Codex too: on the MCPs tab in the app, or by deleting its block from config.toml. Revoking disconnects the agent immediately.

FAQ

Frequently asked questions

Using another client? See how to connect Claude to WordPress, ChatGPT or Cursor.

Sources

Checked on 15 October 2026, with Fabrement 1.4.0. If a step has changed, tell us and we will correct it.

Build and maintain custom WordPress themes with your AI agent

Install the free plugin in a minute and connect the AI you already use: ChatGPT, Claude, Codex or Cursor. No credits to buy, no new subscription.

NO CREDIT CARD · WORKS WITH EXISTING SITES · YOUR OWN AI AGENT