Codex + WordPress

Connect Codex to WordPress.

Point Codex at WPGuard’s Streamable HTTP endpoint and name the environment variable that holds the raw token. Codex can then inspect registered sites and prepare supported WordPress edits for review.

Codex CLI, desktop and IDE · Shared host config · Environment-backed bearer token

How do I connect Codex to a WordPress MCP server?

Add a Streamable HTTP table to ~/.codex/config.toml, or use a trusted project’s .codex/config.toml. Store the token in the named environment variable before starting Codex.

~/.codex/config.toml
[mcp_servers.wpguard]
url = "http://127.0.0.1:8642/mcp"
bearer_token_env_var = "WPGUARD_TOKEN_ADMIN"

Store the raw token in the environment

bearer_token_env_var names an environment variable. Its value is the raw WPGuard token, without a Bearer prefix. Codex adds the Authorization scheme when it connects.

Share the config on one Codex host

The Codex CLI, desktop app, and IDE extension share MCP configuration on the same host. A project config applies only to a trusted project. Review the official Codex MCP documentation →

Verify Codex and WPGuard as two separate layers.

First confirm that Codex loaded the server. Then confirm that the server can identify and inspect the intended WordPress site.

Check the Codex tool catalog

Run codex mcp list or open /mcp. Restart the desktop app or IDE extension after changing its MCP settings. A missing environment variable leaves Codex without the bearer credential WPGuard requires.

Use site_list as the handshake

Call site_list before any site mutation. A successful empty list proves the MCP connection and shows that registration is the next step. Follow it with wp_site_context for the selected staging site.

Route remote Codex correctly

127.0.0.1 refers to the machine where Codex is running. A remote execution environment needs its own authenticated HTTPS route to WPGuard. Do not expose the local HTTP endpoint directly to the public internet.

Keep client approval and packet approval distinct

Codex can prompt before write-capable MCP tools. WPGuard’s guarded writes still require their own matching packet and state checks. One approval surface does not prove that another person reviewed the change.

Give Codex an exact WordPress target.

The useful request names the registered site, the field to inspect, the desired value, and the condition that must remain true.

Preview before apply

Use apply=False for supported option, post-meta, and post-content changes. Review the old value, proposed value, correction result, state tag, and digest. Approve and apply the same request only when those details match.

Read back, then render

Read the stored value after the write. Open the page in a browser for layout, responsive behavior, interaction, accessibility, and link checks. WPGuard’s stored-value verification is not a rendered-page test.

The WPGuard Codex example uses the same environment-backed bearer setting documented by OpenAI.

Connect Codex to one staging site.

Load the server. List the sites. Preview one supported change.