Codex MCP Setup: Build React UI With Real Components

OpenAI Codex writes React fast, and left alone it writes the components it remembers: a settings page from scratch, a modal without a phone layout, a button with a hand-rolled spinner. A Codex MCP connection to your component library fixes that, because Codex can search the real catalog, read props with their defaults and install the source with a CLI before it writes a line. This tutorial sets that up end to end with our library, Wingo UI: the key, the config.toml entry, the rules file, the restart and the check, three prompts that produce whole screens from real blocks, and the errors you are likely to hit.
We tested it on October 13, 2026 with Codex CLI 0.162.1, our CLI 1.0.3 and Wingo UI release 1.8.0, and checked the config syntax against OpenAI's Codex MCP docs (opens in a new tab) and config reference (opens in a new tab) on the same day. What an MCP server for components is and why agents need one is covered in our component library MCP guide; this post is the Codex half of it, in detail.
What does a Codex MCP server setup need?
Four pieces, and one command writes the two files:
Step 1: How do I get a key?
Sign the CLI in once per computer:
It opens the browser to approve the device and saves an API key in ~/.config/wingo-ui. A free account needs only an email. The key decides what Codex receives:
- No key: search, props, docs, design rules and tokens all answer, with no source. We called
get_account_statuswithout one and the server said exactly that. - Free key: adds the source of the 75 free items, the Button among them.
- Pro key: adds the source of every item, including blocks like the Settings Page and Login Page used below.
For the HTTP setup in step 3 you also want the key as a value: create one for Codex on your account's API keys page, so you can revoke it on its own later.
Step 2: What does agents install codex write?
Run it in the project:
Without WINGO_UI_API_KEY in the environment, on a clean machine, it printed these lines (plus a note about the key):
The default is your user config on purpose. OpenAI's config reference says Codex "loads project-scoped config files only when you trust the project", and untrusted projects skip the whole .codex/ folder. A server in your home folder works in every project, trusted or not.
For a repository your team shares, --scope project writes .codex/config.toml and a marked block in the project's AGENTS.md instead. In our test project, create-next-app had already written an AGENTS.md; the CLI appended its block and kept the rest. Running the command again changes nothing, and it keeps other servers in the file.
Should Codex use HTTP or the stdio proxy?
The CLI picks HTTP when WINGO_UI_API_KEY is set and the proxy otherwise; --mcp http or --mcp stdio picks for you. This is the Codex config.toml mcp_servers table each one writes:
bearer_token_env_var holds the name of a variable, never the key itself, so the file is safe to sync or share. HTTP is one less process and starts instantly. The proxy needs no environment setup: if you already ran login, it works. Pick the proxy if you start Codex from an editor or app that may not load your shell profile.
Step 3: How do I export the key for Codex?
HTTP mode only. Codex reads the variable when it starts, so it has to be in the environment of the shell that launches it. Put it in your shell profile:
Open a new terminal, and check that the variable is there before you start Codex: echo $WINGO_UI_API_KEY | cut -c1-4 should print wui_.
Step 4: How do I check the connection?
Restart Codex, then check from the shell. In our test project codex mcp list printed:
codex mcp get wingo-ui shows the transport (streamable_http for HTTP). Inside a Codex session, type /mcp to see the active servers. Then ask one question that only the server can answer:
If the answer mentions your plan, the key reached the server. If it says "Anonymous", Codex connected without a key: check step 3.
What do the AGENTS.md rules tell Codex?
When to call which tool, how to install, and what never to do. This is the block the CLI wrote, between version markers that npx wingo-ui@latest agents update rewrites later:
How Codex finds it, from OpenAI's AGENTS.md guide (opens in a new tab): first ~/.codex/AGENTS.md (or AGENTS.override.md), then one file per folder from the project root down to where you started Codex, joined in that order up to project_doc_max_bytes, 32 KiB by default. Files closer to your working folder come later, so a project's own rules can refine the global block.
That order is the one trade-off of the default setup: the global block says "This project builds its UI with Wingo UI" in every repository on your machine. If you also work on projects that use something else, install with --scope project there, or add a line to those projects' AGENTS.md that says which library they use. If you want a fuller Codex AGENTS.md React template, with commands, tokens and the checks for every screen, our AGENTS.md vs CLAUDE.md comparison has one.
Which prompts get OpenAI Codex to build React UI from real components?
Prompts that name the block, say where its data comes from and ask for a list of what is still simulated. That holds for any OpenAI Codex React UI task, with any library. Our blocks ship working sample handlers so their demos run, and every handler you do not pass keeps its sample behavior. Here are three, with the tools the rules and server instructions lead Codex to call. We called each of those tools on the server directly to check its answer; how often a given model follows them varies.
Prompt 1: a settings screen from settings-page
The block's section ids are its own (profil, cont, notificari, facturare, securitate, pericol); the labels on screen are English. A good run ends with a client component like this, which we type-checked against release 1.8.0:
The list Codex should hand back includes onUpload (the photo upload), onEmailChange and verifyEmailCode (the change-email dialog, where the code 123456 passes until you wire it), and checkWorkspaceAddress. In the demo below, a save fails on purpose so you can see what the user sees when your API rejects one.
$ npx wingo-ui@latest add settings-pagePrompt 2: a sign-in from login-page
The sample brand matters here: the block's default labels name Northwind CRM in the app name and the sign-in description and Northwind Software in the copyright line, and its default logo is the Northwind mark. The result we expect:
Without onVerifyCode, the code view accepts 123456 for anyone, which is the line in the agent's report you most want to see. With the methods above and the providers hidden, the list should come back empty.
$ npx wingo-ui@latest add login-pagePrompt 3: swap a hand-written component
The point is get_component: our Button has a loading prop, so the hand-rolled spinner and the disabled juggling go away:
While saving is true the label swaps for a spinner and "Saving", the width holds, clicks are ignored and aria-busy is set.
What goes wrong, and how do I fix it?
- The server is missing in a trusted project. You installed with
--scope project, and Codex does not trust the folder. In our test,codex mcp listprinted "No MCP servers configured yet" until we marked the folder as trusted. Trust lives in~/.codex/config.tomlasprojects.<path>.trust_level; we addedtrust_level = "trusted"under a[projects."<path>"]table and the server appeared. Trust the project when Codex asks, or install with the default user scope. - The key variable is missing. Codex has no token to send for the HTTP entry. Check with the
echoline from step 3 in the shell you start Codex from, exportWINGO_UI_API_KEYin your profile, open a new terminal and restart Codex. An editor or desktop app may not load your shell profile; switch to the proxy withnpx wingo-ui@latest agents install codex --mcp stdio. - The stdio proxy times out on first start.
npxdownloads the package the first time, and Codex waits 10 seconds by default (startup_timeout_sec). Addstartup_timeout_sec = 30to the[mcp_servers.wingo-ui]table, or runnpx -y wingo-ui@latest --versiononce beforehand. - A free key and a Pro block.
get_blockstill returns props and usage forsettings-page, but no source, andnpx wingo-ui@latest add settings-pagestops with "Settings Page is part of Wingo UI Pro". Ask Codex to build from free components instead, or upgrade. - Codex writes UI without calling the tools. Check that the rules block is in an
AGENTS.mdCodex reads (npx wingo-ui@latest agents statustells you), and name the block in the prompt.
Where should I start?
Run npx wingo-ui@latest login, then npx wingo-ui@latest agents install codex, restart Codex and try prompt 3 on a free component first. The MCP server docs list every tool, and the coding agents docs cover the other agents and the --scope and --mcp options. The Settings Page and Login Page blocks are part of Wingo UI Pro, on the pricing page. Everything we ship for coding agents is on one page, Wingo UI for AI agents, and more setups like this one live under Building UI with AI agents, including the Claude Code shadcn MCP setup for the same job in Claude Code.
FAQ
Where does Codex store MCP servers?
In config.toml: ~/.codex/config.toml for every project, or .codex/config.toml inside a project. OpenAI's docs say Codex loads the project file only when you trust the project, which is why our CLI writes to the user file by default.
How do I pass an API key to a remote MCP server in Codex?
Set bearer_token_env_var to the name of an environment variable, such as WINGO_UI_API_KEY, and export that variable in the shell that starts Codex. Codex sends its value as a bearer token in the Authorization header, so the key never goes in the config file.
Why does Codex not see my MCP server?
Usually the server sits in .codex/config.toml of a project Codex does not trust, or Codex was not restarted after the change. Run codex mcp list in the project folder: if the server is missing there, Codex is not reading the file.
Does Codex read AGENTS.md from my home folder?
Yes. Codex reads ~/.codex/AGENTS.md first, then AGENTS.md files from the project root down to the current folder, and joins them up to 32 KiB by default (project_doc_max_bytes).
Can Codex install Pro components with a free key?
No. A free key returns the source of free items; Pro blocks such as the Settings Page still return their props and docs, but the source and npx wingo-ui@latest add need a Pro account.
- Codex
- OpenAI
- MCP
- AGENTS.md
- AI agents


