Connect with MCP

OpenAI Codex

One table in config.toml, shared by the Codex CLI, the IDE extension and the app.

Sections

You are connecting Codex to the Nexus402 gateway, one remote MCP server reached over streamable HTTP. You install nothing and host nothing. The Codex CLI, its IDE extension and the desktop app read the same configuration, so one entry serves all three. If you want to build and sell a tool instead, see Build a Server.

Prerequisites #

  • Codex installed and signed in.
  • A Nexus402 account with the developer role, and a funded wallet or trial credit. See Funding and spend.
  • An API key (nx_dev_…, shown once) with its own 24-hour spend cap. See Keys, caps and rotation.

Configure the connection #

Add a server table to ~/.codex/config.toml. env_http_headers maps a header to the name of an environment variable, so the key never sits in the file:

~/.codex/config.toml toml
[mcp_servers.nexus402]
url = "https://api.nexus402.dev/v1/mcp"
env_http_headers = { "X-Nexus-Api-Key" = "NEXUS402_API_KEY" }
# A creator's tool may run for up to two minutes through the gateway;
# Codex's own default per-tool limit is 60 seconds.
tool_timeout_sec = 130
Set the key before starting Codex bash
export NEXUS402_API_KEY="nx_dev_..."
  • Edit the file rather than using codex mcp add. Its --url form has a flag for a bearer token but none for a custom header, and the gateway's key is a custom header.
  • Do not use bearer_token_env_var. It sends the key as Authorization: Bearer, and the gateway refuses an nx_dev_ key there with 400 Authorization_Rejected, because Authorization is passed through to creators.
  • If the variable is unset or empty, Codex silently sends no header. The gateway then answers 401, which Codex reports as a login problem (below).
  • http_headers = { "X-Nexus-Api-Key" = "nx_dev_..." } also works, with the key in the file. Keep that file private.
  • A project .codex/config.toml is read only in a project you have marked trusted.

Verify the connection #

Check it bash
codex mcp list            # nexus402 should be listed and enabled
codex mcp get nexus402    # its URL and settings

In the Codex TUI or the app, /mcp shows each server and its tools. To rule Codex out, ask the gateway directly; tools/list is never billed:

Check the key without Codex bash
curl -s https://api.nexus402.dev/v1/mcp \
  -H "X-Nexus-Api-Key: $NEXUS402_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Use the tools #

Ask Codex for what you need, or name the tool. Codex names each tool mcp__nexus402__… and replaces every character other than letters, digits and _ with _ — hyphens included — so acme/weather/forecast appears as mcp__nexus402__acme_weather_forecast. The call still reaches the original name, and the gateway accepts the tool's listed name, acme_weather_forecast, as well. Two names that clean to the same text get a short hash suffix to tell them apart.

  • Each call is billed once at the tool's fixed price to the wallet behind the key; a tool with free calls costs nothing until they run out.
  • enabled_tools and disabled_tools in the server table narrow what Codex offers the model, by the gateway's tool name. For a limit the gateway enforces, scope the key instead.
  • enabled = false switches the server off without deleting it.

Common errors #

What you seeLikely causeFix
"The nexus402 MCP server is not logged in. Run codex mcp login nexus402."The gateway answered 401. It does not use OAuth, so codex mcp login will not help: the key is missing, wrong, revoked or expired, or the variable was not setRun the curl check. Export NEXUS402_API_KEY in the shell Codex starts from
"timed out after N seconds"The connection did not finish within startup_timeout_sec (10 s by default)Check the network path to api.nexus402.dev; raise startup_timeout_sec if it is only slow
A tool call times out after 60 secondsCodex's default tool_timeout_sec is shorter than the gateway's two minutesSet tool_timeout_sec as in the example
Authorization_Rejected (400)The key was sent as a bearer tokenUse env_http_headers, not bearer_token_env_var
Budget_Exhausted (402)The wallet cannot cover the call, or the key's 24-hour cap would be exceededAdd funds or raise the cap. Nothing was charged
Upstream_Unavailable (502)The creator's endpoint failed or timed outRetry later. You were not charged

Install agent tools

Help your coding agent stay on track when building with Nexus402. Learn more

Paste this into Claude Code, Codex or Cursor. Your agent connects itself to Nexus402 and adds the skills, for whichever tool it is.

Prompt for your agent text
Set up Nexus402 for me in this coding agent.
1. Read https://www.nexus402.dev/docs/agents.md and work out which tool you are (Claude Code, Codex or Cursor).
2. Add the Nexus402 MCP server https://api.nexus402.dev/v1/mcp the way that page shows for your tool, sending the X-Nexus-Api-Key header from the NEXUS402_API_KEY environment variable.
3. Install the skills listed at https://www.nexus402.dev/.well-known/skills/index.json where your tool keeps skills or rules.
Never write my key into a file, a commit or a reply. If NEXUS402_API_KEY is not set, stop and tell me to set it.
Then check the connection lists tools, and tell me what you changed.

Connect the gateway, then add the two skills.

Terminal bash
claude mcp add --transport http --scope user nexus402 https://api.nexus402.dev/v1/mcp \
  --header "X-Nexus-Api-Key: $NEXUS402_API_KEY"

mkdir -p ~/.claude/skills/nexus402-tools && curl -fsSL https://www.nexus402.dev/.well-known/skills/nexus402-tools/SKILL.md -o ~/.claude/skills/nexus402-tools/SKILL.md
mkdir -p ~/.claude/skills/nexus402-endpoint && curl -fsSL https://www.nexus402.dev/.well-known/skills/nexus402-endpoint/SKILL.md -o ~/.claude/skills/nexus402-endpoint/SKILL.md

Add the gateway to ~/.codex/config.toml, then add the skills with npx skills add https://www.nexus402.dev.

~/.codex/config.toml toml
[mcp_servers.nexus402]
url = "https://api.nexus402.dev/v1/mcp"
env_http_headers = { "X-Nexus-Api-Key" = "NEXUS402_API_KEY" }
tool_timeout_sec = 130
Add to Cursor

Opens Cursor and asks to add the gateway. Your key is read from NEXUS402_API_KEY.

Or add it by hand to ~/.cursor/mcp.json. Then add the skills with npx skills add https://www.nexus402.dev.

~/.cursor/mcp.json json
{
  "mcpServers": {
    "nexus402": {
      "url": "https://api.nexus402.dev/v1/mcp",
      "headers": {
        "X-Nexus-Api-Key": "${env:NEXUS402_API_KEY}"
      }
    }
  }
}

Skills-only installs don't update automatically.

Terminal bash
npx skills add https://www.nexus402.dev

Every option reads your key from NEXUS402_API_KEY; none writes it into a file. Learn more