Connect Codex
Add the EDEXTRON MCP server to Codex CLI with your AI key kept in an environment variable.
Codex reads your AI key from an environment variable, so the key never appears in the Codex config file or in your prompts.
1. Create a key
In the dashboard, open Connect AI. Enter a Key name (for example "Codex laptop"), choose the Permissions, and press Create key. Copy the key (it starts with edx_). It is shown only once.
2. Store the key in EDEXTRON_TOKEN
The variable must exist in the process that launches Codex. Type the key at a hidden prompt rather than pasting it into a command, so it doesn't end up in your shell history.
Windows (PowerShell)
$secure = Read-Host "EDEXTRON key" -AsSecureString
$plain = [System.Net.NetworkCredential]::new("", $secure).Password
setx EDEXTRON_TOKEN $plain | Out-Null
Remove-Variable plain, secure
setx saves the variable for new terminals only. Close this terminal and open a new one before you continue.
(The dashboard also shows the short form setx EDEXTRON_TOKEN "<key>". It works, but it leaves the key in your PowerShell history.)
macOS / Linux (bash or zsh)
mkdir -p ~/.config/edextron
printf 'EDEXTRON key: '; read -rs key; echo
(umask 077; printf '%s' "$key" > ~/.config/edextron/token); unset key
echo 'export EDEXTRON_TOKEN="$(cat ~/.config/edextron/token)"' >> ~/.bashrc
If you use zsh (the macOS default), add the export line to ~/.zshrc instead. Then open a new terminal, or run source ~/.bashrc.
Apps started from a desktop launcher (not from a terminal) may not see variables from ~/.bashrc or ~/.zshrc. If Codex reports a missing variable, start it from a terminal.
3. Add the server
Run this in a terminal where EDEXTRON_TOKEN is set:
codex mcp add edextron --url https://mcp.edextron.com/mcp --bearer-token-env-var EDEXTRON_TOKEN
Codex stores only the variable name in its config. Check it with:
codex mcp list
4. Try it
Start Codex and ask:
List my EDEXTRON devices.
Turn on relay 1 on Living room.
Codex calls list_devices and then set_relay. The switching tools are marked as non-read-only, so in interactive mode Codex normally asks for your approval before it switches a relay. Read-only tools such as list_devices are marked read-only.
For better behaviour, paste the prompt from Prompt for your AI on the Connect AI page as your first message, or put it in AGENTS.md. It contains no key.
Common problems
| Symptom | Fix |
|---|---|
Codex can't find EDEXTRON_TOKEN |
Open a new terminal after setx, or check echo $EDEXTRON_TOKEN / $env:EDEXTRON_TOKEN |
401 "Invalid or expired API key." |
The key was revoked or mistyped. Create a new key and store it again |
| "AI control is disabled for this relay." | Turn on Allow AI control for that relay in the dashboard |
| "This API key does not permit this operation." | The key lacks a permission. Create a key with the right Permissions |
More: MCP tools reference and Troubleshooting.