Connect OpenAI Codex CLI to FineProxy MCP
Add the FineProxy MCP server to the OpenAI Codex CLI with codex mcp add or config.toml, sending the API key from an environment variable as a bearer token.
This page shows how to connect the OpenAI Codex CLI to the FineProxy MCP server. Codex connects directly over Streamable HTTP and sends your API key as a bearer token that it reads from an environment variable.
Requirements
- Codex CLI with MCP support,
codexon yourPATH. - A FineProxy API key (starts with
fb_). Create one in Settings → API keys. Start with read-only scopes.
Set up
Where the config lives
| Scope | Path |
|---|---|
| User | ~/.codex/config.toml |
| Project | .codex/config.toml (only in trusted projects) |
~ is your home folder.
Option 1: add the server with the CLI
-
Put your key in an environment variable:
export FINEPROXY_API_KEY="fb_your_api_key" -
Add the server:
codex mcp add fineproxy --url https://fineproxy.org/account_new/api/v1/mcp \ --bearer-token-env-var FINEPROXY_API_KEY
Option 2: edit config.toml
Add this table to ~/.codex/config.toml:
[mcp_servers.fineproxy]
url = "https://fineproxy.org/account_new/api/v1/mcp"
bearer_token_env_var = "FINEPROXY_API_KEY"
Codex reads the variable when it starts and sends Authorization: Bearer <value> with every request.
Keep your key out of the config
bearer_token_env_varstores only the name of the variable. The key itself stays in your environment, soconfig.tomlholds no secret.env_http_headersmaps header names to environment variable names in the same way, for servers that need other headers. For FineProxy,bearer_token_env_varis all you need.- Avoid
http_headerswith a literal key: it writes the secret intoconfig.toml.
Warning: A project-level
.codex/config.tomlis easy to commit. Keep only variable names in it, never a literalfb_...key.
Verify the connection
Check that the server is configured:
codex mcp list
codex mcp get fineproxy --json
Then start codex, type /mcp to see the active servers and their tools, and ask:
What is my FineProxy balance?
Codex calls the wallet_balance tool and answers with your balance, for example "balance_cents": 5000 — money values are integer cents, so that is $50.00.
Tips
- Approve tool calls. Review each FineProxy tool call before Codex runs it, especially order, renewal and cancellation tools, and don’t switch to an approval mode that runs money-moving tools unattended.
- Use a read-only key first. For exploring, a key with
customer:read,wallet:read,services:readandcatalog:readis enough. Withoutwallet:spend, the agent can’t run tools that debit your wallet. - Add
wallet:spendonly for purchases. Create a separate key withwallet:spendwhen you want Codex to buy or renew. Purchase tools carry a price guard and an idempotency key: a wrong total is rejected without a charge, and a retry with the same key never charges twice. - Some tools take a while to answer (
list_countriescan take about 10 seconds). If a call times out, raisetool_timeout_secfor the server (the default is 60 seconds). - Read MCP safety and the scopes reference before you give an agent spending rights.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
401 | FINEPROXY_API_KEY isn’t set in the shell that starts codex. Export it there and restart Codex. |
| Codex asks you to sign in with OAuth | The bearer token isn’t configured. codex mcp login is for OAuth servers; FineProxy MCP accepts API keys only — use bearer_token_env_var. |
| The project config is ignored | .codex/config.toml is read only in trusted projects. Trust the project or use ~/.codex/config.toml. |
429 Too Many Requests | Too many sessions connecting at once. Wait a moment and start Codex again. |
For server-side errors and tool failures, see MCP troubleshooting.