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

Add the server

  1. 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.

  2. Add the server block to ~/.codex/config.toml

    Open ~/.codex/config.toml in your editor and append:

    [mcp_servers.hatchable]
    url = "https://hatchable.com/mcp"
    bearer_token_env_var = "HATCHABLE_API_KEY"

    The key hatchable after 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.

  3. Restart Codex and verify

    Fully quit any running Codex sessions and restart:

    codex

    In 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.

  4. 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.

Why the env-var indirection? Codex stores configs in plain-text TOML that's often checked into dotfile repos. The 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:

Codex says "failed to connect to MCP server"

Almost always a network or URL problem:

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.