You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think codex doesn't support this yet, at least the same ${ENV_VAR} syntax didn't work for me. Currently I have to put secrets directly into ~/.codex/config.toml, I think?
Are you interested in implementing this feature?
No
Additional information
No response
Reacted by David Montoya, Ciprian Cimpan, YAMAMORI, Akihiro, Cory Hall, David Krasnitsky, Shankar Nakai Gonçalves dos Santos, Marcel Richter, Gasser Loïc, Steve, LimLLL and 14 more
I tried different syntaxes as well and couldn't manage to make environment variable interpolation work, so I believe Codex CLI does not yet support this feature indeed.
This kind of feature would be great when you need to share and sync Codex CLI config across multiple, possibly ephemeral, dev environments (e.g., devcontainers, Gihub Codespaces) while letting each machine manage its own secrets or instance specific params.
Reacted by Ciprian Cimpan, David Krasnitsky, Gasser Loïc, zhongwangninja, LimLLL and Vito Dinovi
I have a project-scoped MCP configuration where the server expects generic environment variable names such as OPENSEARCH_USERNAME and OPENSEARCH_PASSWORD.
For security, I do not want to place credential values in the project’s .codex/config.toml. I also do not want to require contributors to rename their existing locally managed environment variables just to match one MCP server’s expected names.
A supported expansion/alias mechanism would solve this cleanly, for example:
[mcp_servers.example.env]
OPENSEARCH_USERNAME = "${LOCAL_CLUSTER_A_OPENSEARCH_USERNAME}"OPENSEARCH_PASSWORD = "${LOCAL_CLUSTER_A_OPENSEARCH_PASSWORD}"or an explicit mapping form:
[mcp_servers.example]
env_vars = [
{ name = "OPENSEARCH_USERNAME", from = "LOCAL_CLUSTER_A_OPENSEARCH_USERNAME" },
{ name = "OPENSEARCH_PASSWORD", from = "LOCAL_CLUSTER_A_OPENSEARCH_PASSWORD" },
]
This would keep secrets out of repository-scoped configuration while allowing portable MCP configuration that uses the environment variable names required by the server.
Activity
masda70 commentedon Sep 2, 2025
I tried different syntaxes as well and couldn't manage to make environment variable interpolation work, so I believe Codex CLI does not yet support this feature indeed.
This kind of feature would be great when you need to share and sync Codex CLI config across multiple, possibly ephemeral, dev environments (e.g., devcontainers, Gihub Codespaces) while letting each machine manage its own secrets or instance specific params.
kossnocorp commentedon Oct 2, 2025
Env var expansion will help a lot with stuff like this:
GIT_CONFIG_GLOBALneeds to be absolute, so~/won't work.I have this in my dotfiles that automatically pulled in Dev Containers, so having project-specific config is not an option.
I currently have an Ansible playbook that solves this (that also merges local config), sharing it in case anyone needs a workaround:
I use such a script to run it:
LimLLL commentedon Dec 19, 2025
can't believe codex still doesn't support the env expansion......
jeroenwienk commentedon Feb 28, 2026
Really need this as well there is now way to have a shared config now.
michaelfrog commentedon Jun 30, 2026
What is the best workaround today? assuming i have dynamic url for remote MCP that i want to plant in plugin ?
Do not expand where Codex cannot
Make the gateway URL environment-aware (#3)
Q288: persist the Codex expansion measurement, PATH cut, with its kb …
starryeyez024 commentedon Sep 30, 2026
Any updates on this?
ghobadimhd commentedon Oct 21, 2026
I have a project-scoped MCP configuration where the server expects generic environment variable names such as
OPENSEARCH_USERNAMEandOPENSEARCH_PASSWORD.For security, I do not want to place credential values in the project’s
.codex/config.toml. I also do not want to require contributors to rename their existing locally managed environment variables just to match one MCP server’s expected names.A supported expansion/alias mechanism would solve this cleanly, for example:
This would keep secrets out of repository-scoped configuration while allowing portable MCP configuration that uses the environment variable names required by the server.