[BUG] Codex: stdio MCP env ${VAR} written as plaintext into .codex/config.toml instead of using env_vars

Aperta Adatta ai principianti
#3,393 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@abhishekacharya200 ci sta già lavorando.

Dal 28/10/2026.

  • #3406 di @abhishekacharya200 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
69/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Inizia verificando come la destinazione Codex scrive la configurazione stdio di MCP in .codex/config.toml e come gestisce i valori dell’ambiente. Confronta la gestione HTTP esistente di bearer_token_env_var, aggiunta per #3042. Il lavoro è completato quando un valore ${VAR} con lo stesso nome viene emesso come env_vars senza scrivere il valore della variabile nella configurazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type/bug

Describe the bug
When a stdio MCP server reads its token from an environment variable, the Codex target writes the token's value into .codex/config.toml. That file sits in the repo, so it's easy to commit a secret by accident. If the variable isn't set during install, you get the literal ${FIGMA_API_KEY} instead, and Codex passes that string to the server as-is.

Codex can already forward variables to stdio servers with env_vars, so the token never needs to be written down. APM already does this for HTTP headers since #3042 (bearer_token_env_var).

To Reproduce

  1. In apm.yml:
    targets: [codex]
    dependencies:
      mcp:
        - name: figma
          registry: false
          transport: stdio
          command: npx
          args: ["-y", "figma-developer-mcp", "--stdio"]
          env:
            FIGMA_API_KEY: "${FIGMA_API_KEY}"
    
  2. Run FIGMA_API_KEY=example-token apm install.
  3. .codex/config.toml now contains FIGMA_API_KEY = "example-token".

Expected behavior

[mcp_servers.figma]
command = "npx"
args = ["-y", "figma-developer-mcp", "--stdio"]
env_vars = ["FIGMA_API_KEY"]

That is, when the value is just ${VAR} and the key has the same name, use env_vars instead of writing the value. Other cases could keep today's behaviour with a warning, like #3042 does.

Environment:

  • OS: macOS (also seen with 0.33.0 on Linux)
  • Python Version: 3.14.3
  • APM Version: 0.35.0
  • VSCode Version (if relevant): n/a

Logs
No error; the install succeeds.

Additional context
Same problem as #3252, but for Codex. We work around it today by post-processing .codex/config.toml in our CI agent containers.


Lingua principale
Python
Stelle
4.2k
Fork
412
Merge medio
1g 6h
PR unite (30g)
66

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/apm

Tutte le issue di microsoft/apm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.