Codex CLI
Add twin memory to OpenAI's Codex CLI as a streamable HTTP MCP server in config.toml.
Add the server
Codex reads MCP servers from ~/.codex/config.toml. Add twin memory with its URL, the environment variable
that holds your key, and the end user as a static header:
[mcp_servers.twin-memory]
url = "https://api.twinmemory.dev/v1/mcp"
bearer_token_env_var = "TWIN_MEMORY_API_KEY"
http_headers = { "X-Twin-Account" = "user_42" }bearer_token_env_varnames an environment variable. Codex sends its value asAuthorization: Bearer ....http_headersholds headers with fixed values.env_http_headersmaps a header to an environment variable instead, for exampleenv_http_headers = { "X-Twin-Account" = "TWIN_ACCOUNT" }.
Set the key in the environment Codex runs in:
export TWIN_MEMORY_API_KEY="tm_..."Use a read key if Codex should only search and read: it cannot write or erase.
Use a read and write key if Codex should save what it learns: the server then lists memory_add too.
codex mcp add NAME --url URL also adds a server, but we could not confirm a flag for the bearer variable, so
set it in config.toml as above.
If no tools are listed, see Troubleshooting.
Sources checked 2026-10-21: learn.chatgpt.com/docs/extend/mcp?surface=cli.