Codex CLI
Add the MCP server to Codex in config.toml, and check that it works.
Codex reads its MCP servers from ~/.codex/config.toml. The file stores the name of the environment variable that holds the key. It does not store the key.
Install
-
Make a test key in the dashboard. A test key starts with
sk_test_. -
Put the key in an environment variable:
export AFFFAST_API_KEY="sk_test_..." -
Add the server to
~/.codex/config.toml:[mcp_servers.afffast] url = "https://api.afffast.com/mcp" bearer_token_env_var = "AFFFAST_API_KEY"Codex sends the value of
AFFFAST_API_KEYin the headerAuthorization: Bearer ....
You can also add the server with a command:
codex mcp add afffast --url https://api.afffast.com/mcpThis command does not set the key. Add the line bearer_token_env_var = "AFFFAST_API_KEY" to the new table in config.toml.
To use the server in one project only, put the same table in .codex/config.toml of the project. Codex reads this file only for a trusted project.
Check that it works
- Run
codex mcp list. The list must showafffast. - Start
codex. Type/mcp. The server must show its tools.
Example prompts
- "Use the afffast tools to show the revenue by network for last month."
- "Find the conversions with the status declined this week. Group them by program."
- "List my sites and the number of clicks that each site got in the last 7 days."
Troubleshooting
- The server does not connect. Make sure that
AFFFAST_API_KEYis set in the shell that startedcodex. A variable that you set in another terminal does not apply. - A 401 error. The key is wrong or revoked. Make a new key.
- The tools are missing. The key decides the tools. A read-only key has no write tools.
- The project config is ignored. Codex reads
.codex/config.tomlonly in a trusted project. - You see a login prompt.
codex mcp loginis for OAuth. This server uses an API key and has no OAuth. Usebearer_token_env_var.
Security
- Never paste a key into a chat. Use the environment variable.
- Start with a test key. A test key reads and writes test data only.
- Use a read-only key if the tool must only read.
- Never put the key in
config.toml. Usebearer_token_env_var.