
Conectar con Codex
Codex in VS Code or the terminal — config.toml with OAuth sign-in or a key in an environment variable.
Este contenido está disponible en inglés.
¿Qué MCP vas a conectar? Los comandos de abajo cambian según tu elección.
- 1
Install and sign in
In VS Code, install the official Codex extension from the marketplace and sign in with your ChatGPT/OpenAI account from the panel. The extension and the CLI share the same configuration, in ~/.codex/config.toml.
- 2
Add the NewAlgorithm server
Open config.toml (in the Codex panel: gear → Codex Settings → Open config.toml) and declare the server:
~/.codex/config.toml[mcp_servers.NewAlgorithm-TOTVS] url = "https://totvs.mcp.newalgorithm.io/mcp" - 3
Path 1 — OAuth sign-in
In the terminal, run the server sign-in. The browser opens the NewAlgorithm authorization page (app.newalgorithm.io) for you to authorize; Codex stores the credential on its own.
codex mcp login NewAlgorithm-TOTVS - 4
Generate your API key
Sign in to app.newalgorithm.io with your account, open Keys & apps and generate a key. It is shown only once: copy it and store it somewhere safe.
Key formatna_live_xxxxxxxxxxxxxxxxx - 5
Path 2 — key in an environment variable
To keep the key out of the file, store it in an environment variable and point Codex to it with bearer_token_env_var:
Environment variableWindows (PowerShell): setx NA_API_KEY "YOUR_API_KEY" macOS / Linux: echo 'export NA_API_KEY="YOUR_API_KEY"' >> ~/.zshrc # or ~/.bashrcResultado esperado: Close and reopen the terminal and VS Code — only then do the processes pick up the new variable.
- 6
And in config.toml
~/.codex/config.toml[mcp_servers.NewAlgorithm-TOTVS] url = "https://totvs.mcp.newalgorithm.io/mcp" bearer_token_env_var = "NA_API_KEY" - 7
Confirm in the Codex panel
The /mcp command lists the active MCP servers.
/mcpResultado esperado: NewAlgorithm-TOTVS Connected
bearer_token_env_var holds the NAME of the variable, not the key. That way anyone can read config.toml without exposing the secret.
Detalles de autenticación y herramientas en la Documentación.