# API keys out of Codex’s config.toml

> Codex configures MCP servers in [mcp_servers.<name>] tables in ~/.codex/config.toml, or .codex/config.toml in a trusted project. env sets values for a server (so a key written there is in the file), env_vars forwards named variables from your environment, and HTTP servers can take a bearer token or headers from environment variables (bearer_token_env_var, env_http_headers). For business platforms, Codex can talk to MoltenRock Connect on your Mac instead: Connect holds the keys and answers.

codex mcp add --env writes the key into config.toml. Codex can forward variables instead, and for your business tools it can do without a key entirely.

Source: https://moltenrock.com/mcp-api-keys-codex · 2026-10-17

## A key in config.toml is a key on disk

- **--env writes the value**: codex mcp add <name> --env KEY=value stores the value in config.toml.
- **Project config travels**: .codex/config.toml in a repository goes wherever the repository goes.
- **Forwarded vars live somewhere**: env_vars keeps the key out of the file, but it still sits in your shell environment.

## Keys that are never in a file

- **Codex reaches Connect**: Codex runs commands on your Mac, so it talks to MoltenRock Connect’s local socket after a short note from Connect’s Agent Setup. 30 platforms, no key.
- **Keychain for the rest**: A wrapper reads other servers’ keys from the macOS Keychain when they start.
- **Every request logged**: Connect records each call on your Mac, under the name Codex gives itself.
- **Changes wait for you**: On Stripe, Cloudflare and GitHub, Codex can only propose; you approve with Touch ID.

## Clean up Codex’s MCP config

1. **Find the keys**: Look in ~/.codex/config.toml and any .codex/config.toml for env values and http_headers.
2. **Point Codex at Connect**: In MoltenRock Connect → Settings → Agent Setup → Other agents, copy the note and give it to Codex.
3. **Keychain for the rest**: Store the key once with security add-generic-password -a "$USER" -s my-mcp-key -w (it asks for the value, so it never lands in your shell history), then point the server’s command at a two-line wrapper script that reads it with security find-generic-password -s my-mcp-key -w, exports it and starts the server. The config then holds a path, not a secret.
4. **Rotate what was in the file**: Any key that sat in a config file may have been copied, synced or shared. Make a new one and revoke the old.

## Where a Codex MCP key can live

| Option | What’s in config.toml | Good for |
| --- | --- | --- |
| env = { KEY = "…" } | The key itself, in plain text | A quick test, then remove it |
| env_vars, bearer_token_env_var | A variable name; the key sits in your environment | Keys you already keep in your shell |
| Keychain and a wrapper script | A path to the wrapper; no secret | Any MCP server you trust |
| MoltenRock Connect | Nothing: Codex uses Connect’s local socket | Its 30 business platforms |

## What this fixes, and what it doesn’t

**Stays on your Mac**

- Platform keys, in Connect or MoltenRock’s vault
- Keys for other servers, in the Keychain
- A config.toml with nothing secret in it

**Leaves your Mac**

- Connect’s calls from your Mac to each platform
- Answers, to Codex and its model
- MoltenRock Connect covers its 30 business platforms (Stripe, Shopify, WooCommerce, GitHub, Cloudflare and more). An MCP server for anything else still needs its own key: keep that one in the Keychain.

## What people ask first

### What’s the difference between env and env_vars in Codex?

env sets values for the server (a key written there sits in config.toml); env_vars lists variables to forward from your environment.

### How does Codex use MoltenRock Connect?

Codex runs commands on your Mac, so it talks to Connect’s local socket; Connect’s Agent Setup gives you the note to paste. No MCP entry and no key needed.

### Can Codex change anything through Connect?

Only by proposing, on Stripe, Cloudflare and GitHub. Each change waits for your Touch ID; approving needs MoltenRock Pro.

### What does it cost?

Connect is free for two platforms; one $9.99 unlock opens all 30, and MoltenRock Pro includes it.

## A config.toml with no secrets in it.

MoltenRock Connect is free for Mac.
