Codex CLI
Before you start
- A Nexara workspace at
https://app.nexara.ac(Enterprise instances: use your own address). - An agent key: in the app open Agents, New agent, then Create agent and key. Copy the
nxc_key (shown once) and export it:export NEXARA_KEY=nxc_.... - The MCP URL is
https://app.nexara.ac/mcp.https://app.nexara.ac/w/<workspace>/mcpalso works and refuses keys from other workspaces.
Configure
Add to ~/.codex/config.toml:
[mcp_servers.nexara]
url = "https://app.nexara.ac/mcp"
bearer_token_env_var = "NEXARA_KEY"
and export the key in your shell profile:
export NEXARA_KEY="nxc_..."
Codex reads the bearer token from the environment at start-up. To expose only the read tools, add:
enabled_tools = ["context_bundle", "context_search", "context_get", "context_tree", "context_related", "context_whoami"]
Verify
Ask the agent to call context_whoami. It returns the agent name, workspace and grants. Or run:
curl -s https://app.nexara.ac/mcp \
-H "Authorization: Bearer $NEXARA_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"context_whoami","arguments":{}}}'
Hand off automatically when a session ends
Codex has no session-end hook, so run it through a small wrapper. When Codex exits, for any reason, the Nexara CLI writes an entry marked "Automatic note" to <scope>/handoff.md with your open tasks and the commits of the last 12 hours. It is skipped if the agent already wrote a note in the last 10 minutes.
# ~/.bashrc or ~/.zshrc
codexn() { codex "$@"; local rc=$?; NEXARA_HANDOFF_SCOPE="${NEXARA_HANDOFF_SCOPE:-projects/billing}" nexara handoff --auto </dev/null; return $rc; }
Use codexn instead of codex. Set NEXARA_HANDOFF_SCOPE per project (for example in a .envrc).
Troubleshooting
| Symptom | Cause |
|---|---|
401 invalid, expired or revoked token | Wrong key, key revoked, or a workspace lockdown bumped the token epoch. Mint a new key |
401 git tokens (nxg_) are not accepted on /mcp | You pasted a git token. Use an nxc_ agent key |
403 forbidden host or origin | The server has ALLOWED_HOSTS set and your Host header is not in it |
Tool result forbidden: ... | The agent's grant does not cover that Space, action or sensitivity. Widen it on the agent page |
Tool result step_up_required | The change needs a human with step-up; it was turned into a proposal |