// guide

How to connect your WordPress site to Codex

OpenAI's Codex CLI can operate your self-hosted WordPress site from the terminal — publishing posts, running WP-CLI, and reading the error log to explain what broke. Install the free Cowboy MCP plugin, generate an API key under Settings → Cowboy MCP, export it, and run one codex mcp add command to register your site as a remote MCP server — no Node proxy. New to MCP? Start with the WordPress MCP server guide.

// what you can ask

What can Codex do on your WordPress site once it's connected?

Once connected, the Codex CLI acts on your live site with real tools, not just code it prints back for you to paste. From the terminal it can vibe code a theme tweak, run WP-CLI commands, read the PHP error log to debug a fatal, and make bulk edits across posts or WooCommerce products. Cowboy MCP exposes 137 WordPress tools that Codex calls directly over HTTPS.

codex — cowboy-mcp
$ "Add a REST route to my theme that returns the 5 latest posts as JSON."
$ "Run wp plugin update --all, then run a site-health check."
$ "Read the error log and fix the fatal on the checkout page."
$ "Find every Clearance product, drop the price 15%, then clear the cache."
// setup

How do you connect Codex to WordPress in three steps?

Connecting takes three steps and two short commands. Install the Cowboy MCP plugin, generate an API key under Settings → Cowboy MCP, then export that key and run one codex mcp add command in your terminal. Codex reads the key from the COWBOY_MCP_API_KEY environment variable rather than a config file, so you never paste the secret into a dotfile — it's sent as an HTTP Bearer token at request time.

  1. 1

    Install the free plugin

    In WordPress, go to Plugins → Add New, search for Cowboy MCP, and click Install then Activate.

  2. 2

    Generate an API key

    Open Settings → Cowboy MCP, name a key on the Connection tab, and generate it — it's shown once, so copy it now.

  3. 3

    Export the key and add the server

    Run the two codex commands below in your terminal, swapping in your site and key.

terminal — codex mcp add
$ export COWBOY_MCP_API_KEY="YOUR_API_KEY"
$ codex mcp add your-site --url https://your-site.com/wp-json/cowboy-mcp/v1/endpoint --bearer-token-env-var COWBOY_MCP_API_KEY

Then run codex mcp list — your site should appear in the list.

// architecture

Why doesn't Codex need a Node.js proxy to reach WordPress?

Many MCP setups run a local Node.js process that bridges the agent and a remote service. The Codex CLI needs none of that to reach WordPress. Cowboy MCP publishes its MCP endpoint as an ordinary WordPress REST route at /wp-json/cowboy-mcp/v1/endpoint, so Codex connects to your site directly over HTTPS — no Node bridge, no npm proxy, and nothing extra running on your machine. The plugin is itself the MCP server.

Because the endpoint speaks standard Streamable HTTP, the connection lives on your server rather than in a background daemon — it survives reboots and laptop swaps. The same site works for every MCP client, too: Claude Code, the Claude desktop and web apps, Cursor, and Gemini all reach the same tools. Only the setup command changes from one client to the next.

// safety

Is it safe to run Codex against your live production site?

Yes, with the same guardrails the plugin applies to every client. Safe mode is on by default, so destructive tools ask before they run. Any write can be previewed as a dry run, every change lands in an undo journal you can roll back, and requests are rate-limited to 120 per minute. Give Codex its own API key you can revoke — it all runs on your own server. More on security →

// faq

Questions, answered.

Do I need Node.js to connect WordPress to Codex?

No — the plugin needs no Node.js. Cowboy MCP runs entirely inside WordPress as a REST endpoint, so there's no Node bridge and no proxy to keep running. Installing the Codex CLI itself is OpenAI's requirement, and that step may use npm — but that's Codex's own tooling on your machine, not anything Cowboy MCP adds to your WordPress site.

Where does the API key go, and can I revoke it?

You export it as the COWBOY_MCP_API_KEY environment variable, and Codex reads it from there at request time — it's never pasted into a config file. Generate the key under Settings → Cowboy MCP on the Connection tab; it's shown once and stored only as a hash, so copy it right away. Every key is listed there with one-click revoke.

Codex CLI or ChatGPT's connector — which should I use for WordPress?

Both reach the same tools on your site, so pick the one you already work in. The Codex CLI connects from the terminal with an exported API key and one command. ChatGPT's connector uses a no-terminal browser sign-in instead — the connect WordPress to ChatGPT guide covers that path.

Is it safe to run Codex on a production site?

Yes, with care. Safe mode asks before destructive actions, any write can be previewed as a dry run, and every change lands in an undo journal you can roll back. Give Codex its own API key you can revoke, take a database checkpoint before big changes, and review the audit log regularly.

// get started

Ready to connect Codex to your WordPress site?

Install the free, open-source Cowboy MCP plugin, generate an API key, and run one command — the Codex CLI is managing your site minutes later. It works on any self-hosted WordPress site running version 6.2 or newer on PHP 8.0+. Prefer a different agent? The same site connects to Claude Code and the Claude desktop and web apps too.