Codex CLI is OpenAI's terminal coding agent. It connects to remote MCP servers over Streamable HTTP, and to local servers over stdio.
- Codex CLI, installed and signed in. Run
codex --versionto see the build. - A sec-api.io API key. Get one at sec-api.io.
- An HTTPS URL. Codex refuses plain HTTP for a remote server. This server is HTTPS.
OpenAI states no minimum Codex version for remote MCP servers. Use a current build.
| Scope | Path |
|---|---|
| User | ~/.codex/config.toml |
| Custom home | $CODEX_HOME/config.toml |
| Project | .codex/config.toml in the project |
Codex CLI, the IDE extension and the ChatGPT desktop app share this file. Project config loads only for trusted projects.
One command:
codex mcp add sec-api --url "https://api.sec-api.io/mcp?apiKey=YOUR_API_KEY"Or edit ~/.codex/config.toml by hand:
[mcp_servers.sec-api]
url = "https://api.sec-api.io/mcp?apiKey=YOUR_API_KEY"The server also reads an Authorization: Bearer header. Put the key in an
environment variable instead:
[mcp_servers.sec-api]
url = "https://api.sec-api.io/mcp"
bearer_token_env_var = "SEC_API_KEY"export SEC_API_KEY=YOUR_API_KEYCodex reads the variable at startup. Export it in your shell profile.
Quit Codex and start it again. codex mcp add writes the file at once, but a
running session keeps the server list it loaded.
codex mcp listThe sec-api row shows the URL. Inside a session, run /mcp. It lists the
connected servers and their tools. Expect 49 tools.
Use the sec-api tools. List the last five 8-K filings from Tesla with their item numbers.
Expect five rows. Each row carries a filed date, an accession number and the 8-K items. Codex prints the tool call and the raw result above the answer.
- The key is
mcp_servers, notmcpServers. Codex uses TOML, not JSON.[mcp.servers."name"]never connects. - No
typefield. Aurlkey makes the server Streamable HTTP. Acommandkey makes it stdio. - Server names take letters, numbers,
-and_only. Codex rejects the rest. - Project config needs trust. If
.codex/config.tomllooks ignored, the directory is not trusted. Move the server to~/.codex/config.toml. - Timeouts. Codex allows 10 seconds to start a server and 60 seconds per tool
call. Raise
startup_timeout_secon a slow link. - No OAuth. Do not run
codex mcp login sec-api. The key in the URL or in the bearer header is the whole authentication story. A bad key returns HTTP 401.
Trim the list when 49 tools crowd the context:
[mcp_servers.sec-api]
url = "https://api.sec-api.io/mcp?apiKey=YOUR_API_KEY"
enabled_tools = ["filing-search", "full-text-search", "extractor", "xbrl-to-json"]codex mcp remove sec-apiOr delete the [mcp_servers.sec-api] block from config.toml. Restart Codex.
Codex MCP guide and the Codex config reference, read 2026-08-13.