> ## Documentation Index
> Fetch the complete documentation index at: https://docs.danubeai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex CLI

> Connect the OpenAI Codex CLI to the Danube MCP Server

## Prerequisites

Codex CLI requires **Node.js 22+**. Install it from [nodejs.org](https://nodejs.org/).

Install Codex CLI globally:

```bash theme={null}
npm install -g @openai/codex
```

Verify the installation:

```bash theme={null}
codex --version
```

<Info>
  The Codex CLI and Codex IDE extension share the same `~/.codex/config.toml` configuration. If you've already set up Danube in the IDE extension, it will work in the CLI automatically.
</Info>

## Setup

<Steps>
  <Step title="Add the Danube MCP Server">
    Use the Codex CLI to add Danube as a Streamable HTTP server:

    ```bash theme={null}
    codex mcp add danube --url https://mcp.danubeai.com/mcp \
      --header "danube-api-key: YOUR_API_KEY"
    ```

    This writes the configuration to `~/.codex/config.toml`.
  </Step>

  <Step title="Verify Connection">
    Launch Codex CLI and use the `/mcp` command to verify the server is connected:

    ```bash theme={null}
    codex
    ```

    Then type:

    ```
    /mcp
    ```

    You should see `danube` listed with its available tools.
  </Step>
</Steps>

***

## Manual Configuration

You can also configure the server directly in `~/.codex/config.toml`:

```toml theme={null}
[mcp_servers.danube]
url = "https://mcp.danubeai.com/mcp"

[mcp_servers.danube.http_headers]
danube-api-key = "YOUR_API_KEY"
```

For project-scoped configuration, create `.codex/config.toml` in your project root instead.

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Command not found: codex">
    1. **Verify installation**:
       ```bash theme={null}
       npm list -g @openai/codex
       ```

    2. **Check npm global bin directory is in PATH**:
       ```bash theme={null}
       npm config get prefix
       ```
       The `codex` command should be in `{prefix}/bin/`

    3. **Add to PATH** (if needed):
       ```bash theme={null}
       export PATH="$(npm config get prefix)/bin:$PATH"
       ```
  </Accordion>

  <Accordion title="401 Unauthorized">
    * Verify your API key is correct
    * Ensure the header name is exactly `danube-api-key` (lowercase)
    * Generate a new API key from [danubeai.com/dashboard/api-keys](https://danubeai.com/dashboard/api-keys)
  </Accordion>

  <Accordion title="Connection timeout">
    * Check your internet connection
    * Verify the URL is correct: `https://mcp.danubeai.com/mcp`
    * Test the health check: `curl https://mcp.danubeai.com/mcp/health`
    * Increase the timeout in config: `startup_timeout_sec = 30`
  </Accordion>

  <Accordion title="Tools not appearing">
    * Run `/mcp` in Codex to check the server status
    * Verify the config file syntax: `cat ~/.codex/config.toml`
    * Restart Codex after configuration changes
  </Accordion>
</AccordionGroup>
