mcdx — switch between Codex auth profiles
mcdx is a small CLI for switching between saved
OpenAI Codex login credentials, so you can
use personal and work accounts on the same machine.
It manages only:
~/.codex/auth.json
It does not copy config.toml, sessions, history, SQLite state, plugins, skills,
or temporary runtime files. Runtime state and config.toml stay owned by Codex
itself — after a switch, mcdx asks Codex to restart its app-server daemon so
the new credentials are actually picked up.
Requirements
- Python 3.10+
- The
codexCLI on yourPATH(used bymcdx add, and to reload the app-server daemon afteradd/switch)
Install
# Recommended: pipx (isolated environment, mcdx lands on your PATH)
pipx install mcdx
# Or plain pip
pip install --user mcdx
Published on PyPI.
Install from a clone
git clone https://github.com/zackaryjing/multi-account-codex
mkdir -p ~/.local/bin
ln -sf "$PWD/multi-account-codex/mcdx.py" ~/.local/bin/mcdx
chmod +x multi-account-codex/mcdx.py
Make sure ~/.local/bin is on your PATH.
Usage
mcdx save-current main # save your current login as a profile
mcdx add alt # log in with Codex device auth, saved as a profile
mcdx list # list saved profiles (* marks the active one)
mcdx current # show the active profile
mcdx switch main # switch the active Codex auth
mcdx remove old-name # delete a profile
mcdx rename a b # rename a profile
mcdx doctor # check paths, Codex binary and daemon status
mcdx add and mcdx switch accept:
| Flag | Effect |
|---|---|
-y, --yes |
answer yes to prompts, including the daemon restart |
--no-daemon-restart |
leave the Codex app-server daemon running as it is |
Where things live
Profiles are stored under:
~/.local/share/mcdx/profiles/<name>/
Each profile contains an auth.json copy and metadata.json. Credentials are
not encrypted — the profiles directory is created with 0700 permissions.
Environment overrides:
| Variable | Default | Purpose |
|---|---|---|
MCDX_CODEX_HOME |
~/.codex |
Codex home directory |
MCDX_DATA_HOME |
~/.local/share/mcdx |
mcdx data directory |
MCDX_CODEX_BIN |
codex |
Codex binary for add and daemon restarts |
Behavior
mcdx add <name>temporarily moves the active auth aside, runscodex login --device-auth, saves the resultingauth.json, and leaves the new profile active.mcdx switch <name>saves the current auth as_lastbefore switching.- Duplicate credentials are detected by
account_idandauth.jsonSHA-256. - Codex keeps a long-lived app-server daemon that reads
auth.jsononce at startup, and sessions talk to that daemon rather than to the file. Afteradd/switch, mcdx therefore runscodex app-server daemon restart; without it the daemon keeps serving the previous account no matter whatauth.jsonsays. mcdx asks first (default yes) when it can, and never restarts a daemon that is not running. Restarting interrupts any codex sessions live on that daemon, so scripts should pass-yto accept that, or--no-daemon-restartand reload later.
Development
python3 tests.py # run the test suite
License
Metadata
Release files for mcdx 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcdx-0.2.0.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcdx-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.4 kB
Release files / mcdx-0.2.0.tar.gz
| Download URL | mcdx-0.2.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a3fba9c8eed48b3ed447fa1d8bb671ef8174631fd6010c33828fb909c0b9a8e
|
|
BLAKE2b-256 checksum How to use checksums |
f4f92bb42c179f9713ed51453691014cbb3ce73680b10b7faea2ae8f4a2b2233
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|
Release files / mcdx-0.2.0-py3-none-any.whl
| Download URL | mcdx-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5c1187cf8a12c56a3a7aab91788296d68e918abd74e1b1f9745f4aa933e42f9
|
|
BLAKE2b-256 checksum How to use checksums |
f1b1285ef07b925bba3e354193f319fffbe8ddfda24da825e446883023a1ff2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.2
|