How to Connect Codex to WordPress.com and Post from Termux on Android

AI WORKFLOWS · 2026
Connecting Codex to WordPress.com from Termux on Android, debugging MCP and OAuth errors, and keeping publishing under human control.

You can run Codex from an Android terminal and connect it to WordPress.com through the Model Context Protocol (MCP). This guide documents not only the successful setup, but also the connection failures encountered along the way: an incorrect endpoint that returned HTTP 404, an OAuth callback that depended on Termux remaining open, credentials that did not persist into a fresh process, and WordPress sites whose plans or connection states limited the available tools.

The example device is a Samsung Galaxy S26 Ultra, although the workflow applies to other Android phones capable of running a maintained Termux build. The important parts are the Codex CLI, the exact MCP endpoint, a working OAuth credential store, and a deliberate draft-first publishing workflow.

Using Claude instead? See Publishing to WordPress with Claude and the WordPress MCP Connector for the corresponding browser-based Claude workflow, WordPress HTML constraints, and reusable-skill approach.


1  ·  What You Need
  • An Android phone with Termux installed from a trusted source such as F-Droid or the official Termux GitHub releases.
  • Node.js, npm, and Git in Termux.
  • An OpenAI account and the Codex CLI.
  • A WordPress.com account with permission to edit the target site.
  • A WordPress.com site whose plan and MCP settings permit the content tools you need.

Avoid an obsolete Termux package from an unofficial source. MCP availability is also site-specific: one account can contain a usable paid WordPress.com site, a site requiring a plan upgrade, and disconnected Jetpack sites at the same time.

2  ·  Install Codex in Termux

Update Termux and install the prerequisites:

pkg update
pkg upgrade
pkg install nodejs git

node --version
npm --version

Install and verify Codex, then start it and complete the sign-in flow:

npm install -g @openai/codex
codex --version
codex

Android may open authorization in the default browser. Return to Termux when the browser step completes.

3  ·  Add the Exact WordPress.com MCP Endpoint

Enable the WordPress.com MCP tools for your account, granting only the capabilities you need. Then register the remote Streamable HTTP server in Termux:

codex mcp add wpcom-mcp --url https://public-api.wordpress.com/wpcom/v2/mcp/v1
codex mcp get wpcom-mcp
codex mcp list

The exact path matters. The working endpoint used in this session was:

https://public-api.wordpress.com/wpcom/v2/mcp/v1

The saved configuration should be enabled, use a Streamable HTTP transport, and contain the complete /wpcom/v2/mcp/v1 path. Codex stores MCP configuration in ~/.codex/config.toml by default.

🔐 Keep Termux running during OAuth, and never paste an access token into a prompt.

Start authentication with codex mcp login wpcom-mcp. The browser redirects to a temporary callback on 127.0.0.1, so the Codex process in Termux must remain alive to receive it.

After approval, start a fresh Codex session and verify the server again. Treat ~/.codex as private configuration and never commit it to a public repository.

4  ·  Problems Encountered and How to Debug Them

HTTP 404 during MCP initialization. The first failure looked like this:

MCP startup failed
unexpected server response: HTTP 404
when send initialize request

The configured URL was an incomplete WordPress.com API path, not an MCP endpoint:

https://public-api.wordpress.com/wpcom/

Inspect the registration with codex mcp get wpcom-mcp. If it is wrong, replace it cleanly and authenticate again:

codex mcp remove wpcom-mcp
codex mcp add wpcom-mcp --url https://public-api.wordpress.com/wpcom/v2/mcp/v1
codex mcp login wpcom-mcp

Browser approval succeeded, but the next session was unauthenticated. Symptoms included AuthRequired at startup, Auth: Unsupported in the MCP list, or a success message followed by failure in a fresh Codex process. That is a credential-persistence problem, not an endpoint problem.

Android Termux could not reliably store the OAuth token. In this session, the browser-based WordPress authorization completed successfully, but the Android Termux environment could not reliably save the OAuth token in a form that a later Codex process could retrieve. The clearest symptom was try_lock() not supported when Codex attempted to use its file-backed credential store. As a result, a fresh session could return AuthRequired even though the browser had just reported a successful login. This was a local credential-storage limitation, not a WordPress password problem and not an MCP endpoint problem.

Update Codex and retry because this behavior may improve in newer builds. If it remains, do not work around it by copying OAuth tokens into prompts, shell history, or ordinary files. Use a supported desktop Codex environment for the authenticated WordPress action while continuing to research and draft in Termux.

The server is configured but no tools appear. Start a fresh Codex process after configuration, run codex mcp list, and use /mcp inside the Codex terminal UI to inspect active servers. Run codex mcp --help when the installed CLI syntax is uncertain.

The account connects, but a particular site cannot be managed. Enumerate the sites first. In this session, the same account returned a usable WordPress.com site with partial MCP support, another site requiring a paid plan, and several disconnected Jetpack sites. Authentication alone does not guarantee that every site exposes tools.

5  ·  Ask Codex to Consult Official OpenAI Documentation

When CLI behavior may have changed, prompt Codex to consult the current official documentation instead of relying only on model memory. Name the source, the error, the evidence you want inspected, and the boundary that no configuration should be changed without approval.

The official references for this workflow are the Codex manual and its MCP configuration documentation.

GoalExample Prompt
Verify setup“Use current official OpenAI Codex documentation to verify how a Streamable HTTP MCP server and OAuth login should be configured. Cite the exact OpenAI pages you used. Then inspect my wpcom-mcp registration without changing it.”
Debug 404“Debug this Codex MCP initialization error: HTTP 404. First inspect codex mcp get wpcom-mcp; compare the transport and URL with current official OpenAI MCP documentation and the service’s official endpoint. Explain the cause before making changes.”
Debug OAuth“The browser says OAuth succeeded, but a fresh Codex session reports AuthRequired. Use official OpenAI Codex documentation, check codex mcp list and /mcp, distinguish server reachability from credential persistence, and do not ask me to paste a token.”
Collect evidence“Diagnose this connection layer by layer: saved configuration, endpoint, transport, OAuth callback, stored credential, fresh-session discovery, WordPress site access, and tool permissions. Show the evidence for each conclusion.”

A useful troubleshooting prompt includes four things: the desired outcome, the observed error text, the authoritative sources to consult, and what Codex must not change without confirmation.

6  ·  Verify the Site Before Creating or Editing Content

Once the connector is working, ask Codex to list the accessible WordPress.com sites before writing anything:

Use the WordPress.com MCP tools to list the sites I can access.
Show each site ID, domain, connection status, and MCP availability.
Do not create or update content.

This session demonstrated why that step matters. The account had multiple sites, but only the intended Techucation site could perform the requested basic content operation. Use the numeric site ID or exact domain in later prompts, especially when similarly named or disconnected sites are present.

7  ·  Use a Draft-First Workflow

Tell Codex the target site and status explicitly:

Create a new post on malcolmlow.com as a draft.
Do not publish it.
Return the post ID, edit URL, and preview URL.

Before updating an existing draft, have Codex list recent drafts with their IDs and modification times. “The draft article” can be ambiguous when a site contains many drafts. In this session, the newest modified draft was identified as post 3955 before any write operation was attempted.

Publishing and editing are separate actions. A request to improve formatting should preserve status: draft. A request to publish should identify the site and post ID, and Codex should state that the change will make the article public before executing it.

8  ·  Security and Review Checklist
  • Install Termux and Codex only from trusted sources.
  • Never place WordPress passwords, OAuth tokens, or credential files in prompts.
  • Keep ~/.codex private.
  • Enable only the WordPress MCP tools you need.
  • Confirm the exact domain and post ID before a write.
  • Keep new and revised articles as drafts until reviewed.
  • Check headings, code blocks, links, categories, tags, featured image, alt text, and mobile layout.
  • Revoke WordPress.com access if the phone is lost or replaced.
  • Use Android screen locking and device encryption.
9  ·  Command Cheat Sheet
# Prepare Termux
pkg update
pkg upgrade
pkg install nodejs git

# Install Codex
npm install -g @openai/codex
codex --version

# Register WordPress.com MCP
codex mcp add wpcom-mcp --url https://public-api.wordpress.com/wpcom/v2/mcp/v1

# Authenticate and inspect
codex mcp login wpcom-mcp
codex mcp get wpcom-mcp
codex mcp list
codex mcp --help

# Start a fresh session
codex

# Inside the Codex TUI
/mcp

Once the connection works, keep the workflow conservative: let Codex research and draft first, create or update the WordPress draft second, review it in the editor, and publish only after the exact site and post have been confirmed.

AI Workflows · 2026

✦ This article was assembled with the assistance of OpenAI Codex and checked against current official Codex documentation ✦