TL;DR. Add the MCP server to ~/.codex/config.toml as a [mcp_servers.*] block, and set the bearer token as an environment variable so Codex picks it up at launch. For Hatchable: one config block plus export HATCHABLE_API_KEY="..." in your shell.
What is an MCP server in Codex?
OpenAI Codex is a terminal-based AI coding agent — a command-line cousin of Claude Code. It supports the Model Context Protocol (MCP), which lets it call external tools (databases, APIs, deployment targets) as first-class functions during a session. Registering an MCP server in Codex adds a new tool category to what Codex can do without any new model training.
Hatchable's MCP server exposes tools for creating projects, deploying code, and querying the app's database, so Codex can take you from "describe the app" to "live URL" in one session.
Before you start
- Codex installed. If you don't have it:
npm install -g @openai/codex, then runcodex loginto connect your OpenAI account. - A bearer token for the MCP server you're adding. For Hatchable, click Copy on the Codex snippet at hatchable.com — you'll get a token and config ready to paste.
- Your
~/.codex/directory exists. Codex creates it on first run; if you haven't run Codex yet, runcodexonce and quit out, or justmkdir -p ~/.codex.
Add the server
-
Export the bearer token as an env var
Codex's config references env vars by name rather than storing secrets in the TOML file. Put this in your shell profile (
~/.zshrc,~/.bashrc, or equivalent):export HATCHABLE_API_KEY="YOUR_TOKEN"Reload your shell (
source ~/.zshrc) before continuing so the variable is available to Codex when it launches. -
Add the server block to
~/.codex/config.tomlOpen
~/.codex/config.tomlin your editor and append:[mcp_servers.hatchable] url = "https://hatchable.com/mcp" bearer_token_env_var = "HATCHABLE_API_KEY"The key
hatchableafter the dot is the local name Codex uses to refer to the server — you can set it to anything, but keep it short and lowercase. For additional MCP servers, repeat the block with a different name. -
Restart Codex and verify
Fully quit any running Codex sessions and restart:
codexIn the session, ask Codex to list its tools: "What tools do you have available?" You should see Hatchable's tools (like
create_project,deploy,query_database) in the response. If they're missing, jump to Troubleshooting below. -
Try it
Ask Codex to do something that requires the server:
"Build a small habit-tracker web app on Hatchable. Make it for personal use."
Codex will propose a plan, ask for permission, then call Hatchable's tools to create the project, write the files, and deploy it. You'll get a live URL back in the same session.
bearer_token_env_var pattern keeps the actual secret out of the file so you can safely share your config. The tradeoff: you have to remember to export the variable in every shell environment Codex runs in.
Removing or updating a server
Remove: delete the [mcp_servers.hatchable] block from config.toml. Codex picks up the change on next launch.
Rotate the token: generate a new one, replace HATCHABLE_API_KEY in your shell profile, restart your shell. The config file doesn't need to change.
Troubleshooting
"Tool not available" or Codex doesn't list Hatchable tools
Walk through these in order:
- Confirm the env var is set in the shell that launched Codex. Run
echo $HATCHABLE_API_KEY— if it's empty, the variable didn't export into this shell. Sourcing~/.zshrcrequires a restart in some terminals (iTerm, VS Code integrated terminal). - Check the TOML syntax. TOML is unforgiving; a missing quote or wrong bracket will silently break the entire section. Paste your
config.tomlinto toml-lint.com if you suspect a typo. - Check you restarted Codex. Codex loads MCP servers at launch — edits to
config.tomldon't take effect mid-session. - Token expired? Hatchable auto-signup tokens are valid for 30 days. If yours is older, get a new one at hatchable.com.
Codex says "failed to connect to MCP server"
Almost always a network or URL problem:
- Check the URL. It's
https://hatchable.com/mcp— no trailing slash, no/mcp/. - Corporate proxy or VPN? Codex uses Node's HTTP stack, which honors
HTTPS_PROXY/HTTP_PROXYenv vars. Set those in the same shell before launching Codex if your network requires them. - TLS inspection? Some enterprise firewalls intercept HTTPS with a custom cert. Node may reject those unless you add the cert to
NODE_EXTRA_CA_CERTS.
Codex runs in the cloud — does it still see my env vars?
Yes. Codex's cloud execution mode uses a sandboxed runner that inherits the env vars you exported locally for the purpose of this session. The bearer token isn't logged on OpenAI's side; it's used only to authenticate the MCP calls.
Deploy Codex-built apps to a live URL, free.
Hatchable hosts everything your AI builds. Free forever — bring your own AI.
Get started free →Frequently asked questions
Is Codex's MCP support the same as Claude Code's?
The protocol is the same — any server that speaks MCP works in both. The configuration format differs: Claude Code uses a claude mcp add command, while Codex uses TOML in ~/.codex/config.toml. Servers are interchangeable; only the client config differs.
Do I need an OpenAI API key separately from my Hatchable token?
Yes. Your OpenAI API key (configured during codex login) authenticates Codex to OpenAI's models. Your Hatchable token authenticates Codex's MCP calls to Hatchable. They're separate services and separate credentials.
Can I use multiple MCP servers in Codex at once?
Yes — add multiple [mcp_servers.NAME] blocks to config.toml, each with a unique name. Codex loads all of them at launch and surfaces every server's tools to the model.
Does Codex work with the free OpenAI tier?
The Codex CLI itself is free. You need an OpenAI API key with credits (either paid or from the free-tier dollar grant if available) for the model calls it makes. Most Hatchable users on Codex spend a few cents per project because tool-heavy sessions are short.
Can I commit my <code>config.toml</code> to a dotfiles repo?
Yes. The bearer_token_env_var pattern keeps the actual secret out of the file — only the name of the env var is in the config. Anyone cloning your dotfiles still needs to set the env var themselves to get a working connection.