Codex MCP servers give Codex new tools. A GitHub server lets it read issues, a Playwright server lets it open a browser, and a hosting server lets it put your app online.
You add a server with one command:
codex mcp add my-server --url https://example.com/mcp
That's the short version. Below is the rest: local and remote servers, how to log in, where Codex saves the settings, and what to do when a server doesn't connect.
The commands here were checked with Codex CLI 0.166.
Local or remote?
There are two kinds of MCP servers.
- Remote (HTTP). The server runs somewhere on the internet. Codex connects to its address. Nothing to install.
-
Local (stdio). The server is a program on your computer. Codex starts it for you, usually with
npxoruvx.
The README of the server tells you which kind it is. If it gives you a URL, it's remote. If it gives you a command like npx something, it's local.
Add a remote MCP server
Use --url and a name you choose:
codex mcp add sentry --url https://mcp.sentry.dev/mcp
Most remote servers need you to log in. There are two ways.
Log in with the browser (OAuth). If Codex sees that the server supports OAuth, it starts the login right after add. If it doesn't, or you closed the page, run:
codex mcp login sentry
A browser page opens, you log in and allow access. On a machine without a browser, for example over SSH, add --no-browser. Codex prints a link, and you open it on any computer.
Use a token. Some servers give you an API key instead. Codex doesn't store the key itself. It reads it from an environment variable each time it connects:
codex mcp add my-server --url https://example.com/mcp --bearer-token-env-var MY_SERVER_TOKEN
Then set the variable in the terminal where you start Codex:
export MY_SERVER_TOKEN=your-token
Put that line in ~/.zshrc or ~/.bashrc so you don't have to type it every time.
Add a local MCP server
Put -- before the command that starts the server. Everything after -- is the command:
codex mcp add playwright -- npx @playwright/mcp@latest
If the server needs an API key, pass it with --env:
codex mcp add my-server --env API_KEY=YOUR_KEY -- npx my-mcp-server
You need Node.js for npx servers and Python with uv for uvx servers.
Where Codex saves servers: config.toml
codex mcp add writes the server into ~/.codex/config.toml. The servers there work in every folder. The Codex IDE extension reads the same file, so a server you add in the terminal shows up there too.
You can also edit the file by hand. After the commands above it looks like this:
[mcp_servers.sentry]
url = "https://mcp.sentry.dev/mcp"
[mcp_servers.my-server]
url = "https://example.com/mcp"
bearer_token_env_var = "MY_SERVER_TOKEN"
[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]
A few more settings that are useful for remote servers:
[mcp_servers.my-server]
url = "https://example.com/mcp"
http_headers = { "X-Region" = "eu" } # a fixed header
env_http_headers = { "X-Api-Key" = "MY_API_KEY" } # a header from an environment variable
startup_timeout_sec = 20 # wait longer for a slow server
tool_timeout_sec = 120 # let long tools finish
enabled_tools = ["search", "read_file"] # only these tools
enabled = false # keep it, but turn it off
Don't put real tokens in config.toml. Use bearer_token_env_var or env_http_headers, and keep the values in environment variables.
Check that it works
In the terminal:
codex mcp list
You see every server, whether it is enabled, and how it logs in: OAuth, Bearer token or Not logged in. For one server:
codex mcp get sentry
Inside Codex, type /mcp. It shows the servers Codex connected to in this session and their tools.
Then just ask Codex to use it: "List my open Sentry issues". If the server works, Codex calls its tools.
Remove a server or log out
codex mcp remove sentry
To keep the server but drop the saved login:
codex mcp logout sentry
When the server doesn't connect
-
Not logged inincodex mcp list. Runcodex mcp login <name>. If the login expired, runcodex mcp logout <name>and log in again. -
"MCP server may or may not require login" after
add. Codex couldn't tell if the server uses OAuth. That's fine: runcodex mcp login <name>once. -
401 or 403 with a token. Check that the variable from
bearer_token_env_varis set in the same terminal where you start Codex:echo $MY_SERVER_TOKEN. Codex sends it asAuthorization: Bearer <token>. -
A remote server times out on start. Check the URL. Many servers end with
/mcp. If the server is just slow, raisestartup_timeout_sec. -
A local server fails to start. Run its command by hand, for example
npx @playwright/mcp@latest. You will see the real error, often a missing Node.js or Python. - The server is connected, but Codex doesn't use it. Name it in your request: "use the Playwright MCP to open the page". Codex picks tools by their names and descriptions.
Example: a remote server that deploys your code
Here is a real remote MCP server: vbtnl. It gives Codex tools to create a project on a server, write files there, run them and publish the app to a public address.
codex mcp add vbtnl --url https://api.vbtnl.com/mcp
Codex sees that vbtnl uses OAuth and opens a login page. Log in with your vbtnl account. If you closed the page, run codex mcp login vbtnl. Now you can ask:
Make a landing page with a waitlist and put it online on vbtnl.
Codex writes the code on the server, starts it and replies with a link. Setup for Codex and other apps is in the docs. If you also use Claude Code, the same steps for it are in How to add an MCP server to Claude Code. For a full example, see how to build and deploy a Telegram bot: the same prompt works in Codex.
Which MCP servers to add
Start with the ones that match your daily work. Popular choices for Codex:
- GitHub for issues and pull requests.
- Playwright to open pages in a real browser and test them.
- Figma to read designs and turn them into code.
- Sentry to read errors from production.
- A hosting server like vbtnl to put what Codex built online.
Don't add everything at once. Each server adds tools, and with too many tools Codex has a harder time picking the right one.
Originally published on the vbtnl blog.
Top comments (0)